From 1c46d68abaf08890e10386b3af674233b4dda2d3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 28 Jun 2014 23:56:41 +0800 Subject: bug fixed for message tag --- models/update.go | 76 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 23 deletions(-) (limited to 'models/update.go') diff --git a/models/update.go b/models/update.go index 6702ad3b46..cf7f5d2a79 100644 --- a/models/update.go +++ b/models/update.go @@ -16,6 +16,36 @@ import ( "github.com/gogits/gogs/modules/log" ) +type UpdateTask struct { + Id int64 + Uuid string `xorm:"index"` + RefName string + OldCommitId string + NewCommitId string +} + +func AddUpdateTask(task *UpdateTask) error { + _, err := x.Insert(task) + return err +} + +func GetUpdateTasksByUuid(uuid string) ([]*UpdateTask, error) { + task := &UpdateTask{ + Uuid: uuid, + } + tasks := make([]*UpdateTask, 0) + err := x.Find(&tasks, task) + if err != nil { + return nil, err + } + return tasks, nil +} + +func DelUpdateTasksByUuid(uuid string) error { + _, err := x.Delete(&UpdateTask{Uuid: uuid}) + return err +} + func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) error { //fmt.Println(refName, oldCommitId, newCommitId) //fmt.Println(userName, repoUserName, repoName) @@ -42,29 +72,6 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName return fmt.Errorf("runUpdate.Open repoId: %v", err) } - newCommit, err := repo.GetCommit(newCommitId) - if err != nil { - return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err) - } - - var l *list.List - // if a new branch - if isNew { - l, err = newCommit.CommitsBefore() - if err != nil { - return fmt.Errorf("Find CommitsBefore erro: %v", err) - } - } else { - l, err = newCommit.CommitsBeforeUntil(oldCommitId) - if err != nil { - return fmt.Errorf("Find CommitsBeforeUntil erro: %v", err) - } - } - - if err != nil { - return fmt.Errorf("runUpdate.Commit repoId: %v", err) - } - ru, err := GetUserByName(repoUserName) if err != nil { return fmt.Errorf("runUpdate.GetUserByName: %v", err) @@ -103,6 +110,29 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName return err } + newCommit, err := repo.GetCommit(newCommitId) + if err != nil { + return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err) + } + + var l *list.List + // if a new branch + if isNew { + l, err = newCommit.CommitsBefore() + if err != nil { + return fmt.Errorf("Find CommitsBefore erro: %v", err) + } + } else { + l, err = newCommit.CommitsBeforeUntil(oldCommitId) + if err != nil { + return fmt.Errorf("Find CommitsBeforeUntil erro: %v", err) + } + } + + if err != nil { + return fmt.Errorf("runUpdate.Commit repoId: %v", err) + } + // if commits push commits := make([]*base.PushCommit, 0) var maxCommits = 3 -- cgit v1.2.3