diff --git a/.development/.envrc b/.development/.envrc index 276ea37..d266fea 100644 --- a/.development/.envrc +++ b/.development/.envrc @@ -1,13 +1,35 @@ -#!/bin/sh +#!/bin/bash + +# This configuration allows for local testing of the bridge. It uses Git config +# environment variables to override local configuration without making changes +# to it. See https://git-scm.com/docs/git-config#ENVIRONMENT + +git_config_add() { + local key="$1" + local value="$2" + + index=$(( "${GIT_CONFIG_COUNT:-0}" - 1 )) + + # index is incremented each time a setting is added + index=$(( index + 1 )) + export GIT_CONFIG_COUNT=$(( index + 1 )) + export "GIT_CONFIG_KEY_${index}=${key}" + export "GIT_CONFIG_VALUE_${index}=${value}" +} -# default values -export GIT_CONFIG_COUNT=2 -export GIT_CONFIG_KEY_0="credential.https://github.com.usehttppath" -export GIT_CONFIG_VALUE_0="true" helper_path="$(expand_path ../helper)" -export GIT_CONFIG_KEY_1="credential.https://github.com.helper" -export GIT_CONFIG_VALUE_1="${helper_path}/buildkite-connector-credential-helper http://localhost:${SERVER_PORT:-8080}/credential-helper" +# Use the empty string to override helpers from other configuration +# See https://git-scm.com/docs/gitcredentials/2.29.0#Documentation/gitcredentials.txt-helper +git_config_add "credential.helper" "" +git_config_add "credential.https://github.com.helper" "" + +# Now configure the testing helper from the this repo. This uses the local JWT +# keys to create an OIDC token that mimics Buildkite's, but doesn't require a +# Buildkite agent. It only works if the server is run with the corresponding +# test keys; see the root .envrc for that information. +git_config_add "credential.https://github.com.helper" "${helper_path}/buildkite-connector-credential-helper http://localhost:${SERVER_PORT:-8080}/git-credentials" +git_config_add "credential.https://github.com.usehttppath" "true" source_up @@ -21,9 +43,15 @@ source_env_if_exists ".envrc.private" # # Git diagnostics # +# Useful git variables for understanding if the credential helper is working. +# -# useful git variables for understanding if the credential helper is working +# trace will show the credential commands that are executed # export GIT_TRACE=2 + +# like curl -v, but for git # export GIT_CURL_VERBOSE=1 + +# unsure about the value of this one # export GIT_TRACE_PACKET=1