Skip to content

Commit b046bf8

Browse files
Merge pull request remotemobprogramming#305 from remotemobprogramming/mobResetWarning
added reset warning and delete-remote-wip-branch parameter
2 parents 53731a5 + a8f31a0 commit b046bf8

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# 3.3.0
1+
# 4.0.0
2+
- **NEW** Feature: `mob reset` doesn't reset the mob branch anymore. It now warns you that it deletes the mob branch for everyone and if you want to continue do `mob reset --delete-remote-wip-branch`.
23
- Feature: `mob start --create` will create the remote branch and start the mob session on that branch.
34

45
# 3.2.0

mob.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
const (
25-
versionNumber = "3.3.0"
25+
versionNumber = "4.0.0"
2626
)
2727

2828
var (
@@ -74,6 +74,7 @@ type Configuration struct {
7474
TimerUser string // override with MOB_TIMER_USER
7575
TimerUrl string // override with MOB_TIMER_URL
7676
TimerInsecure bool // override with MOB_TIMER_INSECURE
77+
ResetDeleteRemoteWipBranch bool // override with MOB_RESET_DELETE_REMOTE_WIP_BRANCH
7778
}
7879

7980
func (c Configuration) wipBranchQualifierSuffix() string {
@@ -333,6 +334,7 @@ func getDefaultConfiguration() Configuration {
333334
TimerUrl: "https://timer.mob.sh/",
334335
WipBranchPrefix: "mob/",
335336
StashName: "mob-stash-name",
337+
ResetDeleteRemoteWipBranch: false,
336338
}
337339
}
338340

@@ -424,6 +426,8 @@ func parseUserConfiguration(configuration Configuration, path string) Configurat
424426
setUnquotedString(&configuration.StashName, key, value)
425427
case "MOB_TIMER_INSECURE":
426428
setBoolean(&configuration.TimerInsecure, key, value)
429+
case "MOB_RESET_DELETE_REMOTE_WIP_BRANCH":
430+
setBoolean(&configuration.ResetDeleteRemoteWipBranch, key, value)
427431

428432
default:
429433
continue
@@ -503,6 +507,8 @@ func parseProjectConfiguration(configuration Configuration, path string) Configu
503507
setUnquotedString(&configuration.StashName, key, value)
504508
case "MOB_TIMER_INSECURE":
505509
setBoolean(&configuration.TimerInsecure, key, value)
510+
case "MOB_RESET_DELETE_REMOTE_WIP_BRANCH":
511+
setBoolean(&configuration.ResetDeleteRemoteWipBranch, key, value)
506512

507513
default:
508514
continue
@@ -593,6 +599,8 @@ func parseEnvironmentVariables(configuration Configuration) Configuration {
593599
setStringFromEnvVariable(&configuration.TimerUrl, "MOB_TIMER_URL")
594600
setBoolFromEnvVariable(&configuration.TimerInsecure, "MOB_TIMER_INSECURE")
595601

602+
setBoolFromEnvVariable(&configuration.ResetDeleteRemoteWipBranch, "MOB_RESET_DELETE_REMOTE_WIP_BRANCH")
603+
596604
return configuration
597605
}
598606

@@ -743,6 +751,8 @@ func parseArgs(args []string, configuration Configuration) (command string, para
743751
newConfiguration.DoneSquash = SquashWip
744752
case "--create":
745753
newConfiguration.StartCreate = true
754+
case "--delete-remote-wip-branch":
755+
newConfiguration.ResetDeleteRemoteWipBranch = true
746756
default:
747757
if i == 1 {
748758
command = arg
@@ -1144,6 +1154,14 @@ func moo(configuration Configuration) {
11441154
}
11451155

11461156
func reset(configuration Configuration) {
1157+
if configuration.ResetDeleteRemoteWipBranch {
1158+
deleteRemoteWipBranch(configuration)
1159+
} else {
1160+
sayFix("Executing this command deletes the mob branch for everyone. If you're sure you want that, use", configuration.mob("reset --delete-remote-wip-branch"))
1161+
}
1162+
}
1163+
1164+
func deleteRemoteWipBranch(configuration Configuration) {
11471165
git("fetch", configuration.RemoteName)
11481166

11491167
currentBaseBranch, currentWipBranch := determineBranches(gitCurrentBranch(), gitBranches(), configuration)

mob_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ func TestStartWithMultipleExistingBranchesWithStay(t *testing.T) {
504504

505505
func TestStartNextWithBranch(t *testing.T) {
506506
_, configuration := setup(t)
507+
configuration.ResetDeleteRemoteWipBranch = true
507508
assertOnBranch(t, "master")
508509
configuration.WipBranchQualifier = "green"
509510

@@ -595,7 +596,16 @@ func TestStartNextWithBranchContainingHyphen(t *testing.T) {
595596
}
596597

597598
func TestReset(t *testing.T) {
599+
output, configuration := setup(t)
600+
601+
reset(configuration)
602+
603+
assertOutputContains(t, output, "mob reset --delete-remote-wip-branch")
604+
}
605+
606+
func TestResetDeleteRemoteWipBranch(t *testing.T) {
598607
_, configuration := setup(t)
608+
configuration.ResetDeleteRemoteWipBranch = true
599609

600610
reset(configuration)
601611

@@ -604,7 +614,23 @@ func TestReset(t *testing.T) {
604614
}
605615

606616
func TestResetCommit(t *testing.T) {
617+
output, configuration := setup(t)
618+
619+
start(configuration)
620+
createFile(t, "example.txt", "contentIrrelevant")
621+
next(configuration)
622+
assertMobSessionBranches(t, configuration, "mob-session")
623+
624+
reset(configuration)
625+
626+
assertOutputContains(t, output, "mob reset --delete-remote-wip-branch")
627+
assertMobSessionBranches(t, configuration, "mob-session")
628+
}
629+
630+
func TestResetDeleteRemoteWipBranchCommit(t *testing.T) {
607631
_, configuration := setup(t)
632+
configuration.ResetDeleteRemoteWipBranch = true
633+
608634
start(configuration)
609635
createFile(t, "example.txt", "contentIrrelevant")
610636
next(configuration)

0 commit comments

Comments
 (0)