summaryrefslogtreecommitdiff
path: root/bin/common/gt-sync
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-01 16:07:29 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-07-01 16:07:29 +0200
commit30a898e1040ec91cea1ceeb2180bdcf7265f2407 (patch)
tree027b532b59f44afc2d6bbb598f9f7998cb97f764 /bin/common/gt-sync
parent9d91de38af90ee1d4033666d10613eb03f3d747f (diff)
checkpoint
Diffstat (limited to 'bin/common/gt-sync')
-rwxr-xr-xbin/common/gt-sync21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/common/gt-sync b/bin/common/gt-sync
new file mode 100755
index 0000000..0dc986c
--- /dev/null
+++ b/bin/common/gt-sync
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+# Print if repo is out of sync or not
+
+# path to repo
+repo="$1"
+# remote for repo
+remote="$2"
+[ "$#" -lt 2 ] && exit 1
+
+repo_pretty="$(printf '%s' "$repo" | sed "s@$HOME@~@")"
+
+ref="$(git -C "$repo" symbolic-ref HEAD)"
+local_hash="$(git -C "$repo" rev-parse "$ref")"
+remote_hash="$(git ls-remote "$remote" "$ref" | cut -f 1)"
+
+if [ "$remote_hash" != "$local_hash" ]; then
+ printf '%s: x\n' "$repo_pretty"
+else
+ printf '%s: o\n' "$repo_pretty"
+fi