summaryrefslogtreecommitdiff
path: root/git/repo/base.py
diff options
context:
space:
mode:
authorRob Kimball <rob.kimball@voya.com>2019-11-22 12:08:20 -0500
committerSebastian Thiel <sebastian.thiel@icloud.com>2019-12-06 20:04:19 +0800
commit313b3b4425012528222e086b49359dacad26d678 (patch)
treeae0be2680701d94f9da90bd359b5ff3245f7727e /git/repo/base.py
parent85cf7e89682d061ea86514c112dfb684af664d45 (diff)
downloadgitpython-313b3b4425012528222e086b49359dacad26d678.tar.gz
Avoids env var warning when path contains $/%; fix #832
Diffstat (limited to 'git/repo/base.py')
-rw-r--r--git/repo/base.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/git/repo/base.py b/git/repo/base.py
index 106ed2eb..05c55edd 100644
--- a/git/repo/base.py
+++ b/git/repo/base.py
@@ -77,6 +77,7 @@ class Repo(object):
re_whitespace = re.compile(r'\s+')
re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$')
re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
+ re_envvars = re.compile(r'(\$(\{\s?)?[a-zA-Z_]\w*(\}\s?)?|%\s?[a-zA-Z_]\w*\s?%)')
re_author_committer_start = re.compile(r'^(author|committer)')
re_tab_full_line = re.compile(r'^\t(.*)$')
@@ -125,7 +126,7 @@ class Repo(object):
epath = epath or path or os.getcwd()
if not isinstance(epath, str):
epath = str(epath)
- if expand_vars and ("%" in epath or "$" in epath):
+ if expand_vars and re.search(self.re_envvars, epath):
warnings.warn("The use of environment variables in paths is deprecated" +
"\nfor security reasons and may be removed in the future!!")
epath = expand_path(epath, expand_vars)