summaryrefslogtreecommitdiff
path: root/update.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-27 13:57:17 -0600
committerJeff Carr <[email protected]>2024-11-27 13:57:17 -0600
commit2e3e4f98d33d8794a1c8a6aa13e6c9fa92fbcadb (patch)
treecd6222e4dc98e9de94981ade9f15f34030cc3d61 /update.go
parent44caec2e7fc59697ef01835aacf8a03171a42bea (diff)
start full refactor to have repo be here
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'update.go')
-rw-r--r--update.go21
1 files changed, 19 insertions, 2 deletions
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)
+}