-
Notifications
You must be signed in to change notification settings - Fork 2
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 #69 from davidalpert/67-getallglobalgit-mobco-auth…
- Loading branch information
Showing
5 changed files
with
152 additions
and
29 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
features/git-mob/bugs/67-getallglobal-errors-when-soloing.feature
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,28 @@ | ||
#@announce-gitmob-log | ||
#@announce-stdout @announce-stderr | ||
Feature: 🐛 GetAllGlobal(git-mob.co-author): nonzero exit code: 1: (when soloing) | ||
|
||
Background: | ||
Given I have installed git-mob into "local_bin" within the current directory | ||
And I look for executables in "local_bin" within the current directory | ||
|
||
Given a file named "~/.gitconfig" with: | ||
""" | ||
[user] | ||
name = Jane Doe | ||
email = jane@example.com | ||
""" | ||
And a simple git repo at "example" | ||
And I successfully run `git solo` | ||
|
||
Scenario: #67 git mob print | ||
Given I cd to "example" | ||
And I successfully run `git mob init` | ||
When I run `git mob print` | ||
Then the exit status should be 0 | ||
|
||
Scenario: #68 git commit | ||
Given I cd to "example" | ||
And I successfully run `git mob init` | ||
When I run `git commit --allow-empty -m "test message"` | ||
Then the exit status should be 0 |
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,61 @@ | ||
package gitConfig | ||
|
||
import "fmt" | ||
|
||
// re: https://git-scm.com/docs/git-config#_description | ||
// [the `git config`] command will fail with non-zero status upon error. Some exit codes are... | ||
|
||
// ExitCode of the `git config` command. | ||
type ExitCode int | ||
|
||
// ExitCodes | ||
const ( | ||
UnknownExitCode ExitCode = iota - 1 | ||
CommandSuccess // 0 | ||
SectionOrKeyIsInvalid | ||
SectionOrNameNotProvided | ||
FileIsInvalid | ||
FileCannotBeWritten | ||
CannotUnsetOptionWhichDoesNotExist | ||
CannotUnsetSetMultipleLinesMatched | ||
InvalidRegexp | ||
) | ||
|
||
var exitCodeNames = [...]string{ | ||
CommandSuccess: "On success, the command returns the exit code 0.", | ||
SectionOrKeyIsInvalid: "The section or key is invalid (ret = 1)", | ||
SectionOrNameNotProvided: "no section or name was provided (ret = 2)", | ||
FileIsInvalid: "the config file is invalid (ret = 3)", | ||
FileCannotBeWritten: "the config file cannot be written (ret = 4)", | ||
CannotUnsetOptionWhichDoesNotExist: "you try to unset an option which does not exist (ret = 5)", | ||
CannotUnsetSetMultipleLinesMatched: "you try to unset/set an option for which multiple lines match (ret = 5)", | ||
InvalidRegexp: "you try to use an invalid regexp (ret = 6)", | ||
} | ||
|
||
func (c ExitCode) String() string { | ||
if c.IsKnown() { | ||
return exitCodeNames[c] | ||
} | ||
|
||
if c == UnknownExitCode { | ||
return "unknown" | ||
} | ||
|
||
return "undocumented" | ||
} | ||
|
||
func (c ExitCode) IsKnown() bool { | ||
return UnknownExitCode < c && c <= InvalidRegexp | ||
} | ||
|
||
// Errorf wraps an error with the known interpretation from git | ||
func (c ExitCode) Errorf(err error) error { | ||
if err == nil { | ||
return nil | ||
} | ||
|
||
if c.IsKnown() { | ||
return fmt.Errorf("%s: %v", c, err) | ||
} | ||
return fmt.Errorf("%s: %v", UnknownExitCode, err) | ||
} |
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,30 @@ | ||
package gitConfig | ||
|
||
import "testing" | ||
|
||
func TestExitCode_String(t *testing.T) { | ||
tests := []struct { | ||
have ExitCode | ||
want int | ||
}{ | ||
{ | ||
have: CommandSuccess, | ||
want: 0, | ||
}, | ||
{ | ||
have: SectionOrKeyIsInvalid, | ||
want: 1, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.have.String(), func(t *testing.T) { | ||
if got := int(tt.have); got != tt.want { | ||
t.Errorf("String() = %v, want %v", got, tt.want) | ||
} | ||
|
||
if got := ExitCode(tt.want); got != tt.have { | ||
t.Errorf("String() = %v, want %v", got, tt.have) | ||
} | ||
}) | ||
} | ||
} |
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