-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4666 from cjerdonek/issue-1130-git-dir-env-vars
Address issue #1130 (GIT_DIR and GIT_WORK_TREE).
- Loading branch information
Showing
5 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Allow pip to work if the ``GIT_DIR`` and ``GIT_WORK_TREE`` environment | ||
variables are set. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
|
||
from pip._internal.utils.temp_dir import TempDirectory | ||
from pip._internal.vcs.git import Git | ||
|
||
|
||
def test_git_dir_ignored(): | ||
""" | ||
Test that a GIT_DIR environment variable is ignored. | ||
""" | ||
git = Git() | ||
with TempDirectory() as temp: | ||
temp_dir = temp.path | ||
env = {'GIT_DIR': 'foo'} | ||
# If GIT_DIR is not ignored, then os.listdir() will return ['foo']. | ||
git.run_command(['init', temp_dir], cwd=temp_dir, extra_environ=env) | ||
assert os.listdir(temp_dir) == ['.git'] | ||
|
||
|
||
def test_git_work_tree_ignored(): | ||
""" | ||
Test that a GIT_WORK_TREE environment variable is ignored. | ||
""" | ||
git = Git() | ||
with TempDirectory() as temp: | ||
temp_dir = temp.path | ||
git.run_command(['init', temp_dir], cwd=temp_dir) | ||
# Choose a directory relative to the cwd that does not exist. | ||
# If GIT_WORK_TREE is not ignored, then the command will error out | ||
# with: "fatal: This operation must be run in a work tree". | ||
env = {'GIT_WORK_TREE': 'foo'} | ||
git.run_command(['status', temp_dir], extra_environ=env, cwd=temp_dir) |