summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xacid/cyche-source20
-rwxr-xr-xacid/cychedelic7
2 files changed, 16 insertions, 11 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"
diff --git a/acid/cychedelic b/acid/cychedelic
index 4e26b99..273a041 100755
--- a/acid/cychedelic
+++ b/acid/cychedelic
@@ -23,9 +23,12 @@ update() {
for line in "${CYCHE_SERVICES[@]}"; do
read -r -a arr <<< "$line"
hash=$(cyche-source ${arr[@]:0:3})
+ res=$?
- if [ $? -ne 0 ] || [ "$1" == "$forceopt" ]; then
- cyche-build "${arr[0]}" "${arr[3]}" "$hash" $selfopt
+ if [ $res -ne 2 ]; then
+ if [ $res -eq 1 ] || [ "$1" == "$forceopt" ]; then
+ cyche-build "${arr[0]}" "${arr[3]}" "$hash" $selfopt
+ fi
fi
forceopt="--force"