Skip to content

Commit 059af28

Browse files
committed
scripts: make update-version.bash to not be sticky unless sha is passed
1 parent 2211be7 commit 059af28

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

scripts/update-version.bash

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
set -eo pipefail
44

5-
if [[ $# -ne 2 ]]; then
6-
echo "usage: $0 [version-file|version] [sha]"
5+
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
6+
echo "usage: $0 [version-file|version] [sticky-rev]"
77
exit 1
88
fi
99

@@ -23,25 +23,21 @@ fi
2323

2424
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
2525
SCRIPT_ROOT=$(realpath "$0")
26-
ROOT_SHA="${2:-master}"
26+
ROOT_REV="$2"
2727
ROOT_TS=""
2828

2929
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX)
3030
trap 'cd ; rm -rf $tmp_dir' EXIT
3131

3232
perform() {
3333
git clone "git://git.proxmox.com/git/$1.git" 2>/dev/null
34-
if [[ -z "$ROOT_TS" ]]; then
35-
if [[ "$ROOT_SHA" == "last" ]]; then
36-
ROOT_SHA="$2"
37-
fi
38-
REPO_REV=$(git -C "$1" rev-parse "$ROOT_SHA")
39-
ROOT_TS=$(git -C "$1" log -1 --format=%ct "$ROOT_SHA")
34+
35+
if [[ -z "$ROOT_REV" ]] || [[ -z "$ROOT_TS" ]]; then
36+
REPO_REV=$(git -C "$1" rev-parse "${ROOT_REV:-HEAD}")
37+
ROOT_TS=$(git -C "$1" log -1 --format=%ct "$REPO_REV")
4038
else
4139
while read REPO_TS REPO_REV; do
42-
if [[ $REPO_TS -le $ROOT_TS ]]; then
43-
break
44-
fi
40+
[[ $REPO_TS -le $ROOT_TS ]] && break
4541
done < <(git -C "$1" log --format="%ct %H")
4642
fi
4743

0 commit comments

Comments
 (0)