diff options
| author | Jeff Carr <[email protected]> | 2025-10-30 23:27:40 -0500 | 
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-30 23:27:40 -0500 | 
| commit | 0096a29c0ef6d355b138ef323747b780d37b3ddd (patch) | |
| tree | 967038e719d8e49393279a75cbaa3281e2518591 | |
| parent | da2910c708d29c6e2ab31ed22b81926621f5978e (diff) | |
autogen does all .proto files now
| -rw-r--r-- | generate.go | 6 | ||||
| -rw-r--r-- | reload.go | 2 | ||||
| -rw-r--r-- | reloadBranches.go | 4 | ||||
| -rw-r--r-- | reloadParseGitConfig.go | 48 | ||||
| -rw-r--r-- | repo.proto | 2 | 
5 files changed, 29 insertions, 33 deletions
diff --git a/generate.go b/generate.go index 83ea747..039ecc5 100644 --- a/generate.go +++ b/generate.go @@ -6,8 +6,4 @@ package gitpb  //  // NOTE: please add to go generate: if ! exists go.mod, run 'go mod init' &  'go mod tidy'  // -//go:generate autogenpb --proto repo.proto -//go:generate autogenpb --proto goDep.proto -//go:generate autogenpb --proto gitTag.proto -//go:generate autogenpb --proto stat.proto -//go:generate autogenpb --proto gitConfig.proto +//go:generate autogenpb @@ -62,7 +62,7 @@ func (repo *Repo) ReloadForce() error {  	repo.setRepoType()  	if repo.didFileChange(".git/config", repo.Times.MtimeConfig) { -		if err := repo.updateGitConfig(); err != nil { +		if err := repo.updateConfig(); err != nil {  			log.Infof("%s .git/config parse error %v\n", repo.FullPath, err)  		}  	} diff --git a/reloadBranches.go b/reloadBranches.go index b5fadb2..39a0a12 100644 --- a/reloadBranches.go +++ b/reloadBranches.go @@ -118,11 +118,11 @@ func ListFiles(directory string) []string {  func (repo *Repo) checkUserBranch() error {  	ubn := repo.GetUserBranchName()  	log.Info("user branch name:", ubn, repo.GetGoPath()) -	if repo.GitConfig == nil { +	if repo.Config == nil {  		return fmt.Errorf("GitConfig == nil")  	} -	for _, l := range repo.GitConfig.Local { +	for _, l := range repo.Config.Local {  		log.Info("local branch name:", l.Name)  	} diff --git a/reloadParseGitConfig.go b/reloadParseGitConfig.go index 0a93dd7..a36629b 100644 --- a/reloadParseGitConfig.go +++ b/reloadParseGitConfig.go @@ -13,21 +13,21 @@ import (  // does processing on the go.mod and go.sum files -func (repo *Repo) updateGitConfig() error { +func (repo *Repo) updateConfig() error {  	if repo == nil { -		return fmt.Errorf("gitpb.updateGitConfig() repo == nil") +		return fmt.Errorf("gitpb.updateConfig() repo == nil")  	} -	if repo.GitConfig == nil { -		repo.GitConfig = new(GitConfig) +	if repo.Config == nil { +		repo.Config = new(GitConfig)  	} -	repo.GitConfig.Core = make(map[string]string) -	repo.GitConfig.Remotes = make(map[string]*GitRemote) -	repo.GitConfig.Branches = make(map[string]*GitBranch) -	repo.GitConfig.Submodules = make(map[string]string) -	repo.GitConfig.Versions = make(map[string]string) -	repo.GitConfig.Hashes = make(map[string]string) -	url, err := repo.readGitConfig() +	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  	} @@ -42,8 +42,8 @@ func (repo *Repo) updateGitConfig() error {  	return err  } -// readGitConfig reads and parses the .git/config file -func (repo *Repo) readGitConfig() (string, error) { +// readConfig reads and parses the .git/config file +func (repo *Repo) readConfig() (string, error) {  	var foundURL string  	filename := filepath.Join(repo.GetFullPath(), ".git/config")  	file, err := os.Open(filename) @@ -90,17 +90,17 @@ func (repo *Repo) readGitConfig() (string, error) {  		switch currentSection {  		case "core": -			repo.GitConfig.Core[key] = value +			repo.Config.Core[key] = value  		case "gui":  			// don't really need gui stuff right now  		case "pull":  			// don't store git config pull settings here  			// git config probably has 'rebase = false'  		case "remote": -			test, ok := repo.GitConfig.Remotes[currentName] +			test, ok := repo.Config.Remotes[currentName]  			if !ok {  				test = new(GitRemote) -				repo.GitConfig.Remotes[currentName] = test +				repo.Config.Remotes[currentName] = test  			}  			log.Log(INFO, "switch currentSection", currentSection, currentName)  			switch key { @@ -133,17 +133,17 @@ func (repo *Repo) readGitConfig() (string, error) {  				log.Log(INFO, "unknown remote:", line)  			}  		case "branch": -			test, ok := repo.GitConfig.Branches[currentName] +			test, ok := repo.Config.Branches[currentName]  			if !ok {  				test = new(GitBranch) -				repo.GitConfig.Branches[currentName] = test +				repo.Config.Branches[currentName] = test  				repo.processBranch(currentName)  			}  			switch key {  			case "remote": -				repo.GitConfig.Branches[currentName].Remote = value +				repo.Config.Branches[currentName].Remote = value  			case "merge": -				repo.GitConfig.Branches[currentName].Merge = value +				repo.Config.Branches[currentName].Merge = value  			default:  				log.Log(INFO, "error unknown remote:", currentSection, currentName, key, value)  				log.Info("git .config unknown branch:", line) @@ -154,7 +154,7 @@ func (repo *Repo) readGitConfig() (string, error) {  			case "active":  				// probably 'true' or 'false'  			case "url": -				repo.GitConfig.Submodules[currentName] = value +				repo.Config.Submodules[currentName] = value  			default:  				log.Log(WARN, "unknown submodule line:", line)  			} @@ -192,7 +192,7 @@ func (repo *Repo) readGitConfig() (string, error) {  func (repo *Repo) processBranch(branch string) {  	log.Log(INFO, "    ", branch) -	hash, ok := repo.GitConfig.Hashes[branch] +	hash, ok := repo.Config.Hashes[branch]  	filename := filepath.Join(repo.GetFullPath() + "/.git/refs/heads/" + branch)  	log.Log(INFO, "      hash: need to open", filename) @@ -204,7 +204,7 @@ func (repo *Repo) processBranch(branch string) {  	}  	newhash := strings.TrimSpace(string(data))  	log.Log(INFO, "      hash:", newhash) -	repo.GitConfig.Hashes[branch] = newhash +	repo.Config.Hashes[branch] = newhash  	if ok {  		if hash != newhash {  			log.Log(WARN, "hash changed", hash) @@ -212,6 +212,6 @@ func (repo *Repo) processBranch(branch string) {  	}  	name, _ := repo.gitDescribeByHash(newhash) -	repo.GitConfig.Versions[newhash] = name +	repo.Config.Versions[newhash] = name  	log.Log(INFO, "      hash: version", name)  } @@ -68,7 +68,7 @@ message Repo {                                                     // `autogenpb          repeated string             dirtyList                = 22; // store the list from git status --porcelain          string                      state                    = 23; // status or state. useful for building tooling          GitTag                      currentTag               = 24; // used to examine repo branches -        GitConfig                   gitConfig                = 25; // protobuf of the current .git/config +        GitConfig                   config                   = 25; // protobuf of the current .git/config  }  message Repos {                                                    // `autogenpb:marshal` `autogenpb:sort` `autogenpb:gui` `autogenpb:nomutex` `autogenpb:http`  | 
