Skip to content

Commit

Permalink
When mob start fails the timer won't start now.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonharrer committed May 11, 2021
1 parent 019045c commit 9b349f2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.6.0
- When `mob start` fails the timer won't start now.

# 1.5.0
- Less noisy output: Only show number of unpushed commits in output if there are more than 0.
- Add experimental command `mob squash-wip` to squash any WIP commits in the wip branch into a following manual commit using `git rebase --interactive` with `mob` as the temporary `GIT_EDITOR`.
Expand Down
17 changes: 10 additions & 7 deletions mob.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
"os"
"os/exec"
Expand Down Expand Up @@ -281,8 +282,8 @@ func execute(command string, parameter []string, configuration Configuration) {

switch command {
case "s", "start":
start(configuration)
if !isMobProgramming(configuration) {
err := start(configuration)
if !isMobProgramming(configuration) || err != nil {
return
}
if len(parameter) > 0 {
Expand Down Expand Up @@ -514,7 +515,7 @@ func reset(configuration Configuration) {
sayInfo("Branches " + currentWipBranch + " and " + configuration.RemoteName + "/" + currentWipBranch + " deleted")
}

func start(configuration Configuration) {
func start(configuration Configuration) error {
stashed := false
if hasUncommittedChanges() {
if configuration.MobStartIncludeUncommittedChanges {
Expand All @@ -525,7 +526,7 @@ func start(configuration Configuration) {
sayUnstagedChangesInfo()
sayUntrackedFilesInfo()
sayTodo("To start mob programming including uncommitted changes, use", "mob start --include-uncommitted-changes")
return
return errors.New("cannot start; clean working tree required")
}
}

Expand All @@ -538,18 +539,18 @@ func start(configuration Configuration) {
sayInfo("qualified mob branches detected")
sayTodo("To start mob programming, use", "mob start --branch <branch>")
sayIndented("(use \"\" for the default mob branch)")
return
return errors.New("qualified mob branches detected")
}

if !hasRemoteBranch(currentBaseBranch, configuration) {
sayError("Remote branch " + configuration.RemoteName + "/" + currentBaseBranch + " is missing")
sayTodo("To set the upstream branch, use", "git push "+configuration.RemoteName+" "+currentBaseBranch+" --set-upstream")
return
return errors.New("Remote branch is missing")
}

if hasUnpushedCommits(currentBaseBranch, configuration) {
sayError("cannot start; unpushed changes on base branch must be pushed upstream")
return
return errors.New("cannot start; unpushed changes on base branch must be pushed upstream")
}

if !isMobProgramming(configuration) {
Expand All @@ -570,6 +571,8 @@ func start(configuration Configuration) {

sayInfo("on wip branch " + currentWipBranch + " (base branch " + currentBaseBranch + ")")
sayLastCommitsList(currentBaseBranch, currentWipBranch)

return nil // no error
}

func sayUntrackedFilesInfo() {
Expand Down

0 comments on commit 9b349f2

Please sign in to comment.