Skip to content

Commit

Permalink
Merge branch 'git-shallow'
Browse files Browse the repository at this point in the history
* git-shallow:
  MISC: mknews.sh: create NEWS in forward order
  MISC: mknews.sh: handle repos without tags
  MISC: mkassets.sh: fallback to building in /tmp/anklang.tmp/
  MISC: version.sh: support git repos without tags

Signed-off-by: Tim Janik <[email protected]>
  • Loading branch information
tim-janik committed Nov 22, 2023
2 parents 80927e0 + f7deff5 commit bdb8273
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions misc/mkassets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ set -Eeuo pipefail -x && SCRIPTNAME=${0##*/} && die() { [ -z "$*" ] || echo "$SC

grep ' Anklang ' ./README.md || die 'failed to find Anklang project'

# Usage: mkrelease.sh [RELEASE_BUILDDIR]
# Usage: mkassets.sh [BUILDDIR]
# Make dist tarball and build release assets from it.
BUILDDIR="${1:-/tmp/anklang/}"
BUILDDIR="${1:-/tmp/anklang.tmp/}"

# Clear assets and builddir
rm -rf assets $BUILDDIR
Expand Down Expand Up @@ -38,5 +38,5 @@ test ! -r config-defaults.mk ||

# Fetch release assets and cleanup
cp $BUILDDIR/assets/* ./assets/
test "$BUILDDIR" == /tmp/anklang/ && rm -rf /tmp/anklang/
test "$BUILDDIR" == /tmp/anklang.tmp/ && rm -rf /tmp/anklang.tmp/
ls -l assets/*
4 changes: 3 additions & 1 deletion misc/mknews.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ fetch_news_version() # fetch_news_version {1|2}
}
NEWS_TAG="v$(fetch_news_version 1)"

# Work around repos without tags
git rev-parse --verify "$NEWS_TAG" 2>/dev/null || NEWS_TAG=`git log --reverse --format=%H | sed -n '1p' `

# Just print topmost NEWS.md version
test " ${1:-}" == " --version" && {
echo "$NEWS_TAG"
Expand All @@ -47,7 +50,6 @@ else
echo
echo '``````````````````````````````````````````````````````````````````````````````````````'
git log --pretty='%s # %cd %an %h%n%w(0,4,4)%b' \
--reverse \
--first-parent --date=short "$NEWS_TAG..HEAD" |
sed -e '/^\s*Signed-off-by:.*<.*@.*>/d' |
sed '/^\s*$/{ N; /^\s*\n\s*$/D }'
Expand Down
6 changes: 3 additions & 3 deletions misc/version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ if ! [[ "$HASH" =~ ^[0-9a-f]+$ ]] ; then # checks proper hash
DESCRIBE=
if test -e "${ABSPATHSCRIPT%/*}"/../.git ; then # fetch version from live git
HASH=$(git log -1 --pretty="tformat:%H")
DESCRIBE=$(git describe --tags --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/dev/null || git describe --match='v[0-9]*.[0-9]*.[0-9]*')
DESCRIBE=$(git describe --tags --match='v[0-9]*.[0-9]*.[0-9]*' --exact-match 2>/dev/null || git describe --match='v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null) || DESCRIBE=""
VDATE=$(git log -1 --pretty="tformat:%ci")
fi
fi

# == Fallback version ==
if test -z "$DESCRIBE" ; then
HASH=0000000000000000000000000000000000000000
if test -z "$DESCRIBE" ; then # triggered by e.g. forks
HASH=$(git log -1 --pretty="tformat:%H" 2>/dev/null) || HASH=0000000000000000000000000000000000000000
DESCRIBE=v0.0.0-snapshot0
VDATE="2001-01-01 01:01:01 +0000"
fi
Expand Down

0 comments on commit bdb8273

Please sign in to comment.