Skip to content

Commit 59b4c54

Browse files
authored
chore: fix git-tag-go-mod.sh (#156)
2 parents bb2c803 + 9b74b03 commit 59b4c54

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

.bin/git-tag-go-mod.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ __main__() {
3030

3131
trap "git switch -" EXIT
3232

33-
latest_git_tag=$(git tag --sort=committerdate | grep -E "^v[0-9]+" | tail -n 1)
34-
latest_git_tag_commit=$(git rev-list -n 1 "${latest_git_tag:?}")
33+
target_git_tag="${TARGET_GIT_TAG:-$(git tag --sort=committerdate | grep -E "^v[0-9]+" | tail -n 1)}"
34+
target_git_tag_commit=$(git rev-list -n 1 "${target_git_tag:?}")
3535

36-
git switch --detach "${latest_git_tag:?}"
36+
git switch --detach "${target_git_tag:?}"
3737
targets=$(
3838
find "${REPO_ROOT:?}" -name go.mod -print | # find go.mod
3939
sed "s@${REPO_ROOT:?}/@@g; s@/*go\.mod@@g" | # trim repo root path
@@ -44,14 +44,14 @@ __main__() {
4444
LogshInfo "targets:" "$(tr '\n' ' ' <<< "${targets:-none}")"
4545
if [ -n "${targets:-}" ]; then
4646
while read -r mod; do
47-
go_module_tag="${mod:?}/${latest_git_tag:?}"
47+
go_module_tag="${mod:?}/${target_git_tag:?}"
4848
if git tag --sort=committerdate | grep -qE "^${go_module_tag:?}$"; then
4949
# skip
5050
LogshInfo "$(printf "tag already exists: %s" "${go_module_tag:?}")"
5151
continue
5252
fi
5353
# add tag
54-
LogshExec git tag -a "${go_module_tag:?}" -m "${go_module_tag:?}" "${latest_git_tag_commit:?}"
54+
LogshExec git tag -a "${go_module_tag:?}" -m "${go_module_tag:?}" "${target_git_tag_commit:?}"
5555
done <<<"${targets:?}"
5656

5757
git push --tags

0 commit comments

Comments
 (0)