Refactor isolated_temporary_checkout CM naming

Co-Authored-By: Pradyun Gedam <pradyunsg@gmail.com>
This commit is contained in:
Sviatoslav Sydorenko 2020-01-28 16:58:16 +01:00
parent daba4b4c9e
commit db028e516c
No known key found for this signature in database
GPG Key ID: 9345E8FEA89CA455
1 changed files with 7 additions and 4 deletions

View File

@ -204,14 +204,17 @@ def workdir(nox_session, dir_path: pathlib.Path):
@contextlib.contextmanager @contextlib.contextmanager
def mk_tmp_git_checkout(nox_session, target_commitish: str): def isolated_temporary_checkout(
nox_session: nox.sessions.Session,
target_ref: str,
) -> pathlib.Path:
"""Make a clean checkout of a given version in tmp dir.""" """Make a clean checkout of a given version in tmp dir."""
with tempfile.TemporaryDirectory() as tmp_dir_path: with tempfile.TemporaryDirectory() as tmp_dir_path:
tmp_dir = pathlib.Path(tmp_dir_path) tmp_dir = pathlib.Path(tmp_dir_path)
git_checkout_dir = tmp_dir / f'pip-build-{target_commitish}' git_checkout_dir = tmp_dir / f'pip-build-{target_ref}'
nox_session.run( nox_session.run(
'git', 'worktree', 'add', '--force', '--checkout', 'git', 'worktree', 'add', '--force', '--checkout',
str(git_checkout_dir), str(target_commitish), str(git_checkout_dir), str(target_ref),
external=True, silent=True, external=True, silent=True,
) )
@ -241,7 +244,7 @@ def build_release(session):
session.log("# Install dependencies") session.log("# Install dependencies")
session.install("setuptools", "wheel", "twine") session.install("setuptools", "wheel", "twine")
with mk_tmp_git_checkout(session, version) as build_dir_path: with isolated_temporary_checkout(session, version) as build_dir_path:
session.log( session.log(
"# Start the build in an isolated, " "# Start the build in an isolated, "
f"temporary Git checkout at {build_dir_path!s}", f"temporary Git checkout at {build_dir_path!s}",