Merge branch 'master' of github.com:gogits/gogs

This commit is contained in:
Unknown 2014-03-28 07:26:27 -04:00
commit 04bc86cafc

View file

@ -40,24 +40,33 @@ func runUpdate(c *cli.Context) {
log.SetOutput(w) log.SetOutput(w)
args := c.Args() args := c.Args()
//log.Info(args)
if len(args) != 3 { if len(args) != 3 {
log.Error("received less 3 parameters") log.Error("received less 3 parameters")
return return
} }
refName := args[0] refName := args[0]
if refName == "" {
log.Error("refName is empty, shouldn't use")
return
}
oldCommitId := args[1] oldCommitId := args[1]
newCommitId := args[2] 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") userName := os.Getenv("userName")
userId := os.Getenv("userId") userId := os.Getenv("userId")
//repoId := os.Getenv("repoId") //repoId := os.Getenv("repoId")
repoName := os.Getenv("repoName") repoName := os.Getenv("repoName")
log.Info("username", userName)
log.Info("repoName", repoName)
f := models.RepoPath(userName, repoName) f := models.RepoPath(userName, repoName)
log.Info("f", f)
gitUpdate := exec.Command("git", "update-server-info") gitUpdate := exec.Command("git", "update-server-info")
gitUpdate.Dir = f gitUpdate.Dir = f
@ -69,24 +78,6 @@ func runUpdate(c *cli.Context) {
return 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) newOid, err := git.NewOidFromString(newCommitId)
if err != nil { if err != nil {
log.Error("runUpdate.Ref repoId: %v", err) log.Error("runUpdate.Ref repoId: %v", err)
@ -101,11 +92,25 @@ func runUpdate(c *cli.Context) {
var l *list.List var l *list.List
// if a new branch // if a new branch
if strings.HasPrefix(oldCommitId, "0000000") { if isNew {
l, err = ref.AllCommits() l, err = repo.CommitsBefore(newCommit.Id())
if err != nil {
log.Error("Find CommitsBefore erro:", err)
return
}
} else { } 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 { if err != nil {