github.com/purpleclay/gitz@v0.8.2-0.20240515052600-43f80eea2fe1/testdata/tagsigned.go (about) 1 package main 2 3 import ( 4 "log" 5 "os" 6 7 git "github.com/purpleclay/gitz" 8 ) 9 10 var ( 11 gpgPublicKeyID = os.Getenv("GPG_PUBLIC_KEY_ID") 12 gpgFingerprint = os.Getenv("GPG_FINGERPRINT") 13 ) 14 15 func main() { 16 gitc, _ := git.NewClient() 17 gitc.ConfigSetL("user.signingkey", gpgPublicKeyID) 18 19 if _, err := gitc.Tag("0.1.0", git.WithSigned(), git.WithAnnotation("withsigned")); err != nil { 20 log.Fatal(err.Error()) 21 } 22 23 verif, err := gitc.VerifyTag("0.1.0") 24 if err != nil { 25 log.Fatal(err.Error()) 26 } 27 28 if verif.Tagger.Name != "batman" { 29 log.Fatalf("invalid tagger name, expecting: 'batman' but received: '%s'", verif.Tagger.Name) 30 } 31 32 if verif.Tagger.Email != "batman@dc.com" { 33 log.Fatalf("invalid tagger email, expecting: 'batman@dc.com' but received: '%s'", verif.Tagger.Email) 34 } 35 36 if verif.Annotation != "withsigned" { 37 log.Fatalf("invalid annotation, expecting: 'withsigned' but received: '%s'", verif.Annotation) 38 } 39 40 if verif.Signature.Fingerprint != gpgFingerprint { 41 log.Fatalf("invalid fingerprint, expecting: '%s' but received: '%s'", gpgFingerprint, verif.Signature.Fingerprint) 42 } 43 44 if verif.Signature.Author.Name != "batman" { 45 log.Fatalf("invalid signed-by name, expecting: 'batman' but received: '%s'", verif.Signature.Author.Name) 46 } 47 48 if verif.Signature.Author.Email != "batman@dc.com" { 49 log.Fatalf("invalid signed-by email, expecting: 'batman@dc.com' but received: '%s'", verif.Signature.Author.Email) 50 } 51 }