summaryrefslogtreecommitdiff
path: root/defaultBehavior.go
diff options
context:
space:
mode:
Diffstat (limited to 'defaultBehavior.go')
-rw-r--r--defaultBehavior.go89
1 files changed, 65 insertions, 24 deletions
diff --git a/defaultBehavior.go b/defaultBehavior.go
index c215aa2..b42ca34 100644
--- a/defaultBehavior.go
+++ b/defaultBehavior.go
@@ -4,9 +4,73 @@
package main
import (
+ "errors"
+
+ "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
+func defaultBehaviorMaster() error {
+ var reallybad bool
+ // always run dirty first
+ me.forge.CheckDirtyQuiet()
+
+ // if no option is given to patch, list out the
+ // repos that have patches ready in them
+ found := findReposWithPatches()
+ if found.Len() == 0 {
+ log.Info("you currently have no repos with patches")
+ return nil
+ }
+ // warn about dirty repos not in master branches
+ for repo := range found.IterAll() {
+ if repo.CheckDirty() {
+ if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
+ repo.State = "DIRTY BAD"
+ reallybad = true
+ }
+ // return log.Errorf("%s repo is dirty", repo.FullPath)
+ }
+ }
+ footer := me.forge.PrintDefaultTB(found)
+ log.Info("default master table", footer)
+ if reallybad {
+ return errors.New("\nYOU ARE MAKING EDITS ON NON USER BRANCHES\n")
+ }
+ return nil
+}
+
+func doDefaultBehavior() (string, error) {
+ // DEFAULT BEHAVIOR CHANGES BETWEEN MODES
+ if me.forge.Config.Mode == forgepb.ForgeMode_NORMAL || me.forge.Config.Mode == forgepb.ForgeMode_USER {
+ // PROBABLY YOU ARE WRITING CODE
+ // got to the end with nothing to do (?)
+ if showWorkRepos() {
+ // found some repos at least
+ }
+ // every repo is in a really clean state. no extra files anywhere
+ // no dirty repos, no repos that need to be published
+ // nothing different between user and master branch version. not common
+ s := "All of your git repositories appear to be in perfect shape"
+ return s, nil
+ }
+
+ if me.forge.Config.Mode == forgepb.ForgeMode_MASTER {
+ // PROBABLY YOU ARE PUBLISHING / MERGING CODE
+ err := defaultBehaviorMaster()
+ if err != nil {
+ return "has problems", err
+ }
+ return "default master behavior is ok", nil
+ }
+
+ // PROBABLY A NEW USER
+ found := findAll()
+ footer := me.forge.PrintDefaultTB(found)
+ return "new user: " + footer, nil
+}
+
+/*
func defaultBehavior() error {
// always run dirty first
me.forge.CheckDirtyQuiet()
@@ -46,27 +110,4 @@ func defaultBehavior() error {
}
return nil
}
-
-func defaultBehaviorMaster() error {
- // always run dirty first
- me.forge.CheckDirtyQuiet()
-
- // if no option is given to patch, list out the
- // repos that have patches ready in them
- found := findReposWithPatches()
- if found.Len() == 0 {
- log.Info("you currently have no repos with patches")
- return nil
- }
- // warn about dirty repos not in master branches
- for repo := range found.IterAll() {
- if repo.CheckDirty() {
- if repo.GetCurrentBranchName() != repo.GetUserBranchName() {
- repo.State = "DIRTY REPO NOT IN USER BRANCH"
- }
- // return log.Errorf("%s repo is dirty", repo.FullPath)
- }
- }
- me.forge.PrintDefaultTB(found)
- return nil
-}
+*/