Add way to force checkout (#6322)

This commit is contained in:
John Olheiser 2019-03-15 11:18:01 -05:00 committed by techknowlogick
parent c55bdca562
commit 4f74bad783
1 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,7 @@ import (
"path" "path"
"path/filepath" "path/filepath"
"runtime" "runtime"
"strconv"
"time" "time"
"code.gitea.io/gitea/modules/markup/external" "code.gitea.io/gitea/modules/markup/external"
@ -162,6 +163,12 @@ func main() {
return 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 //Otherwise checkout PR
if len(os.Args) != 2 { if len(os.Args) != 2 {
log.Fatal("Need only one arg: the PR number") log.Fatal("Need only one arg: the PR number")
@ -221,7 +228,7 @@ func main() {
log.Printf("Checkout PR #%s in %s\n", pr, branch) log.Printf("Checkout PR #%s in %s\n", pr, branch)
err = tree.Checkout(&git.CheckoutOptions{ err = tree.Checkout(&git.CheckoutOptions{
Branch: branchRef, Branch: branchRef,
//Force: runtime.GOOS == "windows", Force: force,
}) })
if err != nil { if err != nil {
log.Fatalf("Failed to checkout %s : %v", branch, err) log.Fatalf("Failed to checkout %s : %v", branch, err)