IsLocalBranch()
This commit is contained in:
parent
d7a90a71ab
commit
2574ec733a
|
@ -211,6 +211,28 @@ func (repo *Repo) IsBranch(findname string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: redo this and above. both are messed up. ignore for now until things are stable
|
||||||
|
func (repo *Repo) IsLocalBranch(findname string) bool {
|
||||||
|
loop := repo.Tags.All()
|
||||||
|
for loop.Scan() {
|
||||||
|
t := loop.Next()
|
||||||
|
// log.Info("LocalTagExists() tag:", t.Refname)
|
||||||
|
|
||||||
|
tagname := t.Refname
|
||||||
|
if strings.HasPrefix(tagname, "refs/heads") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path, filename := filepath.Split(tagname)
|
||||||
|
log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GoPath)
|
||||||
|
if filename == findname {
|
||||||
|
log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GoPath)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.Log(GITPB, "did not find tag:", findname, "in", repo.GoPath)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func trimNonNumericFromStart(s string) string {
|
func trimNonNumericFromStart(s string) string {
|
||||||
for i, r := range s {
|
for i, r := range s {
|
||||||
if unicode.IsDigit(r) {
|
if unicode.IsDigit(r) {
|
||||||
|
|
19
shell.go
19
shell.go
|
@ -79,12 +79,29 @@ func (repo *Repo) Exists(filename string) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) IsValid() bool {
|
func (repo *Repo) IsValid() bool {
|
||||||
if !repo.IsDirectory() {
|
if repo == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !repo.IsGitDirectory() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repo) ReadFile(fname string) ([]byte, error) {
|
||||||
|
fullname := filepath.Join(repo.FullPath, fname)
|
||||||
|
return os.ReadFile(fullname)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (repo *Repo) IsGitDirectory() bool {
|
||||||
|
gitdir := filepath.Join(repo.FullPath, ".git")
|
||||||
|
info, err := os.Stat(gitdir)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return info.IsDir()
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repo) IsDirectory() bool {
|
func (repo *Repo) IsDirectory() bool {
|
||||||
info, err := os.Stat(repo.FullPath)
|
info, err := os.Stat(repo.FullPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue