Repository: remotemobprogramming/mob (go)

Issue:
mob status should show if a mob session exists
It would be helpful when `mob status` shows if a mob session exists on the current branch, when not on a mob branch, to look up if a remote mob branch already exists.

Something like this:

    ➜  myProject git:(main) mob status
    > you are on base branch 'main'
    > wip branch 'mob/main' contains 7 commits. The last 5 were:
    > 38209edb 6 hours ago <Wanda Hess>
    > 2359e605 5 hours ago <Ross Carter>
    > 3868b5c6 5 hours ago <Claudia Osborne>
    > b848355a 5 hours ago <Lee Klein>
    > 209e8bb2 5 hours ago <Ammar Carlson>

Pull request:
#410: added duration to latest commit for a remote branch to mob status
closes #410 

the result of the change can be seen here. 
```
$ mob status
> you are on base branch 'main'
> remote wip branches detected:
  - origin/mob/main (10 months ago)
  - origin/mob/main-my-feature (1 year, 4 months ago)

```

if there is no remote wip branch:
```
$ mob status
> you are on base branch 'main'
> no remote wip branches detected!
```


Patch:
diff --git a/mob.go b/mob.go
index f2a67fa..876c859 100644
--- a/mob.go
+++ b/mob.go
@@ -27,7 +27,7 @@ import (
 )
 
 const (
-	versionNumber     = "4.5.0"
+	versionNumber     = "4.5.1"
 	minimumGitVersion = "2.13.0"
 )
 
@@ -887,16 +887,6 @@ func warnForActiveWipBranches(configuration config.Configuration, currentBaseBra
 	}
 }
 
-func showActiveMobSessions(configuration config.Configuration, currentBaseBranch Branch) {
-	existingWipBranches := getWipBranchesForBaseBranch(currentBaseBranch, configuration)
-	if len(existingWipBranches) > 0 {
-		say.Info("remote wip branches detected:")
-		for _, wipBranch := range existingWipBranches {
-			say.WithPrefix(wipBranch, "  - ")
-		}
-	}
-}
-
 func sayUntrackedFilesInfo() {
 	untrackedFiles := getUntrackedFiles()
 	hasUntrackedFiles := len(untrackedFiles) > 0
@@ -1190,19 +1180,6 @@ func squashOrCommit(configuration config.Configuration) string {
 	}
 }
 
-func status(configuration config.Configuration) {
-	if isMobProgramming(configuration) {
-		currentBaseBranch, currentWipBranch := determineBranches(gitCurrentBranch(), gitBranches(), configuration)
-		say.Info("you are on wip branch " + currentWipBranch.String() + " (base branch " + currentBaseBranch.String() + ")")
-
-		sayLastCommitsList(currentBaseBranch.String(), currentWipBranch.String())
-	} else {
-		currentBaseBranch, _ := determineBranches(gitCurrentBranch(), gitBranches(), configuration)
-		say.Info("you are on base branch '" + currentBaseBranch.String() + "'")
-		showActiveMobSessions(configuration, currentBaseBranch)
-	}
-}
-
 func sayLastCommitsList(currentBaseBranch string, currentWipBranch string) {
 	commitsBaseWipBranch := currentBaseBranch + ".." + currentWipBranch
 	log := silentgit("--no-pager", "log", commitsBaseWipBranch, "--pretty=format:%h %cr <%an>", "--abbrev-commit")
diff --git a/status.go b/status.go
new file mode 100644
index 0000000..413fe98
--- /dev/null
+++ b/status.go
@@ -0,0 +1,32 @@
+package main
+
+import (
+	config "github.com/remotemobprogramming/mob/v4/configuration"
+	"github.com/remotemobprogramming/mob/v4/say"
+)
+
+func status(configuration config.Configuration) {
+	if isMobProgramming(configuration) {
+		currentBaseBranch, currentWipBranch := determineBranches(gitCurrentBranch(), gitBranches(), configuration)
+		say.Info("you are on wip branch " + currentWipBranch.String() + " (base branch " + currentBaseBranch.String() + ")")
+
+		sayLastCommitsList(currentBaseBranch.String(), currentWipBranch.String())
+	} else {
+		currentBaseBranch, _ := determineBranches(gitCurrentBranch(), gitBranches(), configuration)
+		say.Info("you are on base branch '" + currentBaseBranch.String() + "'")
+		showActiveMobSessions(configuration, currentBaseBranch)
+	}
+}
+
+func showActiveMobSessions(configuration config.Configuration, currentBaseBranch Branch) {
+	existingWipBranches := getWipBranchesForBaseBranch(currentBaseBranch, configuration)
+	if len(existingWipBranches) > 0 {
+		say.Info("remote wip branches detected:")
+		for _, wipBranch := range existingWipBranches {
+			time := silentgit("log", "-1", "--pretty=format:(%ar)", wipBranch)
+			say.WithPrefix(wipBranch+" "+time, "  - ")
+		}
+	} else {
+		say.Info("no remote wip branches detected!")
+	}
+}


Test patch:
diff --git a/mob_test.go b/mob_test.go
index 7fb0d71..7ae679d 100644
--- a/mob_test.go
+++ b/mob_test.go
@@ -177,38 +177,6 @@ func TestDoneNotMobProgramming(t *testing.T) {
 	assertOutputContains(t, output, "to start working together")
 }
 
-func TestStatusMobProgramming(t *testing.T) {
-	output, configuration := setup(t)
-	start(configuration)
-
-	status(configuration)
-
-	assertOutputContains(t, output, "you are on wip branch mob-session")
-}
-
-func TestStatusWithMoreThan5LinesOfLog(t *testing.T) {
-	output, configuration := setup(t)
-	configuration.NextStay = true
-	start(configuration)
-
-	for i := 0; i < 6; i++ {
-		createFile(t, "test"+strconv.Itoa(i)+".txt", "contentIrrelevant")
-		next(configuration)
-	}
-
-	status(configuration)
-	// 6 wip commits + 1 start commit
-	assertOutputContains(t, output, "wip branch 'mob-session' contains 7 commits.")
-}
-
-func TestExecuteKicksOffStatus(t *testing.T) {
-	output, _ := setup(t)
-
-	execute("status", []string{}, config.GetDefaultConfiguration())
-
-	assertOutputContains(t, output, "you are on base branch 'master'")
-}
-
 func TestExecuteInvalidCommandKicksOffHelp(t *testing.T) {
 	output, _ := setup(t)
 
diff --git a/status_test.go b/status_test.go
new file mode 100644
index 0000000..db7ae33
--- /dev/null
+++ b/status_test.go
@@ -0,0 +1,53 @@
+package main
+
+import (
+	config "github.com/remotemobprogramming/mob/v4/configuration"
+	"strconv"
+	"testing"
+)
+
+func TestExecuteKicksOffStatus(t *testing.T) {
+	output, _ := setup(t)
+
+	execute("status", []string{}, config.GetDefaultConfiguration())
+
+	assertOutputContains(t, output, "you are on base branch 'master'")
+}
+
+func TestStatusMobProgramming(t *testing.T) {
+	output, configuration := setup(t)
+	start(configuration)
+
+	status(configuration)
+
+	assertOutputContains(t, output, "you are on wip branch mob-session")
+}
+
+func TestStatusWithMoreThan5LinesOfLog(t *testing.T) {
+	output, configuration := setup(t)
+	configuration.NextStay = true
+	start(configuration)
+
+	for i := 0; i < 6; i++ {
+		createFile(t, "test"+strconv.Itoa(i)+".txt", "contentIrrelevant")
+		next(configuration)
+	}
+
+	status(configuration)
+	// 6 wip commits + 1 start commit
+	assertOutputContains(t, output, "wip branch 'mob-session' contains 7 commits.")
+}
+
+func TestStatusDetectsWipBranches(t *testing.T) {
+	output, configuration := setup(t)
+	start(configuration)
+	createFile(t, "test.txt", "contentIrrelevant")
+	next(configuration)
+	git("checkout", "master")
+
+	status(configuration)
+
+	assertOutputContains(t, output, "remote wip branches detected:\n  - origin/mob-session")
+	assertOutputContains(t, output, " second")
+	assertOutputContains(t, output, " ago)")
+}