crystal-lang / shards

Dependency manager for the Crystal language
Other
763 stars 100 forks source link

Disable interactive credential prompt for git resolver #411

Closed straight-shoota closed 4 years ago

straight-shoota commented 4 years ago

Resolves #316

Git repository requests over HTTP can result in 401 Authentication Required status code. This is typically the case when a repository is private. Some git providers also return this status code when a repository exists to avoid disclosing the existence of private repositories. By default, git clone prompts for credentials when it receives a 401 status code. When shards install uses git clone, this leads to unexpected and misleading behaviour. shards install is not meant to be used interactively, so this prompt should be completely disabled.

This PR implements this by using the environment variable GIT_ASKPASS set to a value resulting in false. It can still be overriden by setting the environment variable.

straight-shoota commented 4 years ago

The option doesn't need to be an absolute path. I also changed it to true because that's the minimal reduced value and should work in any shell (test probably too, but we don't really need a test here). I also changed from using the environment variable GIT_ASKPASS to the git config setting core.askPass because that seems cleaner. Overriding is still possible by setting the environment variable because it has precedence over the config setting.

jhass commented 4 years ago

Maybe add a comment explaining this both :)

I read the diff first and was very confused, as you need to know that the setting takes a command rather than a boolean value and that it's still overridable :)