summaryrefslogtreecommitdiffstats
path: root/models/update.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2014-06-28 23:56:41 +0800
committerLunny Xiao <xiaolunwen@gmail.com>2014-06-28 23:56:41 +0800
commit1c46d68abaf08890e10386b3af674233b4dda2d3 (patch)
treeee366ead93743202b7a1d92936cbaaed76623867 /models/update.go
parent4ce2fa520a1d9c36febd19562015107b74a4bc1d (diff)
downloadgitea-1c46d68abaf08890e10386b3af674233b4dda2d3.tar.gz
gitea-1c46d68abaf08890e10386b3af674233b4dda2d3.zip
bug fixed for message tag
Diffstat (limited to 'models/update.go')
-rw-r--r--models/update.go76
1 files changed, 53 insertions, 23 deletions
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