update: fix branch update
(cherry picked from commit dc1c7a8e423e0f42a3621199c43a6a1640b720a2)
This commit is contained in:
parent
57ab5d5de7
commit
40e9c9c08c
|
@ -9,6 +9,16 @@ fi
|
||||||
|
|
||||||
${log} "Updating the main repository to branch $BRANCH"
|
${log} "Updating the main repository to branch $BRANCH"
|
||||||
|
|
||||||
|
function auto_update(){
|
||||||
|
git fetch
|
||||||
|
UPDATE=$(git diff --numstat origin/$BRANCH scripts/bash/update.sh | awk '/update.sh/ {print $NF}')
|
||||||
|
if [[ -n "${UPDATE}" ]]; then
|
||||||
|
# Update the file and restart the script
|
||||||
|
git checkout origin/$BRANCH scripts/bash/update.sh
|
||||||
|
exec scripts/bash/update.sh $BRANCH
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function restart(){
|
function restart(){
|
||||||
sudo nginx -t && sudo systemctl reload nginx
|
sudo nginx -t && sudo systemctl reload nginx
|
||||||
sudo systemctl restart nodered.service
|
sudo systemctl restart nodered.service
|
||||||
|
@ -19,7 +29,13 @@ function update(){
|
||||||
sudo killall -15 raspimjpeg
|
sudo killall -15 raspimjpeg
|
||||||
sudo killall -15 python3
|
sudo killall -15 python3
|
||||||
git stash
|
git stash
|
||||||
git checkout --force $BRANCH
|
# TODO detect branch change and use git pull on same branch and checkout on diff branch
|
||||||
|
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
|
if [ "$CURRENT_BRANCH" -eq $BRANCH ]; then
|
||||||
|
git merge
|
||||||
|
else
|
||||||
|
git checkout --force $BRANCH
|
||||||
|
fi
|
||||||
git checkout stash@'{0}' -- config.json hardware.json
|
git checkout stash@'{0}' -- config.json hardware.json
|
||||||
# TODO we need to change this to drop stash@{1} if changes made to the flow are to be restored by the user
|
# TODO we need to change this to drop stash@{1} if changes made to the flow are to be restored by the user
|
||||||
git stash drop
|
git stash drop
|
||||||
|
@ -50,13 +66,7 @@ if [[ "$local" == "$remote" ]]; then
|
||||||
${log} "nothing to do!"
|
${log} "nothing to do!"
|
||||||
else
|
else
|
||||||
${log} "Local and Remote are different, we have to update!"
|
${log} "Local and Remote are different, we have to update!"
|
||||||
git fetch
|
auto_update
|
||||||
UPDATE=$(git diff --numstat origin/$BRANCH scripts/bash/update.sh | awk '/update.sh/ {print $NF}')
|
|
||||||
if [[ -n "${UPDATE}" ]]; then
|
|
||||||
# Update the file and restart the script
|
|
||||||
git checkout origin/$BRANCH scripts/bash/update.sh
|
|
||||||
exec scripts/bash/update.sh $BRANCH
|
|
||||||
fi
|
|
||||||
special_before
|
special_before
|
||||||
update
|
update
|
||||||
special_after
|
special_after
|
||||||
|
|
Loading…
Reference in a new issue