Skip to content

Commit 4f74bad

Browse files
jolheisertechknowlogick
authored andcommitted
Add way to force checkout (#6322)
1 parent c55bdca commit 4f74bad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

contrib/pr/checkout.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"path"
1818
"path/filepath"
1919
"runtime"
20+
"strconv"
2021
"time"
2122

2223
"code.gitea.io/gitea/modules/markup/external"
@@ -162,6 +163,12 @@ func main() {
162163
return
163164
}
164165

166+
// To force checkout (e.g. Windows complains about unclean work tree) set env variable FORCE=true
167+
force, err := strconv.ParseBool(os.Getenv("FORCE"))
168+
if err != nil {
169+
force = false
170+
}
171+
165172
//Otherwise checkout PR
166173
if len(os.Args) != 2 {
167174
log.Fatal("Need only one arg: the PR number")
@@ -221,7 +228,7 @@ func main() {
221228
log.Printf("Checkout PR #%s in %s\n", pr, branch)
222229
err = tree.Checkout(&git.CheckoutOptions{
223230
Branch: branchRef,
224-
//Force: runtime.GOOS == "windows",
231+
Force: force,
225232
})
226233
if err != nil {
227234
log.Fatalf("Failed to checkout %s : %v", branch, err)

0 commit comments

Comments
 (0)