|
|
@ -16,6 +16,36 @@ import ( |
|
|
|
"github.com/gogits/gogs/modules/log" |
|
|
|
"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 { |
|
|
|
func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) error { |
|
|
|
//fmt.Println(refName, oldCommitId, newCommitId)
|
|
|
|
//fmt.Println(refName, oldCommitId, newCommitId)
|
|
|
|
//fmt.Println(userName, repoUserName, repoName)
|
|
|
|
//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) |
|
|
|
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) |
|
|
|
ru, err := GetUserByName(repoUserName) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("runUpdate.GetUserByName: %v", err) |
|
|
|
return fmt.Errorf("runUpdate.GetUserByName: %v", err) |
|
|
@ -103,6 +110,29 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName |
|
|
|
return err |
|
|
|
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
|
|
|
|
// if commits push
|
|
|
|
commits := make([]*base.PushCommit, 0) |
|
|
|
commits := make([]*base.PushCommit, 0) |
|
|
|
var maxCommits = 3 |
|
|
|
var maxCommits = 3 |
|
|
|