Skip to content

Commit dbaac4e

Browse files
authored
Merge pull request #23 from flying7eleven/feat/add-status-option-for-accessing-some-information-automatically
Add `--json` flag for the `status` sub-command
2 parents 9c74f91 + bdc8259 commit dbaac4e

File tree

15 files changed

+74
-18
lines changed

15 files changed

+74
-18
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
./git-team
22
target/
33
mocks/
4+
.idea/

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
VERSION := $(shell grep -E "version\s+=" `pwd`/main.go | awk -F '"' '{print $$2}')
22

33
GOOS :=
4+
GOARCH :=
45
prefix :=
56
UNAME_S := $(shell uname -s)
7+
UNAME_M := $(shell uname -m)
68
ifeq ($(UNAME_S),Darwin)
79
GOOS=darwin
810
prefix:=/usr/local
911
endif
12+
ifeq ($(UNAME_M),arm64)
13+
GOARCH=arm64
14+
endif
1015
ifeq ($(UNAME_S),Linux)
1116
GOOS=linux
1217
prefix:=/usr
1318
endif
19+
ifeq ($(UNAME_M),x86_64)
20+
GOARCH=amd64
21+
endif
1422

1523
exec_prefix := $(prefix)
1624
bindir := $(exec_prefix)/bin
@@ -47,7 +55,7 @@ test: go-test hookscript-tests
4755
verify: test acceptance-tests
4856

4957
mocks:
50-
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(CURR_DIR):/src" -w /src vektra/mockery:v2.14.0 --dir=src/ --all --keeptree
58+
docker run --rm --user "$(shell id -u):$(shell id -g)" -v "$(CURR_DIR):/src" -w /src vektra/mockery:v2.15.0 --dir=src/ --all --keeptree
5159

5260
go-test: mocks deps
5361
go test -cover ./src/...
@@ -61,7 +69,7 @@ ifndef GOPATH
6169
$(error GOPATH is not set)
6270
endif
6371
mkdir -p $(CURR_DIR)/target/bin
64-
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=amd64 go build -o $(CURR_DIR)/target/bin ./...
72+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(CURR_DIR)/target/bin ./...
6573
@echo "[INFO] Successfully built git-team version v$(VERSION)"
6674

6775
man-page: deps

acceptance-tests.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN go mod download
2929
COPY src ./src
3030
COPY main.go .
3131

32-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install ./...
32+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go install ./...
3333

3434
# ----------------------------------------------------------------- #
3535

acceptance-tests/disable_global.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ teardown() {
7272
assert_line "ls: /home/git-team-acceptance-test/.git-team/commit-templates/global/COMMIT_TEMPLATE: No such file or directory"
7373
}
7474

75-
@test "git-team: (scope: global) disable should treat a previously disabled git-team idempotently" {
75+
@test "git-team: (scope: global) disable should treat a previously disabled git-team in an idempotent way" {
7676
run /usr/local/bin/git-team disable
7777
assert_success
7878
assert_line "git-team disabled"

acceptance-tests/disable_repo_local.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ teardown() {
8585
assert_line "ls: /home/git-team-acceptance-test/.git-team/commit-templates/repo-local/$REPO_CHECKSUM: No such file or directory"
8686
}
8787

88-
@test "git-team: (scope: repo-local) disable should treat a previously disabled git-team idempotently" {
88+
@test "git-team: (scope: repo-local) disable should treat a previously disabled git-team in an idempotent way" {
8989
run /usr/local/bin/git-team disable
9090
assert_success
9191
assert_line "git-team disabled"

acceptance-tests/status_global.bats

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ setup() {
1313
assert_line 'git-team disabled'
1414
}
1515

16-
@test 'git-team: (scope: global) status should properly disaplay the enabled status' {
16+
@test 'git-team: (scope: global) status should properly display the enabled status' {
1717
/usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>'
1818

1919
run /usr/local/bin/git-team status
@@ -27,3 +27,13 @@ setup() {
2727
/usr/local/bin/git-team disable
2828
}
2929

30+
@test 'git-team: (scope: global) status should properly display the enabled status in a json format' {
31+
/usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>'
32+
33+
run /usr/local/bin/git-team status --json
34+
assert_success
35+
assert_line --index 0 '{"status":"enabled","coAuthors":["A <[email protected]>","B <[email protected]>","C <[email protected]>"],"previousHooksPath":""}'
36+
37+
/usr/local/bin/git-team disable
38+
}
39+

acceptance-tests/status_repo_local.bats

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ teardown() {
3030
assert_line 'git-team disabled'
3131
}
3232

33-
@test 'git-team: (scope: repo-local) status should properly disaplay the enabled status' {
33+
@test 'git-team: (scope: repo-local) status should properly display the enabled status' {
3434
/usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>'
3535

3636
run /usr/local/bin/git-team status
@@ -44,6 +44,15 @@ teardown() {
4444
/usr/local/bin/git-team disable
4545
}
4646

47+
@test 'git-team: (scope: repo-local) status should properly display the enabled status' {
48+
/usr/local/bin/git-team enable 'A <[email protected]>' 'B <[email protected]>' 'C <[email protected]>'
49+
50+
run /usr/local/bin/git-team status --json
51+
assert_success
52+
assert_line --index 0 '{"status":"enabled","coAuthors":["A <[email protected]>","B <[email protected]>","C <[email protected]>"],"previousHooksPath":""}'
53+
54+
/usr/local/bin/git-team disable
55+
}
4756

4857
@test 'git-team: (scope: repo-local) status should fail when not inside a git repository' {
4958
cd /tmp

hookscript-tests.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN go mod download
2929
COPY src ./src
3030
COPY main.go .
3131

32-
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go install ./...
32+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go install ./...
3333

3434
# ----------------------------------------------------------------- #
3535

src/command/disable/cliadapter/cmd/cmd_mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func Command() *cli.Command {
2121
Name: "disable",
2222
Usage: "Use default commit template and remove prepare-commit-msg hook",
2323
Action: func(c *cli.Context) error {
24-
return commandadapter.Run(policy(), disableeventadapter.MapEventToEffectFactory(statuscmdmapper.Policy()))
24+
return commandadapter.Run(policy(), disableeventadapter.MapEventToEffectFactory(statuscmdmapper.Policy(false)))
2525
},
2626
}
2727
}

src/command/enable/cliadapter/cmd/cmd_mapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Command() *cli.Command {
3232
Action: func(c *cli.Context) error {
3333
coauthors := c.Args().Slice()
3434
useAll := c.Bool("all")
35-
return commandadapter.Run(policy(&coauthors, &useAll), enableeventadapter.MapEventToEffectFactory(statuscmdmapper.Policy()))
35+
return commandadapter.Run(policy(&coauthors, &useAll), enableeventadapter.MapEventToEffectFactory(statuscmdmapper.Policy(false)))
3636
},
3737
BashComplete: func(c *cli.Context) {
3838
remainingAliases := aliascompletion.NewAliasShellCompletion(gitconfig.NewDataSource()).Complete(c.Args().Slice())

0 commit comments

Comments
 (0)