Skip to content

Commit

Permalink
Add way to force checkout (go-gitea#6322)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolheiser authored and techknowlogick committed Mar 15, 2019
1 parent c55bdca commit 4f74bad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion contrib/pr/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"path"
"path/filepath"
"runtime"
"strconv"
"time"

"code.gitea.io/gitea/modules/markup/external"
Expand Down Expand Up @@ -162,6 +163,12 @@ func main() {
return
}

// To force checkout (e.g. Windows complains about unclean work tree) set env variable FORCE=true
force, err := strconv.ParseBool(os.Getenv("FORCE"))
if err != nil {
force = false
}

//Otherwise checkout PR
if len(os.Args) != 2 {
log.Fatal("Need only one arg: the PR number")
Expand Down Expand Up @@ -221,7 +228,7 @@ func main() {
log.Printf("Checkout PR #%s in %s\n", pr, branch)
err = tree.Checkout(&git.CheckoutOptions{
Branch: branchRef,
//Force: runtime.GOOS == "windows",
Force: force,
})
if err != nil {
log.Fatalf("Failed to checkout %s : %v", branch, err)
Expand Down

0 comments on commit 4f74bad

Please sign in to comment.