diff options
| author | Jeff Carr <[email protected]> | 2025-10-04 15:29:34 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-04 15:29:34 -0500 |
| commit | 36f568c3e2ac3ff54d5aa180a2685be94351d8c4 (patch) | |
| tree | ef6a7c0a5e1a255c62eb93ee7b3dee9771f4b2c0 /doMerge.go | |
| parent | ef7e82b9859bcf789f0eceef8d6f051617c50dde (diff) | |
automate publish & merge
Diffstat (limited to 'doMerge.go')
| -rw-r--r-- | doMerge.go | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -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() { |
