diff options
| author | Jeff Carr <[email protected]> | 2025-01-19 00:35:58 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-19 00:35:58 -0600 |
| commit | d84d7d468778ce3e1182fd82d68a27b1e613e305 (patch) | |
| tree | d79ea054e69e62e4da1d3f77c4126a9262568f37 /doClean.go | |
| parent | 39f72d20344c5bbe05b83a13eee9c0d7b54f7e78 (diff) | |
more work on cleaning user branches
Diffstat (limited to 'doClean.go')
| -rw-r--r-- | doClean.go | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -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 +} |
