summaryrefslogtreecommitdiff
path: root/reloadTags.go
diff options
context:
space:
mode:
Diffstat (limited to 'reloadTags.go')
-rw-r--r--reloadTags.go81
1 files changed, 0 insertions, 81 deletions
diff --git a/reloadTags.go b/reloadTags.go
index ce0ca84..a40f2de 100644
--- a/reloadTags.go
+++ b/reloadTags.go
@@ -1,8 +1,6 @@
package gitpb
import (
- "os"
- "path/filepath"
"slices"
"strings"
"time"
@@ -120,13 +118,6 @@ func (repo *Repo) reloadGitTags() error {
tmp := getGitDateStamp(newest)
*/
repo.Times.NewestCommit = timestamppb.New(newest)
-
- if repo.GetMasterBranchName() == "" {
- if err := repo.findHEAD(); err != nil {
- // todo: redo all this shitty code
- // log.Info(repo.FullPath, "master branch blank", err)
- }
- }
return nil
}
@@ -183,75 +174,3 @@ func (repo *Repo) NewestTag() *GitTag {
}
return nil
}
-
-// this should just do is.Exists(".git/refs/heads/findname")
-// this is a simple check and doesn't work all the time
-func (repo *Repo) LocalTagExists(findname string) bool {
- fname := filepath.Join(".git/refs/heads", findname)
- if repo.Exists(fname) {
- return true
- }
- fname = filepath.Join(".git/refs/tags", findname)
- if repo.Exists(fname) {
- return true
- }
- /*
- loop := repo.Tags.SortByRefname()
- for loop.Scan() {
- ref := loop.Next()
- // log.Info(repo.GoPath, ref.Refname)
- if strings.HasPrefix(ref.Refname, "refs/remotes") {
- continue
- }
- tagname := filepath.Base(ref.Refname)
- // log.Info("tag:", path, tagname, "from", repo.GoPath)
- if tagname == findname {
- // log.Info("found tag:", path, tagname, "from", repo.GoPath)
- return true
- }
- }
- */
- return false
-}
-
-// returns true if 'taggy' is _ONLY_ a local tag
-// this means you can not do a git pull or git push on it
-func (repo *Repo) IsOnlyLocalTag(taggy string) bool {
- // first make sure the tag is actually even local
- if !repo.LocalTagExists(taggy) {
- // this means it's not even local now.
- return false
- }
- // okay, taggy exists, does it exist in a remote repo?
- loop := repo.Tags.SortByRefname()
- for loop.Scan() {
- ref := loop.Next()
- tagname := ref.Refname
- if strings.HasPrefix(tagname, "refs/remotes") {
- path, filename := filepath.Split(tagname)
- if filename == taggy {
- log.Log(INFO, "found tag:", path, filename, "from", repo.GetGoPath())
- return false
- }
- }
- }
- // we couldn't find the local tag anywhere remote, so it's probably only local
- return true
-}
-
-func (repo *Repo) findHEAD() error {
- headfile := filepath.Join(repo.GetFullPath(), ".git/refs/remotes/origin/HEAD")
- data, err := os.ReadFile(headfile)
- if err != nil {
- return err
- }
- s := string(data)
- if !strings.HasPrefix(s, "ref: ") {
- return log.Errorf("HEAD doesn't start with 'ref:'")
- }
- fields := strings.Fields(s)
- _, bname := filepath.Split(fields[1])
-
- repo.SetMasterBranchName(bname)
- return nil
-}