From 8c9abfb419f32aae0008683cb04b918039512951 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Fri, 17 Nov 2023 04:35:54 -0500 Subject: acid: source: Only record commit hashes Previously, the object hash computed by `git for-each-ref` was the value we cached in the 'previous_hash' file. If the matching ref was an annotated tag, then this was the tag's hash, not the commit hash it pointed to. Now, always dereference tags to their commit object, and store this value instead. This consistency will improve the web UX in my opinion. Signed-off-by: Malfurious --- acid/acid-source | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/acid/acid-source b/acid/acid-source index 8242452..d03076f 100755 --- a/acid/acid-source +++ b/acid/acid-source @@ -6,21 +6,22 @@ # doesn't exist. If updates are found, we attempt to checkout the newest # version according to (see from git-for-each-ref(1)). # -# 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 -# matches an annotated tag, then the hash refers to the tag object. -# The caller should cache this hash value upon successful deployment. +# On a successful run, the new commit hash is printed to stdout (or the previous +# hash, if no update occurred). The caller should cache this hash value upon +# successful deployment. # # 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, the null hash is # printed, and we exit with 2. gethash() { - git for-each-ref \ + obj=$(git for-each-ref \ --count=1 \ --format='%(objectname)' \ --sort='-creatordate' \ - "$1" # pattern + "$1") # pattern + + git rev-parse --quiet --verify "$obj^{commit}" } fail() { -- cgit v1.2.3