forked from mirror/gitea
Merge branch 'master' of github.com:gogits/gogs
This commit is contained in:
commit
04bc86cafc
55
update.go
55
update.go
@ -40,24 +40,33 @@ func runUpdate(c *cli.Context) {
|
||||
log.SetOutput(w)
|
||||
|
||||
args := c.Args()
|
||||
//log.Info(args)
|
||||
if len(args) != 3 {
|
||||
log.Error("received less 3 parameters")
|
||||
return
|
||||
}
|
||||
|
||||
refName := args[0]
|
||||
if refName == "" {
|
||||
log.Error("refName is empty, shouldn't use")
|
||||
return
|
||||
}
|
||||
oldCommitId := args[1]
|
||||
newCommitId := args[2]
|
||||
|
||||
isNew := strings.HasPrefix(oldCommitId, "0000000")
|
||||
if isNew &&
|
||||
strings.HasPrefix(newCommitId, "0000000") {
|
||||
log.Error("old rev and new rev both 000000")
|
||||
return
|
||||
}
|
||||
|
||||
userName := os.Getenv("userName")
|
||||
userId := os.Getenv("userId")
|
||||
//repoId := os.Getenv("repoId")
|
||||
repoName := os.Getenv("repoName")
|
||||
|
||||
log.Info("username", userName)
|
||||
log.Info("repoName", repoName)
|
||||
f := models.RepoPath(userName, repoName)
|
||||
log.Info("f", f)
|
||||
|
||||
gitUpdate := exec.Command("git", "update-server-info")
|
||||
gitUpdate.Dir = f
|
||||
@ -69,24 +78,6 @@ func runUpdate(c *cli.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ref, err := repo.LookupReference(refName)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
oldOid, err := git.NewOidFromString(oldCommitId)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
oldCommit, err := repo.LookupCommit(oldOid)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
newOid, err := git.NewOidFromString(newCommitId)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
@ -101,11 +92,25 @@ func runUpdate(c *cli.Context) {
|
||||
|
||||
var l *list.List
|
||||
// if a new branch
|
||||
if strings.HasPrefix(oldCommitId, "0000000") {
|
||||
l, err = ref.AllCommits()
|
||||
|
||||
if isNew {
|
||||
l, err = repo.CommitsBefore(newCommit.Id())
|
||||
if err != nil {
|
||||
log.Error("Find CommitsBefore erro:", err)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
l = ref.CommitsBetween(newCommit, oldCommit)
|
||||
oldOid, err := git.NewOidFromString(oldCommitId)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
oldCommit, err := repo.LookupCommit(oldOid)
|
||||
if err != nil {
|
||||
log.Error("runUpdate.Ref repoId: %v", err)
|
||||
return
|
||||
}
|
||||
l = repo.CommitsBetween(newCommit, oldCommit)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user