From 7b60756f2c56314af715fa884388a5654bbfb791 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 3 May 2014 01:37:49 -0400 Subject: Fix Collaborators cannot commit --- models/update.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'models/update.go') diff --git a/models/update.go b/models/update.go index 648c45f1..8aca1594 100644 --- a/models/update.go +++ b/models/update.go @@ -16,14 +16,14 @@ import ( "github.com/gogits/gogs/modules/base" ) -func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId int64) { +func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName string, userId int64) { isNew := strings.HasPrefix(oldCommitId, "0000000") if isNew && strings.HasPrefix(newCommitId, "0000000") { qlog.Fatal("old rev and new rev both 000000") } - f := RepoPath(userName, repoName) + f := RepoPath(repoUserName, repoName) gitUpdate := exec.Command("git", "update-server-info") gitUpdate.Dir = f @@ -59,7 +59,12 @@ func Update(refName, oldCommitId, newCommitId, userName, repoName string, userId qlog.Fatalf("runUpdate.Commit repoId: %v", err) } - repos, err := GetRepositoryByName(userId, repoName) + ru, err := GetUserByName(repoUserName) + if err != nil { + qlog.Fatalf("runUpdate.GetUserByName: %v", err) + } + + repos, err := GetRepositoryByName(ru.Id, repoName) if err != nil { qlog.Fatalf("runUpdate.GetRepositoryByName userId: %v", err) } @@ -83,8 +88,8 @@ 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, refName, &base.PushCommits{l.Len(), commits}); err != nil { + if err = CommitRepoAction(userId, ru.Id, userName, actEmail, + repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}); err != nil { qlog.Fatalf("runUpdate.models.CommitRepoAction: %v", err) } } -- cgit v1.2.3