summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-04-04 06:03:42 -0500
committerJeff Carr <[email protected]>2025-04-04 06:03:42 -0500
commitfcc5a36ad02869a997ad00873401d80a67a0d664 (patch)
tree9f702347d7c5bbbe71973cf4fc0783fa7396c690
parent7297b63339bc3be682137313413f3c82beb0ebb3 (diff)
try to fix defective "Git on Borg" reposv0.0.99v0.0.98
-rw-r--r--checkout.go15
-rw-r--r--reload.go9
2 files changed, 24 insertions, 0 deletions
diff --git a/checkout.go b/checkout.go
index 2180c22..ce8c88b 100644
--- a/checkout.go
+++ b/checkout.go
@@ -1,6 +1,7 @@
package gitpb
import (
+ "os"
"path/filepath"
"go.wit.com/log"
@@ -8,6 +9,20 @@ import (
func (repo *Repo) CheckoutMaster() bool {
bName := repo.GetMasterBranchName()
+ if bName == "giterr" {
+ cmd := []string{"git", "checkout", "main"} // todo: figure out main
+ repo.RunVerbose(cmd)
+ os.Exit(-1)
+ // TODO: try to fix this
+ if repo.checkoutBranch("main") {
+ repo.MasterBranchName = "main"
+ return true
+ } else {
+ cmd := []string{"git", "checkout", "main"} // todo: figure out main
+ repo.RunVerbose(cmd)
+ return false
+ }
+ }
if repo.checkoutBranch(bName) {
return true
}
diff --git a/reload.go b/reload.go
index 60f3e7e..3ec5eca 100644
--- a/reload.go
+++ b/reload.go
@@ -21,6 +21,15 @@ func (repo *Repo) ReloadCheck() error {
// TODO: clean this up more, but it is working now more or less
func (repo *Repo) Reload() error {
+ // sometimes, on new repos, if .git/HEAD does not exist
+ // defective git daemons or badly configured repos, 'git clone' can fail
+ // if so, 'git fetch origin' can repair the state
+ if !repo.Exists(".git/HEAD") {
+ cmd := []string{"git", "fetch", "origin"}
+ repo.RunVerbose(cmd)
+ cmd = []string{"git", "checkout", "main"} // todo: figure out main
+ repo.RunVerbose(cmd)
+ }
// log.Info("in reload", repo.FullPath)
repo.Tags = new(GitTags)
repo.reloadGitTags()