Skip to content

Commit

Permalink
Merge pull request #435 from remotemobprogramming/434-push-options
Browse files Browse the repository at this point in the history
fix #434 ci skip push option is evaluated incorrectly
  • Loading branch information
hollesse authored Jul 8, 2024
2 parents 913c99c + 33c6553 commit e4ded45
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 39 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 5.0.1
- Fix: The configuration option `MOB_SKIP_CI_PUSH_OPTION_ENABLED` now works correctly

Thank you @stefanscheidt for reporting this issue

# 5.0.0
- Feature: You can now set goals
- Feature: Can make use of the git push-option "ci.skip"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ MOB_CLI_NAME="mob"
MOB_REMOTE_NAME="origin"
MOB_WIP_COMMIT_MESSAGE="mob next [ci-skip] [ci skip] [skip ci]"
MOB_START_COMMIT_MESSAGE="mob start [ci-skip] [ci skip] [skip ci]"
MOB_SKIP_CI_PUSH_OPTION_ENABLED=true
MOB_GIT_HOOKS_ENABLED=false
MOB_REQUIRE_COMMIT_MESSAGE=false
MOB_VOICE_COMMAND="say \"%s\""
Expand Down
2 changes: 1 addition & 1 deletion coauthors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"bufio"
"fmt"
"github.com/remotemobprogramming/mob/v4/say"
"github.com/remotemobprogramming/mob/v5/say"
"os"
"path"
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package configuration

import (
"bufio"
"github.com/remotemobprogramming/mob/v4/say"
"github.com/remotemobprogramming/mob/v5/say"
"os"
"runtime"
"strconv"
Expand Down
4 changes: 2 additions & 2 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package configuration

import (
"fmt"
"github.com/remotemobprogramming/mob/v4/say"
"github.com/remotemobprogramming/mob/v4/test"
"github.com/remotemobprogramming/mob/v5/say"
"github.com/remotemobprogramming/mob/v5/test"
"os"
"strings"
"testing"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/remotemobprogramming/mob/v4
module github.com/remotemobprogramming/mob/v5

go 1.22
6 changes: 3 additions & 3 deletions goal/goal.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/httpclient"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/httpclient"
"github.com/remotemobprogramming/mob/v5/say"
"io"
"os"
"strings"
Expand Down
4 changes: 2 additions & 2 deletions help/help.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package help

import (
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/say"
)

func Help(configuration config.Configuration) {
Expand Down
2 changes: 1 addition & 1 deletion httpclient/httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"crypto/x509"
"errors"
"fmt"
"github.com/remotemobprogramming/mob/v4/say"
"github.com/remotemobprogramming/mob/v5/say"
"io/ioutil"
"net/http"
"net/url"
Expand Down
28 changes: 16 additions & 12 deletions mob.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"bufio"
"errors"
"fmt"
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/goal"
"github.com/remotemobprogramming/mob/v4/help"
"github.com/remotemobprogramming/mob/v4/open"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/goal"
"github.com/remotemobprogramming/mob/v5/help"
"github.com/remotemobprogramming/mob/v5/open"
"github.com/remotemobprogramming/mob/v5/say"
"os"
"os/exec"
"path/filepath"
Expand All @@ -21,7 +21,7 @@ import (
)

const (
versionNumber = "5.0.0"
versionNumber = "5.0.1"
minimumGitVersion = "2.13.0"
)

Expand Down Expand Up @@ -755,11 +755,10 @@ func startNewMobSession(configuration config.Configuration) {

func gitPushArgs(c config.Configuration) []string {
pushArgs := []string{"push"}
if c.SkipCiPushOptionEnabled {
if !c.SkipCiPushOptionEnabled {
return pushArgs
} else {
return append(pushArgs, "--push-option", "ci.skip")
}
return append(pushArgs, "--push-option", "ci.skip")
}

func getUntrackedFiles() string {
Expand Down Expand Up @@ -1153,9 +1152,14 @@ func git(args ...string) {
if !isGit() {
say.Error("expecting the current working directory to be a git repository.")
} else {
say.Error(commandString)
say.Error(output)
say.Error(err.Error())
if strings.Contains(output, "does not support push options") {
say.Error("The receiving end does not support push options")
say.Fix("Disable the push option ci.skip in your .mob file or set the expected environment variable", "export MOB_SKIP_CI_PUSH_OPTION_ENABLED=false")
} else {
say.Error(commandString)
say.Error(output)
say.Error(err.Error())
}
}
Exit(1)
}
Expand Down
30 changes: 24 additions & 6 deletions mob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import (
"fmt"
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/open"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/open"
"github.com/remotemobprogramming/mob/v5/say"
"os"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -152,8 +152,8 @@ func TestNextNotMobProgramming(t *testing.T) {
}

func TestRequireCommitMessage(t *testing.T) {
output, _ := setup(t)
configuration := config.GetDefaultConfiguration()
output, configuration := setup(t)
configuration.NextStay = true
configuration.RequireCommitMessage = true
start(configuration)

Expand Down Expand Up @@ -216,13 +216,29 @@ func TestStartDespiteGitHook(t *testing.T) {
}

func TestStartWithCISkip(t *testing.T) {
_, configuration := setup(t)
output, configuration := setup(t)
configuration.SkipCiPushOptionEnabled = true
mockExit()

start(configuration)

assertOutputContains(t, output, "git push --push-option ci.skip --no-verify --set-upstream origin mob-session:mob-session")
assertOutputContains(t, output, "Disable the push option ci.skip in your .mob file or set the expected environment variable")
assertOutputContains(t, output, "export MOB_SKIP_CI_PUSH_OPTION_ENABLED=false")
resetExit()
}

func TestStartWithOutCISkip(t *testing.T) {
output, configuration := setup(t)
configuration.SkipCiPushOptionEnabled = false

start(configuration)

assertOnBranch(t, "mob-session")
assertMobSessionBranches(t, configuration, "mob-session")
assertCommitLogNotContainsMessage(t, "mob-session", configuration.StartCommitMessage)
assertOutputNotContains(t, output, "--push-option ci.skip")

}

func TestStartWithMultipleExistingBranches(t *testing.T) {
Expand Down Expand Up @@ -1901,6 +1917,8 @@ func gitStatus() GitStatus {

func setup(t *testing.T) (output *string, configuration config.Configuration) {
configuration = config.GetDefaultConfiguration()
// Test setup does not support push options
configuration.SkipCiPushOptionEnabled = false
configuration.NextStay = false
createTestbed(t, configuration)
assertOnBranch(t, "master")
Expand Down
4 changes: 2 additions & 2 deletions squash_wip.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/say"
"io"
"os"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion squash_wip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
config "github.com/remotemobprogramming/mob/v4/configuration"
config "github.com/remotemobprogramming/mob/v5/configuration"
"os"
"strings"
"testing"
Expand Down
4 changes: 2 additions & 2 deletions status.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package main

import (
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/say"
)

func status(configuration config.Configuration) {
Expand Down
2 changes: 1 addition & 1 deletion status_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
config "github.com/remotemobprogramming/mob/v4/configuration"
config "github.com/remotemobprogramming/mob/v5/configuration"
"strconv"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package test

import (
"fmt"
"github.com/remotemobprogramming/mob/v4/say"
"github.com/remotemobprogramming/mob/v5/say"
"os"
"path/filepath"
"reflect"
Expand Down
6 changes: 3 additions & 3 deletions timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"errors"
"fmt"
config "github.com/remotemobprogramming/mob/v4/configuration"
"github.com/remotemobprogramming/mob/v4/httpclient"
"github.com/remotemobprogramming/mob/v4/say"
config "github.com/remotemobprogramming/mob/v5/configuration"
"github.com/remotemobprogramming/mob/v5/httpclient"
"github.com/remotemobprogramming/mob/v5/say"
"runtime"
"strconv"
"time"
Expand Down

0 comments on commit e4ded45

Please sign in to comment.