summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-17 00:00:27 -0600
committerJeff Carr <[email protected]>2024-12-17 00:00:27 -0600
commit075fce61e541eec6ccdc02c9de3bee14e9e486cf (patch)
treea715cc0cc960c3d91d0be96e3006c6e8daf5597e
parenta9286af8fd3f912aa357e3ebe67af09f42b8d534 (diff)
start cleaning up git interactions
-rw-r--r--clone.go15
-rw-r--r--goSrcScan.go5
-rw-r--r--repoNew.go9
3 files changed, 17 insertions, 12 deletions
diff --git a/clone.go b/clone.go
index 7fb8a2a..69e62fd 100644
--- a/clone.go
+++ b/clone.go
@@ -60,18 +60,17 @@ func clonePathHack(dirname string, basedir string, gopath string) (string, error
// attempt to git clone if the go path doesn't exist
// does a git clone, if it works, returns true
-// workdir = /home/jcarr/go/src/
// gopath = go.wit.com/apps/helloworld
func (f *Forge) Clone(gopath string) (*gitpb.Repo, error) {
var err error
- pb, err := f.Repos.NewGoPath(f.goSrc, gopath, "")
- if err == nil {
- return f.finishClone(gopath, pb.URL)
+ fullpath := filepath.Join(f.goSrc, gopath)
+
+ if pb := f.Repos.FindByFullPath(fullpath); pb != nil {
+ // repo already exists
+ return pb, nil
}
- workdir := f.goSrc
- fullpath := filepath.Join(workdir, gopath)
- dirname := filepath.Base(fullpath)
+ dirname := filepath.Base(fullpath)
basedir := strings.TrimSuffix(fullpath, dirname)
url := "https://" + gopath
@@ -123,7 +122,7 @@ func (f *Forge) finishClone(gopath string, giturl string) (*gitpb.Repo, error) {
var err error
newr := f.Repos.FindByGoPath(gopath)
if newr == nil {
- newr, err = f.Repos.NewGoPath(f.goSrc, gopath, giturl)
+ newr, err = f.NewGoRepo(gopath, giturl)
}
if newr == nil {
log.Warn("forge.Clone() new repo can not be found or created for gopath", gopath)
diff --git a/goSrcScan.go b/goSrcScan.go
index a50dbb2..f43aed1 100644
--- a/goSrcScan.go
+++ b/goSrcScan.go
@@ -68,6 +68,9 @@ func gitDirectoriesNew(srcDir string) ([]string, error) {
case "go.work.last":
default:
// todo: figure out a way to do padding for init()
+ if trip == false {
+ log.Info("WARNING:")
+ }
log.Info("WARNING: you have an untracked file outside of any .git repository:", path)
trip = true
}
@@ -141,7 +144,7 @@ func (f *Forge) rillScanDirs(gopaths []string) (int, error) {
// Read users from the API.
// Concurrency = 20
dirs := rill.Map(ids, 20, func(id string) (*gitpb.Repo, error) {
- return f.NewGoPathRepo(id)
+ return f.NewGoRepo(id, "")
})
var counter int
diff --git a/repoNew.go b/repoNew.go
index 772e9b2..69a2338 100644
--- a/repoNew.go
+++ b/repoNew.go
@@ -3,19 +3,22 @@ package forgepb
import (
"fmt"
"os/user"
+ "path/filepath"
"strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
-func (f *Forge) NewGoPathRepo(gopath string) (*gitpb.Repo, error) {
- repo, err := f.Repos.NewGoPath(f.GetGoSrc(), gopath, "")
+func (f *Forge) NewGoRepo(gopath string, url string) (*gitpb.Repo, error) {
+ fullpath := filepath.Join(f.GetGoSrc(), gopath)
+ repo, err := f.Repos.NewGoRepo(fullpath, gopath)
if err != nil {
return nil, err
}
+ repo.URL = url
f.VerifyBranchNames(repo)
- repo.ParseGoSum()
+ repo.Reload()
return repo, nil
}