summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--refs.update.go (renamed from update.go)36
-rw-r--r--repo.new.go26
2 files changed, 31 insertions, 31 deletions
diff --git a/update.go b/refs.update.go
index 8e2a12b..3266fd1 100644
--- a/update.go
+++ b/refs.update.go
@@ -1,7 +1,6 @@
package gitpb
import (
- "path/filepath"
"slices"
"strings"
"time"
@@ -11,21 +10,17 @@ import (
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
-// this is becoming a standard format
-// todo: autogenerate this from the .proto file?
-
-// Update version and timestamp.
-// returns ok (ok == true if not found)
-func (r *Repo) Update() error {
+// Update repo.Refs from .git/
+func (repo *Repo) UpdateGit() error {
// delete the old hash
// r.DeleteByHash(hash)
- r.Refs = nil
+ repo.Refs = nil
tags := []string{"%(objectname)", "%(creatordate)", "%(*authordate)", "%(refname)", "%(subject)"}
format := strings.Join(tags, "_,,,_")
cmd := []string{"git", "for-each-ref", "--sort=taggerdate", "--format", format}
// log.Info("RUNNING:", strings.Join(cmd, " "))
- result := shell.PathRunQuiet(r.FullPath, cmd)
+ result := shell.PathRunQuiet(repo.FullPath, cmd)
if result.Error != nil {
log.Warn("git for-each-ref error:", result.Error)
return result.Error
@@ -63,7 +58,7 @@ func (r *Repo) Update() error {
Ctime: timestamppb.New(ctime),
}
- r.AppendRef(&newr)
+ repo.AppendRef(&newr)
return nil
}
@@ -79,24 +74,3 @@ func getGitDateStamp(gitdefault string) time.Time {
}
return tagTime
}
-
-// scans in a new git repo. If it detects the repo is a golang project,
-// then it parses the go.mod/go.sum files
-// TODO: try adding python, rails, perl, rust, other language things?
-// I probably will never have time to try that, but I'd take patches for anyone
-// that might see this note and feel so inclined.
-func (r *Repos) InitNewGoPath(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)
- return &newr
-}
diff --git a/repo.new.go b/repo.new.go
new file mode 100644
index 0000000..6a37b8f
--- /dev/null
+++ b/repo.new.go
@@ -0,0 +1,26 @@
+package gitpb
+
+import (
+ "path/filepath"
+)
+
+// scans in a new git repo. If it detects the repo is a golang project,
+// then it parses the go.mod/go.sum files
+// TODO: try adding python, rails, perl, rust, other language things?
+// I probably will never have time to try that, but I'd take patches for anyone
+// that might see this note and feel so inclined.
+func (r *Repos) InitNewGoPath(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.UpdateGit()
+
+ r.Append(&newr)
+ return &newr
+}