diff options
author | Unknwon <u@gogs.io> | 2015-12-09 20:46:05 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-12-09 20:46:05 -0500 |
commit | 9a2e43bff28ac92f180109fe900a6997614ea5a8 (patch) | |
tree | 564dbb6fb30c153e43b0e18499d80e7d93dd0bee /models/update.go | |
parent | bd5dc626e82e18d3e619d918e579dc130edcd1fa (diff) | |
download | gitea-9a2e43bff28ac92f180109fe900a6997614ea5a8.tar.gz gitea-9a2e43bff28ac92f180109fe900a6997614ea5a8.zip |
move out git module and #1573 send push hook
Diffstat (limited to 'models/update.go')
-rw-r--r-- | models/update.go | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/models/update.go b/models/update.go index 14e56ce813..9878f04a07 100644 --- a/models/update.go +++ b/models/update.go @@ -10,7 +10,8 @@ import ( "os/exec" "strings" - "github.com/gogits/gogs/modules/git" + "github.com/gogits/git-shell" + "github.com/gogits/gogs/modules/log" ) @@ -46,6 +47,24 @@ func DeleteUpdateTaskByUUID(uuid string) error { return err } +func ListToPushCommits(l *list.List) *PushCommits { + commits := make([]*PushCommit, 0) + var actEmail string + for e := l.Front(); e != nil; e = e.Next() { + commit := e.Value.(*git.Commit) + if actEmail == "" { + actEmail = commit.Committer.Email + } + commits = append(commits, + &PushCommit{commit.ID.String(), + commit.Message(), + commit.Author.Email, + commit.Author.Name, + }) + } + return &PushCommits{l.Len(), commits, "", nil} +} + func Update(refName, oldCommitID, newCommitID, userName, repoUserName, repoName string, userID int64) error { isNew := strings.HasPrefix(oldCommitID, "0000000") if isNew && @@ -131,24 +150,8 @@ func Update(refName, oldCommitID, newCommitID, userName, repoUserName, repoName return fmt.Errorf("runUpdate.Commit repoId: %v", err) } - // Push commits. - commits := make([]*PushCommit, 0) - var actEmail string - for e := l.Front(); e != nil; e = e.Next() { - commit := e.Value.(*git.Commit) - if actEmail == "" { - actEmail = commit.Committer.Email - } - commits = append(commits, - &PushCommit{commit.ID.String(), - commit.Message(), - commit.Author.Email, - commit.Author.Name, - }) - } - - if err = CommitRepoAction(userID, user.Id, userName, actEmail, - repo.ID, repoUserName, repoName, refName, &PushCommits{l.Len(), commits, "", nil}, oldCommitID, newCommitID); err != nil { + if err = CommitRepoAction(userID, user.Id, userName, user.Email, + repo.ID, repoUserName, repoName, refName, ListToPushCommits(l), oldCommitID, newCommitID); err != nil { return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err) } return nil |