Repository: remotemobprogramming/mob (go)

Issue:
Allow env var to configure "mob done" squash, but leave manual commits
Now that `mob done` has three options, the boolean for the env var `MOB_DONE_SQUASH` no longer makes sense. I'd like to default to "squash only wip commits".  Either that env var needs to change, or a new env var is needed, unless I'm missing some other way to configure that default?

Pull request description:
Print a deprecation message when MOB_DONE_SQUASH is set to true or false
This PR:

* should be enough to resolve #253
* displays a deprecation message when `MOB_DONE_SQUASH` is set to `true` or `false`, or the quoted values using an  environment variable or the configuration files
* updates the examples to use values that are not deprecated

--

### Screenshots / Demo

When using environment variables:

<img width="626" alt="Screen Shot 2022-07-05 at 14 49 25" src="https://user-images.githubusercontent.com/2585460/177397189-29e37b85-bf59-46e9-b58c-899e0b8c10f3.png">

When using the `.mob` configuration file:

<img width="645" alt="Screen Shot 2022-07-05 at 14 51 25" src="https://user-images.githubusercontent.com/2585460/177397183-1a1b51cc-c48f-4fda-b587-fb51b9fc45a7.png">


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b5790fb..cae11f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,7 @@
   - Skip suggestions if there has only been a single person so far.
   - Consider the case of a new typist joining the session.
   - Fix reporting on first commit.
+- Show a deprecation warning when MOB_DONE_SQUASH is set to `true` or `false` in the environment variable or in the .mob configuration file.
 
 # 3.1.4
 - Fixes a bug where mob saves the wrong filepath of the last modfied file in the wip commit message.
diff --git a/README.md b/README.md
index bfe1d7b..cd067a9 100644
--- a/README.md
+++ b/README.md
@@ -371,7 +371,7 @@ MOB_STASH_NAME="mob-stash-name"
 MOB_WIP_BRANCH_QUALIFIER=""
 MOB_WIP_BRANCH_QUALIFIER_SEPARATOR="-"
 MOB_WIP_BRANCH_PREFIX="mob/"
-MOB_DONE_SQUASH=true
+MOB_DONE_SQUASH=squash
 MOB_OPEN_COMMAND="idea %s"
 MOB_TIMER=""
 MOB_TIMER_ROOM="mob"
diff --git a/mob-configuration-example b/mob-configuration-example
index e55d81d..ebb3aed 100644
--- a/mob-configuration-example
+++ b/mob-configuration-example
@@ -8,7 +8,7 @@ MOB_NEXT_STAY=true
 MOB_START_INCLUDE_UNCOMMITTED_CHANGES=false
 MOB_WIP_BRANCH_QUALIFIER=""
 MOB_WIP_BRANCH_QUALIFIER_SEPARATOR="-"
-MOB_DONE_SQUASH=true
+MOB_DONE_SQUASH=squash
 MOB_TIMER="10"
 MOB_TIMER_ROOM="my-room"
 MOB_TIMER_ROOM_USE_WIP_BRANCH_QUALIFIER=false
diff --git a/mob.go b/mob.go
index 39f928e..250ac9a 100644
--- a/mob.go
+++ b/mob.go
@@ -531,6 +531,7 @@ func setMobDoneSquash(configuration *Configuration, key string, value string) {
 		}
 		value = unquotedValue
 	}
+	printDeprecatedDoneSquashMessage(value)
 	configuration.DoneSquash = doneSquash(value)
 	debugInfo("Overwriting " + key + " =" + string(configuration.DoneSquash))
 }
@@ -620,7 +621,7 @@ func setDoneSquashFromEnvVariable(configuration *Configuration, key string) {
 	if !set {
 		return
 	}
-
+	printDeprecatedDoneSquashMessage(value)
 	configuration.DoneSquash = doneSquash(value)
 
 	if value == "" {
@@ -631,6 +632,18 @@ func setDoneSquashFromEnvVariable(configuration *Configuration, key string) {
 	debugInfo("overriding " + key + "=" + string(configuration.DoneSquash))
 }
 
+func printDeprecatedDoneSquashMessage(value string) {
+	unquotedValue, err := strconv.Unquote(value)
+	if err != nil {
+		unquotedValue = value
+	}
+
+	if unquotedValue == "true" || unquotedValue == "false" {
+		newValue := doneSquash(unquotedValue)
+		say("MOB_DONE_SQUASH is set to the deprecated value " + value + ". Use the value " + newValue + " instead.")
+	}
+}
+
 func removed(key string, message string) {
 	if _, set := os.LookupEnv(key); set {
 		say("Configuration option '" + key + "' is no longer used.")


Test patch:
diff --git a/mob_test.go b/mob_test.go
index 45f4ef3..25a5d45 100644
--- a/mob_test.go
+++ b/mob_test.go
@@ -344,7 +344,7 @@ func TestReadConfigurationFromFileOverrideEverything(t *testing.T) {
 		MOB_WIP_BRANCH_QUALIFIER="green"
 		MOB_WIP_BRANCH_QUALIFIER_SEPARATOR="---"
 		MOB_WIP_BRANCH_PREFIX="ensemble/"
-		MOB_DONE_SQUASH=false
+		MOB_DONE_SQUASH=no-squash
 		MOB_OPEN_COMMAND="idea %s"
 		MOB_TIMER="123"
 		MOB_TIMER_ROOM="Room_42"
@@ -1536,6 +1536,46 @@ func TestSetMobDoneSquashEmptyStringValue(t *testing.T) {
 	equals(t, Squash, configuration.DoneSquash)
 }
 
+func TestPrintDeprecatedDoneSquashMessageWhenValueIsTrue(t *testing.T) {
+	output, _ := setup(t)
+
+	printDeprecatedDoneSquashMessage("true")
+
+	assertOutputContains(t, output, "MOB_DONE_SQUASH is set to the deprecated value true. Use the value squash instead")
+}
+
+func TestPrintDeprecatedDoneSquashMessageWhenValueIsQuotedTrue(t *testing.T) {
+	output, _ := setup(t)
+
+	printDeprecatedDoneSquashMessage("\"true\"")
+
+	assertOutputContains(t, output, "MOB_DONE_SQUASH is set to the deprecated value \"true\". Use the value squash instead")
+}
+
+func TestPrintDeprecatedDoneSquashMessageWhenValueIsFalse(t *testing.T) {
+	output, _ := setup(t)
+
+	printDeprecatedDoneSquashMessage("false")
+
+	assertOutputContains(t, output, "MOB_DONE_SQUASH is set to the deprecated value false. Use the value no-squash instead")
+}
+
+func TestPrintDeprecatedDoneSquashMessageWhenValueIsQuotedFalse(t *testing.T) {
+	output, _ := setup(t)
+
+	printDeprecatedDoneSquashMessage("\"false\"")
+
+	assertOutputContains(t, output, "MOB_DONE_SQUASH is set to the deprecated value \"false\". Use the value no-squash instead")
+}
+
+func TestDoesNotPrintDeprecatedDoneSquashMessageWhenUsingNewValue(t *testing.T) {
+	output, _ := setup(t)
+
+	printDeprecatedDoneSquashMessage(Squash)
+
+	assertOutputNotContains(t, output, "MOB_DONE_SQUASH is set to the deprecated value")
+}
+
 func TestHelpRequested(t *testing.T) {
 	equals(t, false, helpRequested([]string{""}))
 	equals(t, false, helpRequested([]string{"a", "mob", "21"}))