Skip to content
Permalink
Browse files

Fix datefortag function to support signed tags.

The build process tries to read the date for a tag to use
in some timestamps.  That failed because I signed a tag.

The change here should support either signed or unsigned tags.
  • Loading branch information
smoser committed Mar 3, 2020
1 parent 1548dfa commit bd2da52d7d95af8f91c52f36c9611566e5a7589e
Showing with 5 additions and 3 deletions.
  1. +5 −3 bin/common-functions.sh
@@ -89,16 +89,18 @@ datefortag_bzr() {
}

datefortag() {
local spec="$1" fmt="${2:-+%Y%m%d}"
local spec="$1" fmt="${2:-+%Y%m%d}" commit=""
local repo="${CIRROS_GIT:-${CIRROS_BZR:-.}}"
if [ ! -d "$repo/.git" -a -d "$repo/.bzr" ]; then
datefortag_bzr "$@"
return
fi
spec=${spec//"~"/_} # git tags cannot contain ~
commit=$(git rev-parse "$spec^{commit}") ||
{ error "Failed to get commit for $spec"; return 1; }
ts=$( cd "$repo" &&
git show --no-patch "--pretty=format:%ct" "$spec") ||
{ error "failed to 'git show $spec' in $repo"; return 1; }
git show --no-patch "--pretty=format:%ct" "$commit") ||
{ error "failed to 'git show $commit' in $repo for $spec"; return 1; }
out=$(date --utc --date="@$ts" "$fmt") ||
{ error "failed to convert seconds '$ts' to format $fmt"; return 1; }
_RET="$out"

0 comments on commit bd2da52

Please sign in to comment.
You can’t perform that action at this time.