Closed TheZoker closed 9 months ago
I have the same opinion as @Tylerjet. Could you please change your PR (remove the line in .env
file and adjust the corresponding lines in script.sh
). After that we can merge that and change the docs for this optional parameter.
I implemented your suggestions :) Thanks for the review!
I started a review, please check this.
Also, we implemented some if-statements (like this or this) in order to update the .git
folder inside the config_backup
folder and by doing so be more flexible. Otherwise, the user will get an error in the following example scenario:
git_url=some-url.com
in .env
./script.sh
in order to push filesgit_url=some-other-url.com
in .env
./script.sh
again in order to push filesIn this case, git still tries to push the files to some-url.com
as the URL is not updated by itself. The if-statements check if the corresponding line inside the .env
file does not match with the information inside the ~/config_backup/.git
folder. So we need something like
if [[ "$git_url" != $(git remote get-url origin | sed command to grep the some-url.com url) ]];
Can't we just set the URL on every run like this?
git remote set-url origin $git_url
That way we don't have to check if the URL is different, we just always use the current set URL
ah that works as well hehe
I pushed you changes 👍
@TheZoker one last thing actually is the final lines from line ~61 - 64
# Check if remote origin changed and update when it is
if [[ "$github_repository" != $(git remote get-url origin | sed 's/https:\/\/.*@github.com\///' | sed 's/\.git$//' | xargs basename) ]]; then
git remote set-url origin https://"$github_token"@"$git_url"/"$github_username"/"$github_repository".git
if [[ "$full_git_url" != $(git remote get-url origin) ]]; then
git remote set-url origin "$full_git_url"
fi
fi
it should be
# Check if remote origin changed and update when it is
if [[ "$full_git_url" != $(git remote get-url origin) ]]; then
git remote set-url origin "$full_git_url"
fi
for some reason my suggestion didn't substitute the right section
Perfect!
I just saw that and was already fixing it, but this way it was faster :D
@Staubgeborener should be good to merge now!
Nice work!
A sample integration of the git URL parameter
Closes #54