diff options
Diffstat (limited to 'gitConfig.go')
| -rw-r--r-- | gitConfig.go | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/gitConfig.go b/gitConfig.go index 006ce8a..d863cd7 100644 --- a/gitConfig.go +++ b/gitConfig.go @@ -33,50 +33,6 @@ type GitConfig struct { versions map[string]string } -// type GoConfig map[string]string - -func ListGitDirectories() []string { - var all []string - homeDir, err := os.UserHomeDir() - if err != nil { - log.Log(WARN, "Error getting home directory:", err) - return nil - } - - srcDir := filepath.Join(homeDir, "go/src") - - err = filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - log.Log(WARN, "Error accessing path:", path, err) - return nil - } - - // Check if the current path is a directory and has a .git subdirectory - if info.IsDir() && IsGitDir(path) { - all = append(all, path) - // fmt.Println(path) - } - - return nil - }) - - if err != nil { - log.Log(WARN, "Error walking the path:", srcDir, err) - } - - return all -} - -// IsGitDir checks if a .git directory exists inside the given directory -func IsGitDir(dir string) bool { - gitDir := filepath.Join(dir, ".git") - info, err := os.Stat(gitDir) - if os.IsNotExist(err) { - return false - } - return info.IsDir() -} - // readGitConfig reads and parses the .git/config file func (rs *RepoStatus) readGitConfig() error { filename := filepath.Join(rs.realPath.String(), "/.git/config") @@ -211,47 +167,6 @@ func (rs *RepoStatus) readGitConfig() error { return nil } -func (rs *RepoStatus) GitURL() string { - origin, ok := rs.gitConfig.remotes["origin"] - if ok { - return origin.url - } - for i, s := range rs.gitConfig.remotes { - log.Log(WARN, "remote:", i, s.url) - } - log.Log(WARN, "GitURL() repo has non-standard origin or is not uploaded") - return "" -} - -/* -func (rs *RepoStatus) GitLsFiles() (bool, string) { - r := rs.Run([]string{"git", "ls-files"}) - output := strings.Join(r.Stdout, "\n") - if r.Error != nil { - log.Warn("git ls-files failed err =", r.Error) - log.Warn("git ls-files failed output =", output) - return false, output - } - return true, output -} -*/ - -func (rs *RepoStatus) ReadOnly() bool { - if rs.readOnly.String() == "true" { - return true - } else { - return false - } -} - -func (rs *RepoStatus) SetReadOnly(b bool) { - if b { - rs.readOnly.SetText("true") - } else { - rs.readOnly.SetText("false") - } -} - func (rs *RepoStatus) processBranch(branch string) { fullpath := rs.realPath.String() log.Log(INFO, " ", branch) @@ -277,21 +192,3 @@ func (rs *RepoStatus) processBranch(branch string) { rs.gitConfig.versions[newhash] = name log.Log(INFO, " hash: version", name) } - -func (rs *RepoStatus) BranchExists(branch string) bool { - hash, ok := rs.gitConfig.hashes[branch] - if ok { - log.Log(REPOWARN, rs.Path(), "found branch", branch, hash) - return true - } - for i, t := range rs.Tags.tags { - base := filepath.Base(t.tag.String()) - if base == branch { - log.Info("found branch tag:", i, t.tag.String()) - return true - } - // log.Info("not tag:", i, t.tag.String()) - } - log.Log(REPOWARN, rs.Path(), "did not find branch", branch) - return false -} |
