summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--argv.go1
-rw-r--r--doClean.go39
-rw-r--r--exit.go2
4 files changed, 41 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 72c6a89..3b5cf21 100644
--- a/Makefile
+++ b/Makefile
@@ -42,3 +42,6 @@ restart:
reset
-rm ~/go/src/repos.pb
make private
+
+identify:
+ autogenpb --identify /home/jcarr/go/src/repos.pb
diff --git a/argv.go b/argv.go
index 6856a6e..152fd64 100644
--- a/argv.go
+++ b/argv.go
@@ -30,6 +30,7 @@ type args struct {
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"does the actual autocompletion"`
Force bool `arg:"--force" help:"try to strong arm things"`
+ Verbose bool `arg:"--verbose" help:"show more output"`
}
type EmptyCmd struct {
diff --git a/doClean.go b/doClean.go
index bc665a6..ca04c9e 100644
--- a/doClean.go
+++ b/doClean.go
@@ -19,7 +19,8 @@ func doClean() error {
for all.Scan() {
repo := all.Next()
if repo.GetCurrentBranchName() != repo.GetMasterBranchName() {
- continue
+ // skip this while in devel
+ // continue
}
if err := doCleanRepo(repo); err != nil {
badRepoExit(repo, err)
@@ -32,7 +33,9 @@ func doClean() error {
// removes all local branches
func doCleanRepo(repo *gitpb.Repo) error {
var hasLocal bool
- log.Info("Cleaning:", repo.GetGoPath())
+ if argv.Verbose {
+ log.Info("Cleaning:", repo.GetGoPath())
+ }
if repo.GitConfig == nil {
return fmt.Errorf("GitConfig == nil")
}
@@ -42,11 +45,28 @@ func doCleanRepo(repo *gitpb.Repo) error {
}
for name, b := range repo.GitConfig.Branches {
- log.Info("\tlocal branch name:", name, b.Merge, b.Remote)
+ if b.Name == "" {
+ b.Name = name
+ }
if name == repo.GetMasterBranchName() {
+ // never delete the master branch
+ // todo: make sure the master branch is in sync with remote master
continue
}
hasLocal = true
+ if name == repo.GetUserBranchName() {
+ if err := doCleanUserBranch(repo, b); err != nil {
+ return err
+ }
+ continue
+ }
+ if name == repo.GetDevelBranchName() {
+ if err := doCleanDevelBranch(repo, b); err != nil {
+ return err
+ }
+ continue
+ }
+ log.Info("\tlocal branch name unknown:", name, b.Merge, b.Remote)
}
if hasLocal {
return ErrorReposHasLocalBranches
@@ -57,3 +77,16 @@ func doCleanRepo(repo *gitpb.Repo) error {
func verifyLocalBranchIsMerged(repo *gitpb.Repo, branch *gitpb.GitBranch) error {
return nil
}
+
+func doCleanDevelBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error {
+ log.Printf("\tDo something %s on branch name:%s merge:%s remote:%s\n", repo.GetGoPath(), branch.Name, branch.Merge, branch.Remote)
+ return nil
+}
+
+func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error {
+ if branch.Name != repo.GetUserBranchName() {
+ return fmt.Errorf("repo %s was not user branch %s", repo.GetGoPath(), branch.Name)
+ }
+ log.Printf("\tDo something %s on branch name:%s merge:%s remote:%s\n", repo.GetGoPath(), branch.Name, branch.Merge, branch.Remote)
+ return nil
+}
diff --git a/exit.go b/exit.go
index fac574b..7e918cf 100644
--- a/exit.go
+++ b/exit.go
@@ -24,6 +24,6 @@ func badExit(err error) {
}
func badRepoExit(repo *gitpb.Repo, err error) {
- log.Printf("forge failed on %s with %v", repo.GetGoPath(), err)
+ log.Printf("forge failed on %s with %v\n", repo.GetGoPath(), err)
os.Exit(-1)
}