Skip to content

Commit

Permalink
fix push (go-gitea#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny authored Feb 27, 2017
1 parent 136e6be commit 9084bdd
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9084bdd

Please sign in to comment.