9
9
"fmt"
10
10
"os/exec"
11
11
"strings"
12
+ "time"
12
13
13
14
"code.gitea.io/git"
14
15
@@ -119,11 +120,24 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
119
120
if err != nil {
120
121
return fmt .Errorf ("Commit: %v" , err )
121
122
}
122
- tagCreatedUnix := commit .Author .When .Unix ()
123
123
124
- author , err := GetUserByEmail (commit .Author .Email )
125
- if err != nil && ! IsErrUserNotExist (err ) {
126
- return fmt .Errorf ("GetUserByEmail: %v" , err )
124
+ sig := tag .Tagger
125
+ if sig == nil {
126
+ sig = commit .Author
127
+ }
128
+ if sig == nil {
129
+ sig = commit .Committer
130
+ }
131
+
132
+ var author * User
133
+ var createdAt = time .Unix (1 , 0 )
134
+
135
+ if sig != nil {
136
+ author , err = GetUserByEmail (sig .Email )
137
+ if err != nil && ! IsErrUserNotExist (err ) {
138
+ return fmt .Errorf ("GetUserByEmail: %v" , err )
139
+ }
140
+ createdAt = sig .When
127
141
}
128
142
129
143
commitsCount , err := commit .CommitsCount ()
@@ -144,7 +158,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
144
158
IsDraft : false ,
145
159
IsPrerelease : false ,
146
160
IsTag : true ,
147
- CreatedUnix : tagCreatedUnix ,
161
+ Created : createdAt ,
162
+ CreatedUnix : createdAt .Unix (),
148
163
}
149
164
if author != nil {
150
165
rel .PublisherID = author .ID
@@ -155,7 +170,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string)
155
170
}
156
171
} else {
157
172
rel .Sha1 = commit .ID .String ()
158
- rel .CreatedUnix = tagCreatedUnix
173
+ rel .Created = createdAt
174
+ rel .CreatedUnix = createdAt .Unix ()
159
175
rel .NumCommits = commitsCount
160
176
rel .IsDraft = false
161
177
if rel .IsTag && author != nil {
0 commit comments