Skip to content

Commit 5cafe40

Browse files
committed
_examples: tag-create-push, remove defaultSignature
1 parent ae693a9 commit 5cafe40

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

_examples/tag-create-push/main.go

+3-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io/ioutil"
66
"log"
77
"os"
8-
"time"
98

109
"github.com/go-git/go-git/v5"
1110
. "github.com/go-git/go-git/v5/_examples"
@@ -14,13 +13,12 @@ import (
1413
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
1514
)
1615

16+
// Example of how create a tag and push it to a remote.
1717
func main() {
1818
CheckArgs("<ssh-url>", "<directory>", "<tag>", "<name>", "<email>", "<public-key>")
1919
url := os.Args[1]
2020
directory := os.Args[2]
2121
tag := os.Args[3]
22-
name := os.Args[4]
23-
email := os.Args[5]
2422
key := os.Args[6]
2523

2624
r, err := cloneRepo(url, directory, key)
@@ -30,7 +28,7 @@ func main() {
3028
return
3129
}
3230

33-
created, err := setTag(r, tag, defaultSignature(name, email))
31+
created, err := setTag(r, tag)
3432
if err != nil {
3533
log.Printf("create tag error: %s", err)
3634
return
@@ -43,11 +41,9 @@ func main() {
4341
return
4442
}
4543
}
46-
4744
}
4845

4946
func cloneRepo(url, dir, publicKeyPath string) (*git.Repository, error) {
50-
5147
log.Printf("cloning %s into %s", url, dir)
5248
auth, keyErr := publicKey(publicKeyPath)
5349
if keyErr != nil {
@@ -102,7 +98,7 @@ func tagExists(tag string, r *git.Repository) bool {
10298
return res
10399
}
104100

105-
func setTag(r *git.Repository, tag string, tagger *object.Signature) (bool, error) {
101+
func setTag(r *git.Repository, tag string) (bool, error) {
106102
if tagExists(tag, r) {
107103
log.Printf("tag %s already exists", tag)
108104
return false, nil
@@ -115,7 +111,6 @@ func setTag(r *git.Repository, tag string, tagger *object.Signature) (bool, erro
115111
}
116112
Info("git tag -a %s %s -m \"%s\"", tag, h.Hash(), tag)
117113
_, err = r.CreateTag(tag, h.Hash(), &git.CreateTagOptions{
118-
Tagger: tagger,
119114
Message: tag,
120115
})
121116

@@ -151,11 +146,3 @@ func pushTags(r *git.Repository, publicKeyPath string) error {
151146

152147
return nil
153148
}
154-
155-
func defaultSignature(name, email string) *object.Signature {
156-
return &object.Signature{
157-
Name: name,
158-
Email: email,
159-
When: time.Now(),
160-
}
161-
}

0 commit comments

Comments
 (0)