♻ Relocate get_git_untracked_files to utils

This commit is contained in:
Sviatoslav Sydorenko 2020-02-03 11:22:02 +01:00
parent 9d592b394a
commit d772171ad9
No known key found for this signature in database
GPG Key ID: 9345E8FEA89CA455
2 changed files with 17 additions and 17 deletions

View File

@ -7,7 +7,6 @@
import glob
import os
import shutil
import subprocess
import sys
import nox
@ -226,25 +225,10 @@ def build_dists(session):
"# Check if there's any Git-untracked files before building the wheel",
)
def get_git_untracked_files():
"""List all local file paths that aren't tracked by Git."""
git_ls_files_cmd = (
"git", "ls-files", "--ignored", "--exclude-standard",
"--others", "--", ".",
)
# session.run doesn't seem to return any output:
ls_files_out = subprocess.check_output(git_ls_files_cmd, text=True)
ls_files_out_lines = ls_files_out.splitlines()
for file_name in ls_files_out_lines:
if file_name.strip(): # it's useless if empty
continue
yield file_name
has_forbidden_git_untracked_files = any(
# Don't report the environment this session is running in
not untracked_file.startswith('.nox/build-release/')
for untracked_file in get_git_untracked_files()
for untracked_file in release.get_git_untracked_files()
)
if has_forbidden_git_untracked_files:
session.error(

View File

@ -169,3 +169,19 @@ def isolated_temporary_checkout(
str(git_checkout_dir),
external=True, silent=True,
)
def get_git_untracked_files() -> Iterator[str]:
"""List all local file paths that aren't tracked by Git."""
git_ls_files_cmd = (
"git", "ls-files",
"--ignored", "--exclude-standard",
"--others", "--", ".",
)
# session.run doesn't seem to return any output:
ls_files_out = subprocess.check_output(git_ls_files_cmd, text=True)
for file_name in ls_files_out.splitlines():
if file_name.strip(): # it's useless if empty
continue
yield file_name