@@ -30,11 +30,6 @@ func main() {
30
30
return
31
31
}
32
32
33
- if tagExists (tag , r ) {
34
- log .Printf ("Tag %s already exists, nothing to do here" , tag )
35
- return
36
- }
37
-
38
33
created , err := setTag (r , tag , defaultSignature (name , email ))
39
34
if err != nil {
40
35
log .Printf ("create tag error: %s" , err )
@@ -59,19 +54,16 @@ func cloneRepo(url, dir, publicKeyPath string) (*git.Repository, error) {
59
54
return nil , keyErr
60
55
}
61
56
57
+ Info ("git clone %s" , url )
62
58
r , err := git .PlainClone (dir , false , & git.CloneOptions {
63
59
Progress : os .Stdout ,
64
60
URL : url ,
65
61
Auth : auth ,
66
62
})
67
63
68
64
if err != nil {
69
- if err == git .ErrRepositoryAlreadyExists {
70
- log .Print ("repo was already cloned" )
71
- } else {
72
- log .Printf ("clone git repo error: %s" , err )
73
- return nil , err
74
- }
65
+ log .Printf ("clone git repo error: %s" , err )
66
+ return nil , err
75
67
}
76
68
77
69
return r , nil
@@ -89,6 +81,7 @@ func publicKey(filePath string) (*ssh.PublicKeys, error) {
89
81
90
82
func tagExists (tag string , r * git.Repository ) bool {
91
83
tagFoundErr := "tag was found"
84
+ Info ("git show-ref --tag" )
92
85
tags , err := r .TagObjects ()
93
86
if err != nil {
94
87
log .Printf ("get tags error: %s" , err )
@@ -120,7 +113,7 @@ func setTag(r *git.Repository, tag string, tagger *object.Signature) (bool, erro
120
113
log .Printf ("get HEAD error: %s" , err )
121
114
return false , err
122
115
}
123
-
116
+ Info ( "git tag -a %s %s -m \" %s \" " , tag , h . Hash (), tag )
124
117
_ , err = r .CreateTag (tag , h .Hash (), & git.CreateTagOptions {
125
118
Tagger : tagger ,
126
119
Message : tag ,
@@ -144,7 +137,7 @@ func pushTags(r *git.Repository, publicKeyPath string) error {
144
137
RefSpecs : []config.RefSpec {config .RefSpec ("refs/tags/*:refs/tags/*" )},
145
138
Auth : auth ,
146
139
}
147
-
140
+ Info ( "git push --tags" )
148
141
err := r .Push (po )
149
142
150
143
if err != nil {
0 commit comments