-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add checks for commits with missing author and time (#2771)
* Add checks for commits with missing author and time * Fix validate commits with emails if it has no Author
- Loading branch information
Showing
3 changed files
with
43 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"fmt" | ||
"os/exec" | ||
"strings" | ||
"time" | ||
|
||
"code.gitea.io/git" | ||
"code.gitea.io/gitea/modules/cache" | ||
|
@@ -119,11 +120,24 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string) | |
if err != nil { | ||
return fmt.Errorf("Commit: %v", err) | ||
} | ||
tagCreatedUnix := commit.Author.When.Unix() | ||
|
||
author, err := GetUserByEmail(commit.Author.Email) | ||
if err != nil && !IsErrUserNotExist(err) { | ||
return fmt.Errorf("GetUserByEmail: %v", err) | ||
sig := tag.Tagger | ||
if sig == nil { | ||
sig = commit.Author | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lafriks
Author
Member
|
||
} | ||
if sig == nil { | ||
sig = commit.Committer | ||
} | ||
|
||
var author *User | ||
var createdAt = time.Unix(1, 0) | ||
|
||
if sig != nil { | ||
author, err = GetUserByEmail(sig.Email) | ||
if err != nil && !IsErrUserNotExist(err) { | ||
return fmt.Errorf("GetUserByEmail: %v", err) | ||
} | ||
createdAt = sig.When | ||
} | ||
|
||
commitsCount, err := commit.CommitsCount() | ||
|
@@ -144,7 +158,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string) | |
IsDraft: false, | ||
IsPrerelease: false, | ||
IsTag: true, | ||
CreatedUnix: tagCreatedUnix, | ||
Created: createdAt, | ||
CreatedUnix: createdAt.Unix(), | ||
} | ||
if author != nil { | ||
rel.PublisherID = author.ID | ||
|
@@ -155,7 +170,8 @@ func pushUpdateAddTag(repo *Repository, gitRepo *git.Repository, tagName string) | |
} | ||
} else { | ||
rel.Sha1 = commit.ID.String() | ||
rel.CreatedUnix = tagCreatedUnix | ||
rel.Created = createdAt | ||
rel.CreatedUnix = createdAt.Unix() | ||
rel.NumCommits = commitsCount | ||
rel.IsDraft = false | ||
if rel.IsTag && author != nil { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it is never be used because if
sig
is null, nextif
will change it tocommit.Commiter