Skip to content

Commit

Permalink
[Downloader] Disable all git auth prompts on clone/pull (#3159)
Browse files Browse the repository at this point in the history
* fix(downloader): disable all git auth prompts on clone/pull

* chore(changelog): add towncrier entry
  • Loading branch information
Jackenmen authored and Michael H committed Dec 8, 2019
1 parent 6720507 commit 0f62614
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/downloader/3159.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable all git auth prompts when adding/updating repo with Downloader.
15 changes: 12 additions & 3 deletions redbot/cogs/downloader/repo_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,21 @@ def get_value(self, key, args, kwargs):


class Repo(RepoJSONMixin):
GIT_CLONE = "git clone --recurse-submodules -b {branch} {url} {folder}"
GIT_CLONE_NO_BRANCH = "git clone --recurse-submodules {url} {folder}"
GIT_CLONE = (
"git clone -c credential.helper= -c core.askpass="
" --recurse-submodules -b {branch} {url} {folder}"
)
GIT_CLONE_NO_BRANCH = (
"git -c credential.helper= -c core.askpass= clone --recurse-submodules {url} {folder}"
)
GIT_CURRENT_BRANCH = "git -C {path} symbolic-ref --short HEAD"
GIT_CURRENT_COMMIT = "git -C {path} rev-parse HEAD"
GIT_LATEST_COMMIT = "git -C {path} rev-parse {branch}"
GIT_HARD_RESET = "git -C {path} reset --hard origin/{branch} -q"
GIT_PULL = "git -C {path} pull --recurse-submodules -q --ff-only"
GIT_PULL = (
"git -c credential.helper= -c core.askpass= -C {path}"
" pull --recurse-submodules -q --ff-only"
)
GIT_DIFF_FILE_STATUS = (
"git -C {path} diff-tree --no-commit-id --name-status"
" -r -z --line-prefix='\t' {old_rev} {new_rev}"
Expand Down Expand Up @@ -513,6 +521,7 @@ async def _run(
"""
env = os.environ.copy()
env["GIT_TERMINAL_PROMPT"] = "0"
env.pop("GIT_ASKPASS", None)
# attempt to force all output to plain ascii english
# some methods that parse output may expect it
# according to gettext manual both variables have to be set:
Expand Down

0 comments on commit 0f62614

Please sign in to comment.