From 6de7c7ad1b3439a72864153c6a86e3e026fb98dd Mon Sep 17 00:00:00 2001 From: Rui Yang Date: Fri, 1 Oct 2021 16:23:29 -0400 Subject: [PATCH] add git_config option Signed-off-by: Rui Yang --- README.md | 8 ++++++++ assets/check | 2 ++ assets/common.sh | 6 ++++++ assets/in | 3 +++ assets/out | 4 ++++ 5 files changed, 23 insertions(+) diff --git a/README.md b/README.md index bfa6d4c..5be0934 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,14 @@ filed named `.gitkeep`. Finally, create individual locks by making an empty file * `password`: *Optional.* Password for HTTP(S) auth when pulling/pushing. +* `git_config`: *Optional.* If specified as (list of pairs `name` and `value`) + it will configure git global options, setting each name with each value. + + This can be useful to set options like `credential.helper` or similar. + + See the [`git-config(1)` manual page](https://www.kernel.org/pub/software/scm/git/docs/git-config.html) + for more information and documentation of existing git options. + * `retry_delay`: *Optional.* If specified, dictates how long to wait until retrying to acquire a lock or release a lock. The default is 10 seconds. Valid values: `60s`, `90m`, `1h`. diff --git a/assets/check b/assets/check index 911966c..95fb152 100755 --- a/assets/check +++ b/assets/check @@ -23,7 +23,9 @@ uri=$(jq -r '.source.uri // ""' < $payload) branch=$(jq -r '.source.branch // ""' < $payload) pool_name=$(jq -r '.source.pool // ""' < $payload) ref=$(jq -r '.version.ref // ""' < $payload) +git_config_payload=$(jq -r '.source.git_config // []' < $payload) +configure_git_global "${git_config_payload}" if [ -z "$uri" ]; then config_errors="${config_errors}invalid payload (missing uri)\n" diff --git a/assets/common.sh b/assets/common.sh index 1bad43d..ff5d059 100644 --- a/assets/common.sh +++ b/assets/common.sh @@ -57,3 +57,9 @@ configure_credentials() { echo "default login $username password $password" > $HOME/.netrc fi } + +configure_git_global() { + local git_config_payload="$1" + eval $(echo "$git_config_payload" | \ + jq -r ".[] | \"git config --global '\\(.name)' '\\(.value)'; \"") +} diff --git a/assets/in b/assets/in index 3abca25..9c20568 100755 --- a/assets/in +++ b/assets/in @@ -41,6 +41,9 @@ branch=$(jq -r '.source.branch // ""' < $payload) pool_name=$(jq -r '.source.pool // ""' < $payload) ref=$(jq -r '.version.ref // "HEAD"' < $payload) depth=$(jq -r '(.params.depth // 0)' < $payload) +git_config_payload=$(jq -r '.source.git_config // []' < $payload) + +configure_git_global "${git_config_payload}" if [ -z "$uri" ]; then config_errors="${config_errors}invalid payload (missing uri)\n" diff --git a/assets/out b/assets/out index a037700..937de29 100755 --- a/assets/out +++ b/assets/out @@ -13,4 +13,8 @@ load_pubkey $payload configure_https_tunnel $payload configure_credentials $payload +git_config_payload=$(jq -r '.source.git_config // []' < $payload) + +configure_git_global "${git_config_payload}" + /opt/go/out $1 >&3 < $payload