MCPcopy Create free account
hub / github.com/remotemobprogramming/mob / clean

Function clean

mob.go:411–438  ·  view source on GitHub ↗
(configuration config.Configuration)

Source from the content-addressed store, hash-verified

409}
410
411func clean(configuration config.Configuration) {
412 git("fetch", configuration.RemoteName, "--prune")
413
414 currentBranch := gitCurrentBranch()
415 localBranches := gitBranches()
416
417 if currentBranch.isOrphanWipBranch(configuration) {
418 currentBaseBranch, _ := determineBranches(currentBranch, localBranches, configuration)
419
420 say.Info("Current branch " + currentBranch.Name + " is an orphan")
421 if currentBaseBranch.exists(localBranches) {
422 git("checkout", currentBaseBranch.Name)
423 } else if newBranch("main").exists(localBranches) {
424 git("checkout", "main")
425 } else {
426 git("checkout", "master")
427 }
428 }
429
430 for _, branch := range localBranches {
431 b := newBranch(branch)
432 if b.isOrphanWipBranch(configuration) {
433 say.Info("Removing orphan wip branch " + b.Name)
434 git("branch", "-D", b.Name)
435 }
436 }
437
438}
439
440func (branch Branch) isOrphanWipBranch(configuration config.Configuration) bool {
441 return branch.IsWipBranch(configuration) && !branch.hasRemoteBranch(configuration)

Callers 7

TestCleanFunction · 0.85
TestCleanAfterStartFunction · 0.85
TestMobCleanFunction · 0.85
executeFunction · 0.85

Calls 8

InfoFunction · 0.92
gitFunction · 0.85
gitCurrentBranchFunction · 0.85
gitBranchesFunction · 0.85
determineBranchesFunction · 0.85
newBranchFunction · 0.85
isOrphanWipBranchMethod · 0.80
existsMethod · 0.80

Tested by 6

TestCleanFunction · 0.68
TestCleanAfterStartFunction · 0.68
TestMobCleanFunction · 0.68