Skip to content

Commit

Permalink
add git_config option
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Yang <[email protected]>
  • Loading branch information
Rui Yang committed Oct 1, 2021
1 parent 833aab3 commit 6de7c7a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 2 additions & 0 deletions assets/check
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions assets/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)'; \"")
}
3 changes: 3 additions & 0 deletions assets/in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions assets/out
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 6de7c7a

Please sign in to comment.