summaryrefslogtreecommitdiffstats
path: root/acid/cyche-source
diff options
context:
space:
mode:
Diffstat (limited to 'acid/cyche-source')
-rwxr-xr-xacid/cyche-source20
1 files changed, 11 insertions, 9 deletions
diff --git a/acid/cyche-source b/acid/cyche-source
index dd290ac..e53ef6f 100755
--- a/acid/cyche-source
+++ b/acid/cyche-source
@@ -6,12 +6,14 @@
# <name> doesn't exist. If updates are found, we attempt to checkout the newest
# version according to <ref-pattern> (see <pattern> from git-for-each-ref(1)).
#
-# The new (or current, if no update occurred) object hash is printed to stdout.
-# This may be a commit hash. However, if <ref-pattern> matches an annotated tag,
-# then the hash names the tag object. The caller should cache this hash value
-# upon successful deployment.
+# On a successful run, the new object hash is printed to stdout (or the previous
+# hash, if no update occurred). This may be a commit hash. However, if
+# <ref-pattern> matches an annotated tag, then the hash refers to the tag object.
+# The caller should cache this hash value upon successful deployment.
#
-# If the file tree is updated, this file exits non-zero.
+# If a new version of the file tree is checked out, this file exits with code 1,
+# otherwise a stale success exits with 0. On any error, no hash is printed, and
+# we exit with 2.
gethash() {
git for-each-ref \
@@ -24,7 +26,7 @@ gethash() {
cd '/services'
if ! [ -d "$1" ]; then
- git clone "$2" "$1" >&2
+ git clone "$2" "$1" >&2 || exit 2
touch "$1/.git/previous_hash"
touch "$1/.git/previous_slug"
fi
@@ -32,14 +34,14 @@ fi
cd "$1"
git remote set-url origin "$2" >&2 # pick up url changes
-git fetch --all --prune >&2
+git fetch --all --prune >&2 || exit 2
prev=$(cat '.git/previous_hash')
next=$(gethash "$3")
if [ -z "$next" ]; then
- # no matching refs
- next="$prev"
+ echo "No refs match $3" >&2
+ exit 2
fi
echo "$next"