diff options
author | slene <vslene@gmail.com> | 2014-04-13 09:35:36 +0800 |
---|---|---|
committer | slene <vslene@gmail.com> | 2014-04-13 09:35:36 +0800 |
commit | 52b4ab2aa589cf892b24e95872cbac7b6e78ed3a (patch) | |
tree | efa6799dd4b78d6e70a28ac9feaa4351836c201a /models/update.go | |
parent | 9ffa8a40836a5e3341267affbaef08acf4765a74 (diff) | |
download | gitea-52b4ab2aa589cf892b24e95872cbac7b6e78ed3a.tar.gz gitea-52b4ab2aa589cf892b24e95872cbac7b6e78ed3a.zip |
update with new git
Diffstat (limited to 'models/update.go')
-rw-r--r-- | models/update.go | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/models/update.go b/models/update.go index 2ceac271a7..53591fa42e 100644 --- a/models/update.go +++ b/models/update.go @@ -28,34 +28,25 @@ func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId qlog.Fatalf("runUpdate.Open repoId: %v", err) } - newOid, err := git.NewOidFromString(newCommitId) + newCommit, err := repo.GetCommit(newCommitId) if err != nil { - qlog.Fatalf("runUpdate.Ref repoId:%v err: %v", newCommitId, err) - } - - newCommit, err := repo.LookupCommit(newOid) - if err != nil { - qlog.Fatalf("runUpdate.Ref repoId: %v", err) + qlog.Fatalf("runUpdate GetCommit of newCommitId: %v", err) + return } var l *list.List // if a new branch if isNew { - l, err = repo.CommitsBefore(newCommit.Id()) + l, err = newCommit.CommitsBefore() if err != nil { qlog.Fatalf("Find CommitsBefore erro:", err) } } else { - oldOid, err := git.NewOidFromString(oldCommitId) - if err != nil { - qlog.Fatalf("runUpdate.Ref repoId: %v", err) - } - - oldCommit, err := repo.LookupCommit(oldOid) + l, err = newCommit.CommitsBeforeUntil(oldCommitId) if err != nil { - qlog.Fatalf("runUpdate.Ref repoId: %v", err) + qlog.Fatalf("Find CommitsBeforeUntil erro:", err) + return } - l = repo.CommitsBetween(newCommit, oldCommit) } if err != nil { @@ -76,7 +67,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId actEmail = commit.Committer.Email } commits = append(commits, - &base.PushCommit{commit.Id().String(), + &base.PushCommit{commit.Id.String(), commit.Message(), commit.Author.Email, commit.Author.Name}) @@ -87,7 +78,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId //commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()}) if err = CommitRepoAction(userId, userName, actEmail, - repos.Id, repoName, git.BranchName(refName), &base.PushCommits{l.Len(), commits}); err != nil { + repos.Id, repoName, git.RefEndName(refName), &base.PushCommits{l.Len(), commits}); err != nil { qlog.Fatalf("runUpdate.models.CommitRepoAction: %v", err) } } |