summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go1
-rw-r--r--doMerge.go49
-rw-r--r--exit.go9
-rw-r--r--main.go4
-rw-r--r--structs.go2
5 files changed, 61 insertions, 4 deletions
diff --git a/argv.go b/argv.go
index 0f9a4db..59f8f67 100644
--- a/argv.go
+++ b/argv.go
@@ -139,6 +139,7 @@ type MergeCmd struct {
Devel *EmptyCmd `arg:"subcommand:devel" help:"merge user to devel"`
Master *EmptyCmd `arg:"subcommand:master" help:"merge devel to master"`
Publish *EmptyCmd `arg:"subcommand:publish" help:"increment versions and publish master branch"`
+ Check *EmptyCmd `arg:"subcommand:check" help:"check if merge is complete and ready to publish"`
}
type ConfigCmd struct {
diff --git a/doMerge.go b/doMerge.go
index 04e585d..13b5000 100644
--- a/doMerge.go
+++ b/doMerge.go
@@ -52,6 +52,12 @@ func doMerge() error {
log.Printf("Merged %d master branches in %s\n", repos.Len(), shell.FormatDuration(dur))
okExit("")
}
+ if argv.Merge.Check != nil {
+ if err := safeToPublish(); err != nil {
+ me.sh.BadExit("Merge is not complete. Not safe to Publish.", err)
+ }
+ okExit("")
+ }
if showWorkRepos() {
// found some repos at least
} else {
@@ -63,6 +69,49 @@ func doMerge() error {
return nil
}
+func hashesMatch(repo *gitpb.Repo) error {
+ uhash := repo.ActualGetUserHash()
+ dhash := repo.ActualGetDevelHash()
+ mhashl, mhashr := repo.ActualGetMasterHash()
+ // log.Info(uhash, dhash, mhashl, mhashr)
+ if uhash != dhash {
+ return log.Errorf("user does not match devel")
+ }
+ if dhash != mhashl {
+ return log.Errorf("devel does not match mater")
+ }
+ if mhashl != mhashr {
+ return log.Errorf("local master branch does not match remote branch")
+ }
+ return nil
+}
+
+func safeToPublish() 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 log.Errorf("no repos to publish")
+ }
+ for repo := range found.IterAll() {
+ if err := hashesMatch(repo); err != nil {
+ return err
+ }
+ if repo.CheckDirty() {
+ return log.Errorf("%s repo is dirty", repo.FullPath)
+ }
+ if repo.GetCurrentBranchName() != repo.GetMasterBranchName() {
+ return log.Errorf("%s repo is not on master branch", repo.FullPath)
+ }
+ return log.Errorf("%s todo: check if repo is completely merged", repo.FullPath)
+ }
+ return log.Errorf("notsure")
+}
+
func doMergeReport() *forgepb.Patches {
found := forgepb.NewPatches()
for repo := range me.forge.Repos.IterAll() {
diff --git a/exit.go b/exit.go
index d317d3b..7b9fa8c 100644
--- a/exit.go
+++ b/exit.go
@@ -23,7 +23,14 @@ func okExit(thing string) {
}
func badExit(err error) {
- log.Info("forge failed: ", err, me.forge.Config.ReposDir)
+ log.Info(err)
+ log.Info("forge failed")
+ os.Exit(-1)
+}
+
+func newBadExit(msg string, err error) {
+ log.Info(err)
+ log.Info(msg)
os.Exit(-1)
}
diff --git a/main.go b/main.go
index 78da3fe..7c90520 100644
--- a/main.go
+++ b/main.go
@@ -43,8 +43,8 @@ func main() {
me = new(mainType)
// the current os.Argv processing with go-args
- me.myGui = prep.Gui() // adds the GUI package args support
- me.auto = prep.Bash(&argv) // adds auto complete to go-args
+ me.myGui = prep.Gui() // adds the GUI package args support
+ me.sh = prep.Bash(&argv) // adds shell auto complete to go-args
// the current forge init process
me.forge = forgepb.Init() // init forge.pb
diff --git a/structs.go b/structs.go
index 15b17bc..fcdc07f 100644
--- a/structs.go
+++ b/structs.go
@@ -28,7 +28,7 @@ func myServer() string {
// this app's variables
type mainType struct {
// pp *arg.Parser // for parsing the command line args. Yay to alexflint!
- auto *prep.Auto // more experiments for bash handling
+ sh *prep.Auto // shell autocomplete
forge *forgepb.Forge // for holding the forge protobuf files
myGui *prep.GuiPrep // for initializing the GUI toolkits
foundPaths []string // stores gopaths to act on (when doing go-clone)