aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/git-sync
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/git-sync')
-rwxr-xr-xscripts/git-sync25
1 files changed, 18 insertions, 7 deletions
diff --git a/scripts/git-sync b/scripts/git-sync
index fa4d786..17db0f6 100755
--- a/scripts/git-sync
+++ b/scripts/git-sync
@@ -1,6 +1,7 @@
#!/bin/bash
set -eu
+verbose=0
hosthash=$(python3 -c "import uuid, hashlib
print(hashlib.new('sha1', str(uuid.getnode()).encode('utf8')).hexdigest())")
@@ -30,21 +31,27 @@ if [ "$(git config --get --bool branch.${branch_name}.sync)" != "true" ]; then
exit 1
fi
-echo 'Sync: git autocommit'
+if [ "$verbose" -ne 0 ]; then
+ echo 'Sync: git autocommit'
+fi
git add -A "./$(git rev-parse --show-cdup)"
if git status --porcelain | grep -q .; then
git status --short
git commit -m "Auto-commit on ${hosthash}"
fi
-echo 'Sync: fetch and merge'
+if [ "$verbose" -ne 0 ]; then
+ echo 'Sync: fetch and merge'
+fi
-git fetch
+git fetch --quiet
# might fail one time if conflict detected
git merge -m "$conflict_message" || true
-echo 'Sync: conflict autocommit'
+if [ "$verbose" -ne 0 ]; then
+ echo 'Sync: conflict autocommit'
+fi
git status --porcelain | while read -r filename; do
state="${filename:0:2}"
@@ -73,8 +80,12 @@ fi
# should not fail again
git merge -m "$conflict_message"
-echo 'Sync: pushing changes'
+if [ "$verbose" -ne 0 ]; then
+ echo 'Sync: pushing changes'
+fi
-git push
+git push --quiet
-echo 'Sync: done'
+if [ "$verbose" -ne 0 ]; then
+ echo 'Sync: done'
+fi