diff options
| author | Jeff Carr <[email protected]> | 2025-10-05 20:04:38 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-05 20:04:38 -0500 |
| commit | d9ed0838c403e982f572d108542bcc16705049d9 (patch) | |
| tree | 5d8229be3dbfcd068219417cf0039e7e37735eca /compare.go | |
| parent | 7360716b35b452595e93c554d5f342b9f0338ea2 (diff) | |
logic for branch testing
Diffstat (limited to 'compare.go')
| -rw-r--r-- | compare.go | 75 |
1 files changed, 62 insertions, 13 deletions
@@ -1,5 +1,11 @@ package gitpb +import ( + "fmt" + + "go.wit.com/log" +) + type RepoTag struct { r *Repo t *GitTag @@ -16,16 +22,46 @@ func (r *Repo) NewCompareTag(refname string) *RepoTag { return rt } -// if t1 is user branch, and t2 is devel branch, true if 0 -func (t1 *RepoTag) LessThan(t2 *RepoTag) bool { - count, err := t1.r.CountDiffObjects(t1.t.Refname, t2.t.Refname) +func (r *Repo) NewCompareRef(t *GitTag) *RepoTag { + if t == nil { + return nil + } + rt := new(RepoTag) + rt.r = r + rt.t = t + return rt +} + +func (t1 *RepoTag) DeleteBranch(t2 *RepoTag) ([]string, []string, error) { + lines1, err1 := t1.r.CountDiffObjectsNew(t1.t.Refname, t2.t.Refname) + // log.Info("lessthan", t1.t.Refname, t2.t.Refname, count, t1.r.FullPath) + if err1 != nil { + // log.Info("lessthan", t1.t.Refname, t2.t.Refname, count, t1.r.FullPath, err) + return nil, nil, err1 + } + lines2, err2 := t1.r.CountDiffObjectsNew(t2.t.Refname, t1.t.Refname) + // log.Info("lessthan", t1.t.Refname, t2.t.Refname, count, t1.r.FullPath) + if err2 != nil { + // log.Info("lessthan", t1.t.Refname, t2.t.Refname, count, t1.r.FullPath, err) + return nil, nil, err2 + } + if (len(lines1) != 0) || (len(lines2) != 0) { + return lines1, lines2, fmt.Errorf("nope") + } + return lines1, lines2, nil +} + +func (t1 *RepoTag) LessThanVerbose(t2 *RepoTag) []string { + count, err := t1.r.CountDiffObjectsNew(t1.t.Refname, t2.t.Refname) + log.Info("lessthan", t1.t.Refname, t2.t.Refname, len(count), t1.r.FullPath) if err != nil { - return false + log.Info("lessthan", t1.t.Refname, t2.t.Refname, len(count), t1.r.FullPath, err) + return nil } - if count == 0 { - return true + if len(count) == 0 { + return nil } - return false + return count } func (t1 *RepoTag) Equal(t2 *RepoTag) bool { @@ -33,13 +69,26 @@ func (t1 *RepoTag) Equal(t2 *RepoTag) bool { } // if t1 is user branch, and t2 is devel branch, true if 0 -func (t1 *RepoTag) GreaterThan(t2 *RepoTag) bool { - count, err := t1.r.CountDiffObjects(t2.t.Refname, t1.t.Refname) +func (t1 *RepoTag) GreaterThan(t2 *RepoTag) []string { + lines, err := t1.r.CountDiffObjectsNew(t2.t.Refname, t1.t.Refname) + // log.Info("greaterthan", t1.t.Refname, t2.t.Refname, count, t1.r.FullPath, err) if err != nil { - return false + return nil } - if count == 0 { - return true + if len(lines) == 0 { + return lines } - return false + return nil +} + +func (r *Repo) GetLocalUserRef() *GitTag { + return r.IsBranchLocal(r.GetUserBranchName()) +} + +func (r *Repo) GetLocalDevelRef() *GitTag { + return r.IsBranchLocal(r.GetDevelBranchName()) +} + +func (r *Repo) GetLocalMasterRef() *GitTag { + return r.IsBranchLocal(r.GetMasterBranchName()) } |
