This repository has been archived by the owner on Dec 10, 2020. It is now read-only.
forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restore ChangedTargetGoalsIntegrationTest.
All of its tests were marked xfail but are now re-enabled with changes to ensure the targets and git repo under test are isolated from the host pants repo. In order to facilitate integration tests using an ephemeral git repo, a change is made to `build-support/pants_venv` to not rely on git to find the host pants repo root directory. Testing Done: Locally green: `./pants test-changed`. CI went green here: https://travis-ci.org/pantsbuild/pants/builds/159416022 Bugs closed: 3859 Reviewed at https://rbcommons.com/s/twitter/r/4227/
- Loading branch information
Showing
6 changed files
with
135 additions
and
53 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
|
||
|
||
function log() { | ||
echo -e "$@" 1>&2 | ||
} | ||
|
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
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 |
---|---|---|
|
@@ -11,8 +11,7 @@ | |
|
||
from pants.base.revision import Revision | ||
from pants.scm.git import Git | ||
from pants.util.contextutil import environment_as | ||
from pants.util.dirutil import safe_mkdtemp, safe_rmtree | ||
from pants.util.contextutil import environment_as, temporary_dir | ||
|
||
|
||
MIN_REQUIRED_GIT_VERSION = Revision.semver('1.7.10') | ||
|
@@ -29,16 +28,30 @@ def git_version(): | |
|
||
|
||
@contextmanager | ||
def initialize_repo(worktree): | ||
"""Initialize git repository for the given worktree.""" | ||
gitdir = safe_mkdtemp() | ||
with environment_as(GIT_DIR=gitdir, GIT_WORK_TREE=worktree): | ||
def initialize_repo(worktree, gitdir=None): | ||
"""Initialize a git repository for the given `worktree`. | ||
NB: The given `worktree` must contain at least one file which will be committed to form an initial | ||
commit. | ||
:param string worktree: The path to the git work tree. | ||
:param string gitdir: An optional path to the `.git` dir to use. | ||
:returns: A `Git` repository object that can be used to interact with the repo. | ||
:rtype: :class:`pants.scm.git.Git` | ||
""" | ||
@contextmanager | ||
def use_gitdir(): | ||
if gitdir: | ||
yield gitdir | ||
else: | ||
with temporary_dir() as d: | ||
yield d | ||
|
||
with use_gitdir() as git_dir, environment_as(GIT_DIR=git_dir, GIT_WORK_TREE=worktree): | ||
subprocess.check_call(['git', 'init']) | ||
subprocess.check_call(['git', 'config', 'user.email', '[email protected]']) | ||
subprocess.check_call(['git', 'config', 'user.name', 'Your Name']) | ||
subprocess.check_call(['git', 'add', '.']) | ||
subprocess.check_call(['git', 'commit', '-am', 'Add project files.']) | ||
|
||
yield Git(gitdir=gitdir, worktree=worktree) | ||
|
||
safe_rmtree(gitdir) | ||
yield Git(gitdir=git_dir, worktree=worktree) |