summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--checkout.go30
-rw-r--r--goDep.parseGoSum.go13
2 files changed, 26 insertions, 17 deletions
diff --git a/checkout.go b/checkout.go
index 4b46841..eb4d98b 100644
--- a/checkout.go
+++ b/checkout.go
@@ -3,6 +3,7 @@ package gitpb
import (
"fmt"
"os"
+ "os/user"
"path/filepath"
"go.wit.com/log"
@@ -42,12 +43,20 @@ func (repo *Repo) CheckoutDevel() bool {
func (repo *Repo) CheckoutUser() error {
bName := repo.GetUserBranchName()
- // log.Info("attempting checkout user", repo.GetGoPath(), bName)
- err := repo.createUserBranchNew(bName)
- if err != nil {
- log.Info("attempting checkout user error", repo.GetGoPath(), bName, err)
+ if bName == "uerr" {
+ usr, _ := user.Current()
+ repo.SetUserBranchName(usr.Username)
+ bName = usr.Username
+ log.Info("gitpb CheckoutUser() somehow got user 'uerr'")
}
- return err
+
+ return repo.createUserBranch(bName)
+ /*
+ if err != nil {
+ log.Info("attempting checkout user error", repo.GetGoPath(), bName, err)
+ }
+ return err
+ */
}
func (repo *Repo) BranchExists(bName string) bool {
@@ -83,15 +92,16 @@ func (repo *Repo) checkoutBranch(bName string) bool {
return true
}
-func (repo *Repo) createUserBranchNew(branch string) error {
- if branch == "" || branch == "uerr" {
- return fmt.Errorf("forge.gitpb logic err. branch name was: %s", branch)
+// actually creates a local user branch
+func (repo *Repo) createUserBranch(branch string) error {
+ if branch == "" {
+ // get the username here?
+ return fmt.Errorf("gitpb createuserBranch() logic err. git branch name can not be blank")
}
if repo.IsDirty() {
// never change repos on dirty branches
return fmt.Errorf("repo is dirty")
}
- // log.Info("forge.gitpb look for branch name was:", branch, repo.GetGoPath())
if repo.Exists(filepath.Join(".git/refs/heads", branch)) {
var err error
@@ -125,8 +135,6 @@ func (repo *Repo) createUserBranchNew(branch string) error {
// return fmt.Errorf("repo must be on devel branch %s", repo.GetGoPath())
}
- // log.Info("forge.gitpb try to create", branch, repo.GetGoPath())
-
// create the branch from devel
cmd := []string{"git", "branch", branch}
if _, err := repo.RunVerboseOnError(cmd); err != nil {
diff --git a/goDep.parseGoSum.go b/goDep.parseGoSum.go
index 00ed073..c8a219f 100644
--- a/goDep.parseGoSum.go
+++ b/goDep.parseGoSum.go
@@ -14,8 +14,8 @@ import (
"go.wit.com/log"
)
-// reads and parses the go.sum file
-// does not change anything
+// reads and parses the go.sum file into a protobuf struct
+// this function isn't supposed to change anything, just parse the existing files
func (repo *Repo) ParseGoSum() bool {
// empty out what was there before
repo.GoDeps = nil
@@ -75,7 +75,7 @@ func (repo *Repo) ParseGoSum() bool {
// attempt to parse go.* files in a directory
func GoSumParseDir(moddir string) (*GoDeps, error) {
- isprim, err := computePrimitiveNew(moddir)
+ isprim, err := computePrimitive(moddir)
if err != nil {
// "go mod init" failed
return nil, err
@@ -85,14 +85,14 @@ func GoSumParseDir(moddir string) (*GoDeps, error) {
return nil, nil
}
// go.sum exists. parse the go.sum file
- return parseGoSumNew(moddir)
+ return parseGoSum(moddir)
}
// Detect a 'Primitive' package. Sets the isPrimitive flag
// will return true if the repo is truly not dependent on _anything_ else
// like spew or lib/widget
// it assumes 'go mod init' and 'go mod tidy' ran without error
-func computePrimitiveNew(moddir string) (bool, error) {
+func computePrimitive(moddir string) (bool, error) {
// go mod init & go mod tidy ran without errors
log.Log(INFO, "isPrimitiveGoMod()", moddir)
gomod, err := os.Open(filepath.Join(moddir, "go.mod"))
@@ -131,7 +131,8 @@ func computePrimitiveNew(moddir string) (bool, error) {
return true, nil
}
-func parseGoSumNew(moddir string) (*GoDeps, error) {
+// parse the go.sum file into a protobuf
+func parseGoSum(moddir string) (*GoDeps, error) {
godeps := new(GoDeps)
tmp, err := os.Open(filepath.Join(moddir, "go.sum"))