-
Notifications
You must be signed in to change notification settings - Fork 11
Add --json flag for the status sub-command
#23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
hekmekk
merged 9 commits into
hekmekk:main
from
flying7eleven:feat/add-status-option-for-accessing-some-information-automatically
Jun 6, 2025
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b5e5035
chore: fix some smaller typos
flying7eleven d3b7a2b
chore: add the .idea folder to the ignore list
flying7eleven 7b751bf
feat: allow the test to run natively on arm64 if the device supports it
flying7eleven 259351e
refactor: ensure the a variable does not shadow an import with same name
flying7eleven e8887f1
feat: add a --json flag to the status command
flying7eleven c8aa395
fix: ensure the braces for the email addresses are not encoded
flying7eleven cdc903a
fix: ensure the StateRetrievalSucceeded still can be logged
flying7eleven be5ddad
fix: ensure an encoding error gets handled correctly and not silently
flying7eleven bdc8259
fix: return json encoding error
hekmekk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| ./git-team | ||
| target/ | ||
| mocks/ | ||
| .idea/ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ setup() { | |
| assert_line 'git-team disabled' | ||
| } | ||
|
|
||
| @test 'git-team: (scope: global) status should properly disaplay the enabled status' { | ||
| @test 'git-team: (scope: global) status should properly display the enabled status' { | ||
| /usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>' | ||
|
|
||
| run /usr/local/bin/git-team status | ||
|
|
@@ -27,3 +27,13 @@ setup() { | |
| /usr/local/bin/git-team disable | ||
| } | ||
|
|
||
| @test 'git-team: (scope: global) status should properly display the enabled status in a json format' { | ||
| /usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>' | ||
|
|
||
| run /usr/local/bin/git-team status --json | ||
| assert_success | ||
| assert_line --index 0 '{"status":"enabled","coAuthors":["A <[email protected]>","B <[email protected]>","C <[email protected]>"],"previousHooksPath":""}' | ||
|
|
||
| /usr/local/bin/git-team disable | ||
| } | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ teardown() { | |
| assert_line 'git-team disabled' | ||
| } | ||
|
|
||
| @test 'git-team: (scope: repo-local) status should properly disaplay the enabled status' { | ||
| @test 'git-team: (scope: repo-local) status should properly display the enabled status' { | ||
| /usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>' | ||
|
|
||
| run /usr/local/bin/git-team status | ||
|
|
@@ -44,6 +44,15 @@ teardown() { | |
| /usr/local/bin/git-team disable | ||
| } | ||
|
|
||
| @test 'git-team: (scope: repo-local) status should properly display the enabled status' { | ||
| /usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>' | ||
|
|
||
| run /usr/local/bin/git-team status --json | ||
| assert_success | ||
| assert_line --index 0 '{"status":"enabled","coAuthors":["A <[email protected]>","B <[email protected]>","C <[email protected]>"],"previousHooksPath":""}' | ||
|
|
||
| /usr/local/bin/git-team disable | ||
| } | ||
|
|
||
| @test 'git-team: (scope: repo-local) status should fail when not inside a git repository' { | ||
| cd /tmp | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package statuseventadapter | |
|
|
||
| import ( | ||
| "bytes" | ||
| "encoding/json" | ||
| "fmt" | ||
| "sort" | ||
|
|
||
|
|
@@ -17,6 +18,9 @@ import ( | |
| func MapEventToEffect(event events.Event) effects.Effect { | ||
| switch evt := event.(type) { | ||
| case status.StateRetrievalSucceeded: | ||
| if evt.StateAsJson { | ||
| return effects.NewExitOkMsg(toJson(evt.State)) | ||
hekmekk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return effects.NewExitOkMsg(toString(evt.State)) | ||
| case status.StateRetrievalFailed: | ||
| return effects.NewExitErrMsg(evt.Reason) | ||
|
|
@@ -44,3 +48,14 @@ func toString(theState state.State) string { | |
|
|
||
| return buffer.String() | ||
| } | ||
|
|
||
| func toJson(theState state.State) string { | ||
hekmekk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| var buffer bytes.Buffer | ||
| encoder := json.NewEncoder(&buffer) | ||
| encoder.SetEscapeHTML(false) | ||
| err := encoder.Encode(theState) | ||
| if err != nil { | ||
| return buffer.String() | ||
|
||
| } | ||
| return buffer.String() | ||
hekmekk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.