aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2021-01-06 21:36:50 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2021-01-06 21:36:57 -0800
commit2a16fcdcdf721bcf21d47850ad0d6fc5507490ed (patch)
treed7bb5cc865b65668a4c8d849471c0e9701decad2
parentDowngrade to docker-compose file version 2.4. (diff)
downloadsoko-2a16fcdcdf721bcf21d47850ad0d6fc5507490ed.tar.gz
soko-2a16fcdcdf721bcf21d47850ad0d6fc5507490ed.tar.bz2
soko-2a16fcdcdf721bcf21d47850ad0d6fc5507490ed.zip
bin: make updates more reliable and faster
`git pull --rebase` has many corner cases where it tries to do a "safe" update and may leave the working tree in a unsuitable state for automated processes. Since the working git repo is meant to be entirely automated, split it out to a git-fetch of just the branch we need, and then forcibly reset the tree content to the tip of that branch after each fetch. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rwxr-xr-xbin/fullupdate.sh17
-rwxr-xr-xbin/update.sh17
2 files changed, 30 insertions, 4 deletions
diff --git a/bin/fullupdate.sh b/bin/fullupdate.sh
index 5922c24..55f1025 100755
--- a/bin/fullupdate.sh
+++ b/bin/fullupdate.sh
@@ -1,13 +1,26 @@
#!/bin/bash
+: "${GIT_URI:=https://anongit.gentoo.org/git/repo/gentoo.git}"
+: "${GIT_BRANCH:=master}"
+: "${GIT_REMOTE:=origin}"
+
update_repository(){
# This is the copy of the tree used to run gpackages against.
if [[ ! -d /mnt/packages-tree/gentoo/ ]]; then
cd /mnt/packages-tree || exit 1
- git clone https://anongit.gentoo.org/git/repo/gentoo.git
+ git clone \
+ --quiet \
+ --single-branch \
+ --branch "${GIT_BRANCH}" \
+ --origin "${GIT_REMOTE}" \
+ "${GIT_URI}"
else
cd /mnt/packages-tree/gentoo/ || exit 1
- git pull origin master --rebase &>/dev/null
+ if [ "$(git remote get-url "${GIT_REMOTE}")" != "${GIT_URI}" ]; then
+ git remote set-url "${GIT_REMOTE}" "${GIT_URI}"
+ fi
+ git fetch --quiet --force "${GIT_REMOTE}" "${GIT_BRANCH}"
+ git reset --quiet --hard
fi
}
diff --git a/bin/update.sh b/bin/update.sh
index 801ef7d..b6bae12 100755
--- a/bin/update.sh
+++ b/bin/update.sh
@@ -1,13 +1,26 @@
#!/bin/bash
+: "${GIT_URI:=https://anongit.gentoo.org/git/repo/gentoo.git}"
+: "${GIT_BRANCH:=master}"
+: "${GIT_REMOTE:=origin}"
+
update_repository(){
# This is the copy of the tree used to run gpackages against.
if [[ ! -d /mnt/packages-tree/gentoo/ ]]; then
cd /mnt/packages-tree || exit 1
- git clone https://anongit.gentoo.org/git/repo/gentoo.git
+ git clone \
+ --quiet \
+ --single-branch \
+ --branch "${GIT_BRANCH}" \
+ --origin "${GIT_REMOTE}" \
+ "${GIT_URI}"
else
cd /mnt/packages-tree/gentoo/ || exit 1
- git pull origin master --rebase &>/dev/null
+ if [ "$(git remote get-url "${GIT_REMOTE}")" != "${GIT_URI}" ]; then
+ git remote set-url "${GIT_REMOTE}" "${GIT_URI}"
+ fi
+ git fetch --quiet --force "${GIT_REMOTE}" "${GIT_BRANCH}"
+ git reset --quiet --hard
fi
}