Skip to content

Commit

Permalink
fix: git config environment starts at zero
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestelfer committed Apr 11, 2024
1 parent 324c2cb commit 059ce03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion hooks/environment
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ git_config_add() {
local key="$1"
local value="$2"

count="${GIT_CONFIG_COUNT:-0}"
count="${GIT_CONFIG_COUNT:--1}"

# count is incremented each time a setting is added
(( count = count + 1 ))
Expand Down
20 changes: 10 additions & 10 deletions tests/environment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ run_environment() {
run_environment "${PWD}/hooks/environment"

assert_success
assert_line "GIT_CONFIG_COUNT=2"
assert_line "GIT_CONFIG_KEY_1=credential.https://github.com.usehttppath"
assert_line "GIT_CONFIG_VALUE_1=true"
assert_line "GIT_CONFIG_KEY_2=credential.https://github.com.helper"
assert_line --regexp "GIT_CONFIG_VALUE_2=/.*/credential-helper/buildkite-connector-credential-helper http://test-location github-app-auth:default"
assert_line "GIT_CONFIG_COUNT=1"
assert_line "GIT_CONFIG_KEY_0=credential.https://github.com.usehttppath"
assert_line "GIT_CONFIG_VALUE_0=true"
assert_line "GIT_CONFIG_KEY_1=credential.https://github.com.helper"
assert_line --regexp "GIT_CONFIG_VALUE_1=/.*/credential-helper/buildkite-connector-credential-helper http://test-location github-app-auth:default"
}

@test "Adds config for non-default audience" {
Expand All @@ -65,11 +65,11 @@ run_environment() {
run_environment "${PWD}/hooks/environment"

assert_success
assert_line "GIT_CONFIG_COUNT=2"
assert_line "GIT_CONFIG_KEY_1=credential.https://github.com.usehttppath"
assert_line "GIT_CONFIG_VALUE_1=true"
assert_line "GIT_CONFIG_KEY_2=credential.https://github.com.helper"
assert_line --regexp "GIT_CONFIG_VALUE_2=/.*/credential-helper/buildkite-connector-credential-helper http://test-location test-audience"
assert_line "GIT_CONFIG_COUNT=1"
assert_line "GIT_CONFIG_KEY_0=credential.https://github.com.usehttppath"
assert_line "GIT_CONFIG_VALUE_0=true"
assert_line "GIT_CONFIG_KEY_1=credential.https://github.com.helper"
assert_line --regexp "GIT_CONFIG_VALUE_1=/.*/credential-helper/buildkite-connector-credential-helper http://test-location test-audience"
}

@test "Adds to existing configuration if present" {
Expand Down

0 comments on commit 059ce03

Please sign in to comment.