summaryrefslogtreecommitdiff
path: root/reloadParseGitConfig.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-11-02 09:40:01 -0600
committerJeff Carr <[email protected]>2025-11-02 09:40:01 -0600
commit6475144cd37db9ece2a8df6477df820f642c9907 (patch)
treec2c9bbbd7451e58a28ae15335b3d912e474b5256 /reloadParseGitConfig.go
parent7190028798229ba7a2bbfe549ccde2749e87edd8 (diff)
more protobuf changes
Diffstat (limited to 'reloadParseGitConfig.go')
-rw-r--r--reloadParseGitConfig.go57
1 files changed, 33 insertions, 24 deletions
diff --git a/reloadParseGitConfig.go b/reloadParseGitConfig.go
index a36629b..9b78312 100644
--- a/reloadParseGitConfig.go
+++ b/reloadParseGitConfig.go
@@ -3,7 +3,6 @@ package gitpb
import (
"bufio"
"fmt"
- "io/ioutil"
"os"
"path/filepath"
"strings"
@@ -22,11 +21,7 @@ func (repo *Repo) updateConfig() error {
}
repo.Config.Core = make(map[string]string)
- repo.Config.Remotes = make(map[string]*GitRemote)
- repo.Config.Branches = make(map[string]*GitBranch)
repo.Config.Submodules = make(map[string]string)
- repo.Config.Versions = make(map[string]string)
- repo.Config.Hashes = make(map[string]string)
url, err := repo.readConfig()
if repo.URL == "" {
repo.URL = url
@@ -97,10 +92,16 @@ func (repo *Repo) readConfig() (string, error) {
// don't store git config pull settings here
// git config probably has 'rebase = false'
case "remote":
- test, ok := repo.Config.Remotes[currentName]
- if !ok {
- test = new(GitRemote)
- repo.Config.Remotes[currentName] = test
+ var newr *GitRemote
+ for _, x := range repo.Config.Remotes {
+ if x.Name == currentName {
+ newr = x
+ }
+ }
+ if newr == nil {
+ newr = new(GitRemote)
+ newr.Name = currentName
+ repo.Config.Remotes = append(repo.Config.Remotes, newr)
}
log.Log(INFO, "switch currentSection", currentSection, currentName)
switch key {
@@ -112,38 +113,44 @@ func (repo *Repo) readConfig() (string, error) {
log.Info("TODO: gitpb: handle multiple remotes in the parser", foundURL, value)
}
}
- if test.Url == value {
+ if newr.Url == value {
continue
}
- if test.Url == "" {
- test.Url = value
+ if newr.Url == "" {
+ newr.Url = value
continue
}
- log.Log(INFO, "error url mismatch", test.Url, value)
+ log.Log(INFO, "error url mismatch", newr.Url, value)
case "fetch":
- if test.Fetch == value {
+ if newr.Fetch == value {
continue
}
- if test.Fetch == "" {
- test.Fetch = value
+ if newr.Fetch == "" {
+ newr.Fetch = value
continue
}
- log.Log(INFO, "error fetch mismatch", test.Fetch, value)
+ log.Log(INFO, "error fetch mismatch", newr.Fetch, value)
default:
log.Log(INFO, "unknown remote:", line)
}
case "branch":
- test, ok := repo.Config.Branches[currentName]
- if !ok {
- test = new(GitBranch)
- repo.Config.Branches[currentName] = test
- repo.processBranch(currentName)
+ var newb *GitBranch
+ for _, br := range repo.Config.Branches {
+ if br.Name == currentName {
+ newb = br
+ }
+ }
+ if newb == nil {
+ newb = new(GitBranch)
+ newb.Name = currentName
+ repo.Config.Branches = append(repo.Config.Branches, newb)
+ // repo.processBranch(currentName) // todo: redo this
}
switch key {
case "remote":
- repo.Config.Branches[currentName].Remote = value
+ newb.Remote = value
case "merge":
- repo.Config.Branches[currentName].Merge = value
+ newb.Merge = value
default:
log.Log(INFO, "error unknown remote:", currentSection, currentName, key, value)
log.Info("git .config unknown branch:", line)
@@ -190,6 +197,7 @@ func (repo *Repo) readConfig() (string, error) {
return foundURL, nil
}
+/*
func (repo *Repo) processBranch(branch string) {
log.Log(INFO, " ", branch)
hash, ok := repo.Config.Hashes[branch]
@@ -215,3 +223,4 @@ func (repo *Repo) processBranch(branch string) {
repo.Config.Versions[newhash] = name
log.Log(INFO, " hash: version", name)
}
+*/