Skip to content

Commit 094aa0b

Browse files
authored
Merge pull request #3 from antoniomika/am/fix-deploy
Test fix
2 parents acea1d9 + 2ffe37d commit 094aa0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

hook/hook.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,12 @@ func handlePostReceive(hookType, repoDir, oldRev, newRev, refName string) {
9494
os.Exit(1)
9595
}
9696

97-
resetCmd := exec.Command("git", "reset", fmt.Sprintf("origin/%s", mainBranch), "--hard")
97+
mainBranchString := strings.TrimSpace(string(mainBranch))
98+
if mainBranchString == "" {
99+
mainBranchString = "main"
100+
}
101+
102+
resetCmd := exec.Command("git", "reset", fmt.Sprintf("origin/%s", mainBranchString), "--hard")
98103
resetCmd.Dir = deploymentDir
99104
resetCmd.Env = append(resetCmd.Env, "GIT_DIR=.git")
100105
err = resetCmd.Run()

0 commit comments

Comments
 (0)