Skip to content

Commit 313b3b4

Browse files
rgkimballByron
authored andcommitted
Avoids env var warning when path contains $/%; fix #832
1 parent 85cf7e8 commit 313b3b4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

git/repo/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class Repo(object):
7777
re_whitespace = re.compile(r'\s+')
7878
re_hexsha_only = re.compile('^[0-9A-Fa-f]{40}$')
7979
re_hexsha_shortened = re.compile('^[0-9A-Fa-f]{4,40}$')
80+
re_envvars = re.compile(r'(\$(\{\s?)?[a-zA-Z_]\w*(\}\s?)?|%\s?[a-zA-Z_]\w*\s?%)')
8081
re_author_committer_start = re.compile(r'^(author|committer)')
8182
re_tab_full_line = re.compile(r'^\t(.*)$')
8283

@@ -125,7 +126,7 @@ def __init__(self, path=None, odbt=GitCmdObjectDB, search_parent_directories=Fal
125126
epath = epath or path or os.getcwd()
126127
if not isinstance(epath, str):
127128
epath = str(epath)
128-
if expand_vars and ("%" in epath or "$" in epath):
129+
if expand_vars and re.search(self.re_envvars, epath):
129130
warnings.warn("The use of environment variables in paths is deprecated" +
130131
"\nfor security reasons and may be removed in the future!!")
131132
epath = expand_path(epath, expand_vars)

0 commit comments

Comments
 (0)