diff --git a/README.md b/README.md
index 4a990388..a6a273f6 100644
--- a/README.md
+++ b/README.md
@@ -67,6 +67,10 @@ private_key: |
password (Optional) |
Password for HTTP(S) auth when pulling/pushing. |
+
+ credential_hosts (Optional) |
+ List of hostnames the HTTP(S) username/password may be sent to. When set, the credentials are written to .netrc scoped to these hosts instead of the default entry, which matches every host. Hosts are specified with no protocol, e.g. github.com. Submodules on hosts not listed here will not receive these credentials; use submodule_credentials for those. When omitted, credentials match all hosts (previous behavior). |
+
skip_ssl_verification (Optional) |
Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true. |
diff --git a/assets/common.sh b/assets/common.sh
index 6a2faccb..38f9a060 100644
--- a/assets/common.sh
+++ b/assets/common.sh
@@ -282,7 +282,14 @@ configure_credentials() {
configure_submodule_credentials "$1"
if [ "$username" != "" -a "$password" != "" ]; then
- echo "default login $username password $password" >> "${HOME}/.netrc"
+ local credential_hosts=$(jq -r '(.source.credential_hosts // []) | if type == "array" then .[] else . end' <<< "$1")
+ if [ "$credential_hosts" != "" ]; then
+ for host in $credential_hosts; do
+ echo "machine $host login $username password $password" >> "${HOME}/.netrc"
+ done
+ else
+ echo "default login $username password $password" >> "${HOME}/.netrc"
+ fi
fi
}
diff --git a/assets/source_schema.json b/assets/source_schema.json
index b9fa8775..36964c81 100644
--- a/assets/source_schema.json
+++ b/assets/source_schema.json
@@ -8,6 +8,7 @@
"forward_agent": "",
"username": "",
"password": "",
+ "credential_hosts": "",
"paths": "",
"sparse_paths": "",
"ignore_paths": "",
diff --git a/test/check.sh b/test/check.sh
index 04df6677..64fcd7a3 100755
--- a/test/check.sh
+++ b/test/check.sh
@@ -168,6 +168,31 @@ EOF
[ ! -f "$HOME/.netrc" ]
}
+it_scopes_credentials_to_credential_hosts() {
+ local repo=$(init_repo)
+ local ref=$(make_commit "$repo")
+ local expected_netrc
+ expected_netrc=$(cat <