diff options
Diffstat (limited to 'models/update.go')
-rw-r--r-- | models/update.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/models/update.go b/models/update.go index be50a15e5a..952794538a 100644 --- a/models/update.go +++ b/models/update.go @@ -47,6 +47,19 @@ func DeleteUpdateTaskByUUID(uuid string) error { return err } +// CommitToPushCommit transforms a git.Commit to PushCommit type. +func CommitToPushCommit(commit *git.Commit) *PushCommit { + return &PushCommit{ + Sha1: commit.ID.String(), + Message: commit.Message(), + AuthorEmail: commit.Author.Email, + AuthorName: commit.Author.Name, + CommitterEmail: commit.Committer.Email, + CommitterName: commit.Committer.Name, + Timestamp: commit.Author.When, + } +} + func ListToPushCommits(l *list.List) *PushCommits { commits := make([]*PushCommit, 0) var actEmail string @@ -55,16 +68,7 @@ func ListToPushCommits(l *list.List) *PushCommits { if actEmail == "" { actEmail = commit.Committer.Email } - commits = append(commits, - &PushCommit{ - Sha1: commit.ID.String(), - Message: commit.Message(), - AuthorEmail: commit.Author.Email, - AuthorName: commit.Author.Name, - CommitterEmail: commit.Committer.Email, - CommitterName: commit.Committer.Name, - Timestamp: commit.Author.When, - }) + commits = append(commits, CommitToPushCommit(commit)) } return &PushCommits{l.Len(), commits, "", nil} } |