summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-02-27 14:24:58 +0800
committerGitHub <noreply@github.com>2017-02-27 14:24:58 +0800
commit9084bdd8639aecad35a3c6c6421b3550b6e8f53a (patch)
tree7302665ee2e27abc14e9add6a026384925245b49 /cmd
parent136e6beb0f3c26bdf26711dba49513aa2be3aa2e (diff)
downloadgitea-9084bdd8639aecad35a3c6c6421b3550b6e8f53a.tar.gz
gitea-9084bdd8639aecad35a3c6c6421b3550b6e8f53a.zip
fix push (#1076)
Diffstat (limited to 'cmd')
-rw-r--r--cmd/hook.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/hook.go b/cmd/hook.go
index a89c3741bf..8f7f8c3c47 100644
--- a/cmd/hook.go
+++ b/cmd/hook.go
@@ -76,6 +76,9 @@ func runHookPreReceive(c *cli.Context) error {
// the environment setted on serv command
repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64)
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
+ username := os.Getenv(models.EnvRepoUsername)
+ reponame := os.Getenv(models.EnvRepoName)
+ repoPath := models.RepoPath(username, reponame)
buf := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(os.Stdin)
@@ -113,7 +116,7 @@ func runHookPreReceive(c *cli.Context) error {
}
// Check force push
- output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).Run()
+ output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
if err != nil {
fail("Internal error", "Fail to detect force push: %v", err)
} else if len(output) > 0 {