File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 "log"
66 "os"
77 "os/exec"
8+ "strings"
89 "text/template"
910
1011 gfm "github.com/shurcooL/github_flavored_markdown"
@@ -21,11 +22,24 @@ type content struct {
2122}
2223
2324func updateRepo () {
24- cmd := exec .Command ("git" , "pull" )
25- cmd .Stdout = os .Stdout
26- cmd .Stderr = os .Stderr
27- if err := cmd .Run (); err != nil {
28- log .Fatalf ("Error updating repository: %v" , err )
25+ branchCmd := exec .Command ("git" , "rev-parse" , "--abbrev-ref" , "HEAD" )
26+ out , err := branchCmd .Output ()
27+ if err != nil {
28+ log .Printf ("Skipping git pull (unable to detect branch): %v" , err )
29+ return
30+ }
31+
32+ currentBranch := strings .TrimSpace (string (out ))
33+ if currentBranch == "HEAD" || currentBranch == "" {
34+ log .Println ("Skipping git pull: detached HEAD detected" )
35+ return
36+ }
37+
38+ pullCmd := exec .Command ("git" , "pull" , "--ff-only" )
39+ pullCmd .Stdout = os .Stdout
40+ pullCmd .Stderr = os .Stderr
41+ if err := pullCmd .Run (); err != nil {
42+ log .Printf ("Continuing without git pull (failed to update repository): %v" , err )
2943 }
3044}
3145
You can’t perform that action at this time.
0 commit comments