Skip to content

Commit

Permalink
tag: Support tagging against latest prep commit
Browse files Browse the repository at this point in the history
In the event that there are multiple commits in the tree for the target
release version, pick the top one; Complain along the way though.

Signed-off-by: Joe Stringer <[email protected]>
  • Loading branch information
joestringer authored and aanm committed Jan 22, 2025
1 parent 546fec6 commit fca638c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/release/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,23 @@ func (pc *TagCommit) Run(ctx context.Context, yesToPrompt, dryRun bool, ghClient
if err != nil {
return err
}
commitSha := strings.TrimSpace(string(commitShaRaw))
if len(commitSha) == 0 {
gitCommitOutput := strings.TrimSpace(string(commitShaRaw))
if len(gitCommitOutput) == 0 {
return fmt.Errorf("commit not merged into branch %s. Refusing to tag release", remoteBranch)
}

commitShas := strings.Split(gitCommitOutput, "\n")
if len(commitShas) != 1 {
io2.Fprintf(4, os.Stdout, "⚠ Multiple commits found for release preparation:\n")
for _, sha := range commitShas {
io2.Fprintf(5, os.Stdout, "- %s\n", sha)
}
}
commitSha := commitShas[0]

_, err = execCommand(pc.cfg.RepoDirectory, "git", "checkout", commitSha)
if err != nil {
return err
return fmt.Errorf("failed to check out commit %q: %s", commitSha, err)
}

o, err = execCommand(pc.cfg.RepoDirectory, "git", "log", "-1", commitSha)
Expand Down

0 comments on commit fca638c

Please sign in to comment.