diff options
| -rw-r--r-- | reloadTags.go | 81 | ||||
| -rw-r--r-- | rill.go | 12 |
2 files changed, 2 insertions, 91 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 -} @@ -17,16 +17,6 @@ var ErrorGitPullOnLocal error = errors.New("git pull on local only branch") var ErrorGitPullOnDirty error = errors.New("cannot git pull on dirty repo") func (repo *Repo) GitPull() (*cmd.Status, error) { - /* - currentName := repo.GetCurrentBranchName() - if repo.IsOnlyLocalTag(currentName) { - var result cmd.Status - result.Exit = 21 - result.Error = ErrorGitPullOnLocal - // log.Info("git pull skipped on local only branch", repo.GetGoPath()) - return result - } - */ var cmd []string cmd = append(cmd, "git", "pull") return nil, repo.RunVerbose(cmd) @@ -85,6 +75,7 @@ func (all *Repos) RillGitPull(part1 int, part2 int) map[*Repo]*cmd.Status { return allerr } +/* func (repo *Repo) GitPullRealtime() cmd.Status { currentName := repo.GetCurrentBranchName() if repo.IsOnlyLocalTag(currentName) { @@ -99,3 +90,4 @@ func (repo *Repo) GitPullRealtime() cmd.Status { r := repo.RunRealtime(cmd) return r } +*/ |
