aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-07 17:42:06 +0000
committerGravatar Runxi Yu2026-06-07 17:42:25 +0000
commit6ce114a9e285e94a244dda867c0b7c2585680f6c (patch)
treead53e6da4c583e4fb38890911caa26db5aee7f9f /internal/testgit
parentobject/signed{,/commit}: Add (diff)
signatureNo signature
internal/testgit: Add -s to tag
Diffstat (limited to 'internal/testgit')
-rw-r--r--internal/testgit/tag.go13
1 files changed, 12 insertions, 1 deletions
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)