summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitConfig.proto36
-rw-r--r--reloadBranches.go4
-rw-r--r--reloadParseGitConfig.go57
-rw-r--r--repo.proto2
4 files changed, 51 insertions, 48 deletions
diff --git a/gitConfig.proto b/gitConfig.proto
index 0de9cd0..094e204 100644
--- a/gitConfig.proto
+++ b/gitConfig.proto
@@ -4,29 +4,27 @@ package gitpb;
import "google/protobuf/timestamp.proto"; // Import the well-known type for Timestamp
-message GitRemote { // `autogenpb:nomutex`
- string url = 1;
- string fetch = 2;
+message GitRemote { // `autogenpb:nomutex`
+ string name = 1; // the branch name from the config file
+ string url = 2;
+ string fetch = 3;
}
-message GitBranch { // `autogenpb:nomutex`
- string remote = 1; // the name of the remote repo
- string merge = 2; // the merge path from the config file
- string name = 3; // the branch name from the config file
+message GitBranch { // `autogenpb:nomutex`
+ string name = 1; // the branch name from the config file
+ string remote = 2; // the name of the remote repo
+ string merge = 3; // the merge path from the config file
}
-message GitConfig { // `autogenpb:nomutex`
- map<string, string> core = 1; // map[origin] = "https:/git.wit.org/gui/gadgets"
- map<string, GitRemote> remotes = 2; // map[origin] = "https:/git.wit.org/gui/gadgets"
- map<string, GitBranch> branches = 3; // map[guimaster] = origin guimaster
- map<string, string> submodules = 4;
- map<string, string> hashes = 5;
- map<string, string> versions = 6;
- repeated GitBranch local = 7; // move this away from the map<> variables
+message GitConfig { // `autogenpb:nomutex`
+ map<string, string> core = 1; // map[origin] = "https:/git.wit.org/gui/gadgets"
+ map<string, string> submodules = 2;
+ repeated GitBranch branches = 3; // move this away from the map<> variables
+ repeated GitRemote remotes = 4; // move this away from the map<> variables
}
-message GitConfigs { // `autogenpb:marshal` `autogenpb:mutex`
- string uuid = 1; // `autogenpb:uuid:e70b71ec-0326-4485-8460-4a3c4d7b6919`
- string version = 2; // `autogenpb:version:v0.0.1`
- repeated GitConfig GitConfigs = 3; // THIS MUST BE GitConfig and then GitConfigs
+message GitConfigs { // `autogenpb:marshal` `autogenpb:mutex`
+ string uuid = 1; // `autogenpb:uuid:e70b71ec-0326-4485-8460-4a3c4d7b6919`
+ string version = 2; // `autogenpb:version:v0.0.1`
+ repeated GitConfig GitConfigs = 3; // THIS MUST BE GitConfig and then GitConfigs
}
diff --git a/reloadBranches.go b/reloadBranches.go
index fd81bdd..aaa2efc 100644
--- a/reloadBranches.go
+++ b/reloadBranches.go
@@ -122,10 +122,6 @@ func (repo *Repo) checkUserBranch() error {
return fmt.Errorf("repo.Config == nil")
}
- for _, l := range repo.Config.Local {
- log.Info("local branch name:", l.Name)
- }
-
return nil
}
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)
}
+*/
diff --git a/repo.proto b/repo.proto
index 9381f9a..be8088c 100644
--- a/repo.proto
+++ b/repo.proto
@@ -74,7 +74,7 @@ message Repo { // `autogenpb
message Repos { // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui` `autogenpb:nomutex` `autogenpb:http`
string uuid = 1; // `autogenpb:uuid:8daaeba1-fb1f-4762-ae6e-95a55d352673`
- string version = 2; // `autogenpb:version:v5`
+ string version = 2; // `autogenpb:version:v6`
repeated Repo repos = 3; // `autogenpb:append` // generate AppendUnique() function for this
bool hasFullScan = 4; // a full repo scan has been saved to disk
google.protobuf.Timestamp fullScan = 5; // mtime of the last full scan saved to disk