Skip to content

Commit 7dc108b

Browse files
googleaniviagvisor-bot
authored andcommitted
Fix errors when the tagging GitHub releases
When the commit description contains "commit ", it will be wrongly identified as commit hash. This commit changes to take only lines begins with "commit " as a fix, since the description is always indented by `git log`. Copybara uses merge commit for external contributors, this causes that not all commits contain a Piper ID. Adding `--first-parent` to `git log` so that it only lists commits that contain a Piper ID. PiperOrigin-RevId: 338183812
1 parent 16ba350 commit 7dc108b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/tag_release.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fi
4343

4444
closest_commit() {
4545
while read line; do
46-
if [[ "$line" =~ "commit " ]]; then
46+
if [[ "$line" =~ ^"commit " ]]; then
4747
current_commit="${line#commit }"
4848
continue
4949
elif [[ "$line" =~ "PiperOrigin-RevId: " ]]; then
@@ -57,7 +57,9 @@ closest_commit() {
5757
# Is the passed identifier a sha commit?
5858
if ! git show "${target_commit}" &> /dev/null; then
5959
# Extract the commit given a piper ID.
60-
declare -r commit="$(git log | closest_commit "${target_commit}")"
60+
commit="$(set +o pipefail; \
61+
git log --first-parent | closest_commit "${target_commit}")"
62+
declare -r commit
6163
else
6264
declare -r commit="${target_commit}"
6365
fi

0 commit comments

Comments
 (0)