summaryrefslogtreecommitdiff
path: root/update.go
diff options
context:
space:
mode:
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)
+}