Skip to content

Commit 9084bdd

Browse files
authored
fix push (#1076)
1 parent 136e6be commit 9084bdd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/hook.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func runHookPreReceive(c *cli.Context) error {
7676
// the environment setted on serv command
7777
repoID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchRepoID), 10, 64)
7878
isUncyclo := (os.Getenv(models.EnvRepoIsUncyclo) == "true")
79+
username := os.Getenv(models.EnvRepoUsername)
80+
reponame := os.Getenv(models.EnvRepoName)
81+
repoPath := models.RepoPath(username, reponame)
7982

8083
buf := bytes.NewBuffer(nil)
8184
scanner := bufio.NewScanner(os.Stdin)
@@ -113,7 +116,7 @@ func runHookPreReceive(c *cli.Context) error {
113116
}
114117

115118
// Check force push
116-
output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).Run()
119+
output, err := git.NewCommand("rev-list", oldCommitID, "^"+newCommitID).RunInDir(repoPath)
117120
if err != nil {
118121
fail("Internal error", "Fail to detect force push: %v", err)
119122
} else if len(output) > 0 {

0 commit comments

Comments
 (0)