From 6ce114a9e285e94a244dda867c0b7c2585680f6c Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 7 Jun 2026 17:42:06 +0000 Subject: internal/testgit: Add -s to tag --- internal/testgit/tag.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'internal/testgit') diff --git a/internal/testgit/tag.go b/internal/testgit/tag.go index 9aaac157..139edf77 100644 --- a/internal/testgit/tag.go +++ b/internal/testgit/tag.go @@ -12,6 +12,10 @@ type TagAnnotatedOptions struct { Message string Tagger Identity TaggerDate string + + // Sign requests a signed tag via git tag -s, + // using the gpg.format and user.signingkey configured on the repo. + Sign bool } // TagAnnotated creates an annotated tag object and returns its object ID. @@ -23,7 +27,14 @@ func (repo *Repo) TagAnnotated( ) (id.ObjectID, error) { tb.Helper() - cmd := repo.command(tb, "git", "tag", "-a", "-m", opts.Message, "--end-of-options", name, target.String()) + args := []string{"tag", "-a"} + if opts.Sign { + args = append(args, "-s") + } + + args = append(args, "-m", opts.Message, "--end-of-options", name, target.String()) + + cmd := repo.command(tb, "git", args...) if opts.Tagger.Name != "" { cmd.Env = setEnv(cmd.Env, "GIT_COMMITTER_NAME", opts.Tagger.Name) -- cgit v1.3.1-10-gc9f91