From 69eee080459392cef8382a9376aa22692e9ca830 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 19 Jan 2025 02:56:48 -0600 Subject: git branch handling continues --- doClean.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'doClean.go') diff --git a/doClean.go b/doClean.go index cfe5b19..0717ad6 100644 --- a/doClean.go +++ b/doClean.go @@ -56,17 +56,21 @@ func doCleanRepo(repo *gitpb.Repo) error { // todo: make sure the master branch is in sync with remote master continue } - hasLocal = true if name == repo.GetUserBranchName() { + hasLocal = true if err := doCleanUserBranch(repo, b); err != nil { + log.Info("\tLOCAL BRANCH ERROR user") return err } + log.Info("\tLOCAL BRANCH user") continue } if name == repo.GetDevelBranchName() { if err := doCleanDevelBranch(repo, b); err != nil { + log.Info("\tLOCAL BRANCH ERROR devel") return err } + log.Info("\tLOCAL BRANCH devel") continue } log.Info("\tlocal branch name unknown:", name, b.Merge, b.Remote) @@ -120,6 +124,18 @@ func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error { repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/remotes/origin", branch.Name)}) repo.RunVerbose([]string{"cat", filepath.Join(".git/refs/heads", branch.Name)}) + if err := userToDevelRequiresGitPush(repo, branch.Name); err != nil { + log.Info(err) + log.Info("THIS USER BRANCH MUST BE PUSHED TO DEVEL", branch.Name) + return err + } + log.Info("THIS USER BRANCH IS CLEAN TO DELETE", branch.Name) + if argv.Clean.Force != nil { + cmd := []string{"git", "branch", "-D", branch.Name} + _, err := repo.RunVerbose(cmd) + log.Info(err) + return err + } } else { log.Info("why is this local only branch a problem?", branch.Name) repo.RunVerbose([]string{"ls", "-l", ".git/refs/remotes/origin"}) @@ -130,12 +146,15 @@ func doCleanUserBranch(repo *gitpb.Repo, branch *gitpb.GitBranch) error { log.Info(cmd) } if err := userToDevelRequiresGitPush(repo, branch.Name); err != nil { + log.Info(err) + log.Info("THIS USER BRANCH MUST BE PUSHED TO DEVEL", branch.Name) return err } log.Info("THIS USER BRANCH IS CLEAN TO DELETE", branch.Name) if argv.Clean.Force != nil { cmd := []string{"git", "branch", "-D", branch.Name} _, err := repo.RunVerbose(cmd) + log.Info(err) return err } } -- cgit v1.2.3