diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-06-28 23:56:41 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-06-28 23:56:41 +0800 |
commit | 1c46d68abaf08890e10386b3af674233b4dda2d3 (patch) | |
tree | ee366ead93743202b7a1d92936cbaaed76623867 /models | |
parent | 4ce2fa520a1d9c36febd19562015107b74a4bc1d (diff) | |
download | gitea-1c46d68abaf08890e10386b3af674233b4dda2d3.tar.gz gitea-1c46d68abaf08890e10386b3af674233b4dda2d3.zip |
bug fixed for message tag
Diffstat (limited to 'models')
-rw-r--r-- | models/models.go | 3 | ||||
-rw-r--r-- | models/update.go | 76 |
2 files changed, 55 insertions, 24 deletions
diff --git a/models/models.go b/models/models.go index 4e65c00bcb..070784f137 100644 --- a/models/models.go +++ b/models/models.go @@ -35,7 +35,8 @@ func init() { tables = append(tables, new(User), new(PublicKey), new(Repository), new(Watch), new(Action), new(Access), new(Issue), new(Comment), new(Oauth2), new(Follow), new(Mirror), new(Release), new(LoginSource), new(Webhook), new(IssueUser), - new(Milestone), new(Label), new(HookTask), new(Team), new(OrgUser), new(TeamUser)) + new(Milestone), new(Label), new(HookTask), new(Team), new(OrgUser), new(TeamUser), + new(UpdateTask)) } func LoadModelsConfig() { 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 |