From 2e3e4f98d33d8794a1c8a6aa13e6c9fa92fbcadb Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 27 Nov 2024 13:57:17 -0600 Subject: start full refactor to have repo be here Signed-off-by: Jeff Carr --- update.go | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'update.go') diff --git a/update.go b/update.go index 5074cf3..953ad91 100644 --- a/update.go +++ b/update.go @@ -1,6 +1,7 @@ package gitpb import ( + "path/filepath" "slices" "strings" "time" @@ -15,7 +16,7 @@ import ( // Update version and timestamp. // returns ok (ok == true if not found) -func (r *Refs) Update(path string) error { +func (r *Repo) Update(path string) error { // delete the old hash // r.DeleteByHash(hash) r.Refs = nil @@ -54,6 +55,7 @@ func (r *Refs) Update(path string) error { subject = parts[4] } + newr := Ref{ Hash: hash, Subject: subject, @@ -61,7 +63,7 @@ func (r *Refs) Update(path string) error { Ctime: timestamppb.New(ctime), } - r.Append(&newr) + r.AppendRef(&newr) return nil } @@ -77,3 +79,18 @@ func getGitDateStamp(gitdefault string) time.Time { } return tagTime } + +func (r *Repos) NewGoPath(basepath string, gopath string) *Repo { + if oldr := r.FindByPath(gopath); oldr != nil { + // already had this gopath + return oldr + } + // add a new one here + newr := Repo{ + FullPath: filepath.Join(basepath, gopath), + GoPath: gopath, + } + newr.Update() + + r.Append(&newr) +} -- cgit v1.2.3