-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #413 from remotemobprogramming/410-status-time
#410: added duration to latest commit for a remote branch to mob status
- Loading branch information
Showing
4 changed files
with
86 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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!") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)") | ||
} |