summaryrefslogtreecommitdiff
path: root/reloadParseGitConfig.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-11 14:21:37 -0500
committerJeff Carr <[email protected]>2025-09-11 14:21:37 -0500
commit1d8380b9e781ce7087dbd0d8bead69f11ced7527 (patch)
treeeba0f2a889c6232368d4118172caa54ac9e71bb4 /reloadParseGitConfig.go
parente395456c536b2458563d5e872a73e8667cc08659 (diff)
pull out the namespace
Diffstat (limited to 'reloadParseGitConfig.go')
-rw-r--r--reloadParseGitConfig.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/reloadParseGitConfig.go b/reloadParseGitConfig.go
index 5373e2e..c6d01e6 100644
--- a/reloadParseGitConfig.go
+++ b/reloadParseGitConfig.go
@@ -27,16 +27,28 @@ func (repo *Repo) updateGitConfig() error {
repo.GitConfig.Submodules = make(map[string]string)
repo.GitConfig.Versions = make(map[string]string)
repo.GitConfig.Hashes = make(map[string]string)
- return repo.readGitConfig()
+ url, err := repo.readGitConfig()
+ if repo.URL != "" {
+ log.Info("gitpb: url already set", url, repo.URL)
+ }
+
+ if url == "" {
+ log.Info(repo.FullPath, "url was blank. warn user this repo is only on the local disk")
+ } else {
+ repo.URL = url
+ }
+
+ return err
}
// readGitConfig reads and parses the .git/config file
-func (repo *Repo) readGitConfig() error {
+func (repo *Repo) readGitConfig() (string, error) {
+ var foundURL string
filename := filepath.Join(repo.GetFullPath(), ".git/config")
file, err := os.Open(filename)
defer file.Close()
if err != nil {
- return err
+ return "", err
}
var currentSection string = ""
@@ -92,6 +104,13 @@ func (repo *Repo) readGitConfig() error {
log.Log(INFO, "switch currentSection", currentSection, currentName)
switch key {
case "url":
+ if foundURL == "" {
+ foundURL = value
+ } else {
+ if foundURL != value {
+ log.Info("TODO: gitpb: handle multiple remotes in the parser", foundURL, value)
+ }
+ }
if test.Url == value {
continue
}
@@ -164,10 +183,10 @@ func (repo *Repo) readGitConfig() error {
}
if err := scanner.Err(); err != nil {
- return err
+ return "", err
}
- return nil
+ return foundURL, nil
}
func (repo *Repo) processBranch(branch string) {