Thalhammer JWT CPP latest update breaks Docker Compose - c++

The JWT CPP Above has been updated to v0.7.0-rc.0 and with the update they changed the use of get_payload_claims() to get_payload_json(). I wish it was as simple as to just use the later in the code but it isn't. So I am trying to clone it through a docker file but I would like to use the previous version (v0.6.0) as the program worked with that version.
This was the original line of code in the docker file:
RUN git clone https://github.com/Thalhammer/jwt-cpp.git
But that causes it to use the latest version of the repo. I did some googling and found the following methods of doing it:
RUN git clone --depth 1 --branch v0.6.0 https://github.com/Thalhammer/jwt-cpp.git
RUN git checkout v0.6.0
I also tried clearing the cache and running docker fresh with this:
docker system prune -a
However, none of these have worked. When I try to compose in Docker I still get the get_payload_claims() doesn't exist meaning it's still the newer version. How do I use the previous version of the repo?

Related

How to add a new pip package to the project?

I'm working in a project generated by cookiecutter-django localy using docker, I wanted to add new packeges, what is the best aproche to perform this?
I'm actually copying the version of the package and pasting into the base requirements file and building the local.yaml contener again and it's seams to be rebuilding the entire containers in the project instead of building only the container that changes has been detected. So i don't if my aproche is the best, so please help me acheive this
Given how you tagged the question, I assume you want to add a new Python package to a project that was generated using cookiecutter-django.
I think that the way you're doing it is correct. To be 100% clear, you need to:
Edit the requirement file where you want it installed:
local.txt for local only
production.txt for production only
base.txt for both
Rebuild your containers: docker-compose -f local.yml build
Restart your containers: docker-compose -f local.yml up -d
The 2nd step may feel a bit heavy, as it would reinstall all the Python packages, not the just the new one, but AFAIU that's how Docker works.
Hope that helps!

git fork from certain tag version - requirements.txt

I want to fork one github project code, but not from master branch, but from older release.
Reason: I want to edit one place in the code in my fork version and put the url of this tag version into my requirements.txt so that
pip install -e git+https://git_url_to_my_form_in_this_tag_version
works.
I found the tag version in github, but once I fork it, it is being forked from master and not from exactly that tag.
how can I do it?
Forking the repository clones the entire repository, not just the master branch. You can then checkout the tag you want to work on, make the required changes, and create a new tag.
# checkout the tag
git checkout tag_to_fork_from
# alternatively, create a new branch starting with the tag
git checkout -b mybranch tag_to_fork_on

Add an existing origin to a django project and pull the existing repo in it.

I am new to GIT hub version Controlling System.
I am working on a project which i downloaded as zip from GIT hub. It is not a git repository. What i want to do is that I want to make it a git repository and want to pull the existing git repository in it when issuing a git pull command.
I want to create my own Development Branch, develop code on local, push code to github, then do a pull request
Help will be highly appreciated.
Since you don't have any history of your changes to preserve I think your best bet is to clone the repo normally, and then copy your changes into that repository. Your question is a bit sparse on details, but something like the following should work
git clone <git hub project> <new folder on your system>
# maybe you can use a tag here for the SHA
git checkout -b my_branch SHA_THAT_REPRESENTS_YOUR_ZIP_DOWNLOAD
cp -r <your existing directory> <your new git repository>
git status # abort if this step doesn't look right
git add # add all your changed files
git commit # commit your work
git rebase <main dev branch> # catch up

post_receive hook in git: how does it checkouts my non-git folder?

I am using webfaction for my web deployment.
I have a Django app at: webapps/django_app/project_name/
I have a Git repo at: webapps/git_app/repos/my_repo.git
my_repo.git is a bare repository. It is not a working directory.
whenever I push from my local development computer to the remote (webfaction --> my_repo.git), I want my django_app to get the pushed code.
I followed this post which works fine. But no explanation of how this works is given.
I have added these two lines in post_recieve hook in my_repo.git.
#!/bin/sh
GIT_WORK_TREE=/home/username/webapps/django/myproject git checkout -f
GIT_WORK_TREE=/home/username/webapps/django/myproject git reset --hard
what does this two lines actually do?
Moreover, my Djangoapp folder is not a git repo. still whenever push is made to my_repo.git, Djangoapp gets updated. so how does it work?
When you are managing files locally with .git, you typically have two things:
Your git repository, which is contained in the .git directory, and
Your work tree, which is the set of files you are actually editing.
By default, the repository is a subdirectory of the work tree, but this is not a requirement. Setting the GIT_WORK_TREE environment variable directs git to use a different location for your checkout out files.
So the first line...
GIT_WORK_TREE=/home/username/webapps/django/myproject git checkout -f
...is asking git to check out the HEAD of the repository into /home/username/webapps/django/myproject.
The second line...
GIT_WORK_TREE=/home/username/webapps/django/myproject git reset --hard
...makes sure that /home/username/webapps/django/myproject does not have any local changes. reset --hard discards any changes to files that are tracked by git. By "local changes" I mean any changes that you or someone else has made to files in this directory; ideally, there won't be any, but if there were some there, reset -f makes sure that the modified files are overwritten with the version of the file stored in the repository.
For more details on any of the commands listed here, try running git <command> --help for the man page, or see The Git Book.

Why is git not pushing contents of a folder?

After copying a folder 'myapp' into to my working folder, I do the following to add it to my staging area:
git add .
and then commit the changes:
git commit
Then I push my changes to Heroku:
git push heroku master
So my folder, called 'myapp' is present on heroku, but the problem is that it's completely empty.
When I do the following,
git clone myapp myapp2
the folder clones properly on my local machine with all expected subcontents.
Does anyone know why the subfolders' contents are not being pushed to Heroku properly? What am I doing wrong?
To answer the questions below:
I am doing the git add . in my top level folder (the folder that contains folder myapp). Doing git status shows `no changes added to commit (use "git add" and/or "git commit -a")
Yes, myapp contains files/folders (my django project)
I deleted my .gitignore file because I placed my virtual environment in another place altogeher so it's no longer in my project folder so I don't think that's affecting it.
Ok, I seemed to have solved the problem. Somehow git got in a weird state. I don't really understand how, but for some reason it wasn't adding any of the files in the folder.
I simply copied that folder and gave it a new name, and then followed the exact same process I had been doing all along, and it finally uploaded properly.
By default, you cannot push changes to a checked-out branch of a repository. It usually causes major problems! Here is what usually happens:
$ git push heroku master
...error messages...
To heroku
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'heroku'
Since you haven't mentioned any error messages, I'm assuming that you've added the following to your heroku repository configuration, or you're running a fairly old version of Git:
[receive]
denyCurrentBranch = false
It sounds like you want to check out a fresh copy of the master branch whenever you push a new version to your heroku repository. That can be achieved with a post-receive hook. Create a file in your heroku repository .git/hooks/post-receive, and give it +x permissions.
#!/bin/sh
while read oldrev newrev refname
do
if test "$refname" = refs/heads/master
then
( cd ..; GIT_DIR=.git; git reset --hard )
fi
done
Now, whenever you push a new master branch to heroku, the hook will run and check out the new branch. There are better ways to do this kind of thing, but this is simple.
Summary: By default, when you push changes, it only changes the history but not the working tree. The assumption is that someone might be working on that tree, so doing anything to it could be destructive.