mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 16:44:42 +04:00
Restore git 1.8 support
This commit is contained in:
parent
179f11bdce
commit
96e9d1b758
10 changed files with 35 additions and 38 deletions
|
|
@ -62,12 +62,12 @@ def test_autoupdate_old_revision_broken(
|
|||
path = make_repo(tempdir_factory, 'python_hooks_repo')
|
||||
config = make_config_from_repo(path, check=False)
|
||||
|
||||
cmd_output('git', '-C', path, 'mv', C.MANIFEST_FILE, 'nope.yaml')
|
||||
cmd_output('git', '-C', path, 'commit', '-m', 'simulate old repo')
|
||||
cmd_output('git', 'mv', C.MANIFEST_FILE, 'nope.yaml', cwd=path)
|
||||
cmd_output('git', 'commit', '-m', 'simulate old repo', cwd=path)
|
||||
# Assume this is the revision the user's old repository was at
|
||||
rev = git.head_rev(path)
|
||||
cmd_output('git', '-C', path, 'mv', 'nope.yaml', C.MANIFEST_FILE)
|
||||
cmd_output('git', '-C', path, 'commit', '-m', 'move hooks file')
|
||||
cmd_output('git', 'mv', 'nope.yaml', C.MANIFEST_FILE, cwd=path)
|
||||
cmd_output('git', 'commit', '-m', 'move hooks file', cwd=path)
|
||||
update_rev = git.head_rev(path)
|
||||
|
||||
config['rev'] = rev
|
||||
|
|
@ -86,7 +86,7 @@ def out_of_date_repo(tempdir_factory):
|
|||
original_rev = git.head_rev(path)
|
||||
|
||||
# Make a commit
|
||||
cmd_output('git', '-C', path, 'commit', '--allow-empty', '-m', 'foo')
|
||||
cmd_output('git', 'commit', '--allow-empty', '-m', 'foo', cwd=path)
|
||||
head_rev = git.head_rev(path)
|
||||
|
||||
yield auto_namedtuple(
|
||||
|
|
@ -221,7 +221,7 @@ def test_loses_formatting_when_not_detectable(
|
|||
|
||||
@pytest.fixture
|
||||
def tagged_repo(out_of_date_repo):
|
||||
cmd_output('git', '-C', out_of_date_repo.path, 'tag', 'v1.2.3')
|
||||
cmd_output('git', 'tag', 'v1.2.3', cwd=out_of_date_repo.path)
|
||||
yield out_of_date_repo
|
||||
|
||||
|
||||
|
|
@ -240,8 +240,7 @@ def test_autoupdate_tagged_repo(
|
|||
|
||||
@pytest.fixture
|
||||
def tagged_repo_with_more_commits(tagged_repo):
|
||||
cmd = ('git', '-C', tagged_repo.path, 'commit', '--allow-empty', '-mfoo')
|
||||
cmd_output(*cmd)
|
||||
cmd_output('git', 'commit', '--allow-empty', '-mfoo', cwd=tagged_repo.path)
|
||||
yield tagged_repo
|
||||
|
||||
|
||||
|
|
@ -268,8 +267,8 @@ def hook_disappearing_repo(tempdir_factory):
|
|||
get_resource_path('manifest_without_foo.yaml'),
|
||||
os.path.join(path, C.MANIFEST_FILE),
|
||||
)
|
||||
cmd_output('git', '-C', path, 'add', '.')
|
||||
cmd_output('git', '-C', path, 'commit', '-m', 'Remove foo')
|
||||
cmd_output('git', 'add', '.', cwd=path)
|
||||
cmd_output('git', 'commit', '-m', 'Remove foo', cwd=path)
|
||||
|
||||
yield auto_namedtuple(path=path, original_rev=original_rev)
|
||||
|
||||
|
|
|
|||
|
|
@ -161,8 +161,8 @@ def test_install_pre_commit_and_run_custom_path(tempdir_factory):
|
|||
def test_install_in_submodule_and_run(tempdir_factory):
|
||||
src_path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||
parent_path = git_dir(tempdir_factory)
|
||||
cmd_output('git', '-C', parent_path, 'submodule', 'add', src_path, 'sub')
|
||||
cmd_output('git', '-C', parent_path, 'commit', '-m', 'foo')
|
||||
cmd_output('git', 'submodule', 'add', src_path, 'sub', cwd=parent_path)
|
||||
cmd_output('git', 'commit', '-m', 'foo', cwd=parent_path)
|
||||
|
||||
sub_pth = os.path.join(parent_path, 'sub')
|
||||
with cwd(sub_pth):
|
||||
|
|
|
|||
|
|
@ -69,8 +69,8 @@ def _make_conflict():
|
|||
def in_merge_conflict(tempdir_factory):
|
||||
path = make_consuming_repo(tempdir_factory, 'script_hooks_repo')
|
||||
open(os.path.join(path, 'dummy'), 'a').close()
|
||||
cmd_output('git', '-C', path, 'add', 'dummy')
|
||||
cmd_output('git', '-C', path, 'commit', '-m', 'Add config.')
|
||||
cmd_output('git', 'add', 'dummy', cwd=path)
|
||||
cmd_output('git', 'commit', '-m', 'Add config.', cwd=path)
|
||||
|
||||
conflict_path = tempdir_factory.get()
|
||||
cmd_output('git', 'clone', path, conflict_path)
|
||||
|
|
@ -83,8 +83,8 @@ def in_merge_conflict(tempdir_factory):
|
|||
def in_conflicting_submodule(tempdir_factory):
|
||||
git_dir_1 = git_dir(tempdir_factory)
|
||||
git_dir_2 = git_dir(tempdir_factory)
|
||||
cmd_output('git', '-C', git_dir_2, 'commit', '--allow-empty', '-minit!')
|
||||
cmd_output('git', '-C', git_dir_1, 'submodule', 'add', git_dir_2, 'sub')
|
||||
cmd_output('git', 'commit', '--allow-empty', '-minit!', cwd=git_dir_2)
|
||||
cmd_output('git', 'submodule', 'add', git_dir_2, 'sub', cwd=git_dir_1)
|
||||
with cwd(os.path.join(git_dir_1, 'sub')):
|
||||
_make_conflict()
|
||||
yield
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ def test_make_archive(tempdir_factory):
|
|||
git_path = git_dir(tempdir_factory)
|
||||
# Add a files to the git directory
|
||||
open(os.path.join(git_path, 'foo'), 'a').close()
|
||||
cmd_output('git', '-C', git_path, 'add', '.')
|
||||
cmd_output('git', '-C', git_path, 'commit', '-m', 'foo')
|
||||
cmd_output('git', 'add', '.', cwd=git_path)
|
||||
cmd_output('git', 'commit', '-m', 'foo', cwd=git_path)
|
||||
# We'll use this rev
|
||||
head_rev = git.head_rev(git_path)
|
||||
# And check that this file doesn't exist
|
||||
open(os.path.join(git_path, 'bar'), 'a').close()
|
||||
cmd_output('git', '-C', git_path, 'add', '.')
|
||||
cmd_output('git', '-C', git_path, 'commit', '-m', 'bar')
|
||||
cmd_output('git', 'add', '.', cwd=git_path)
|
||||
cmd_output('git', 'commit', '-m', 'bar', cwd=git_path)
|
||||
|
||||
# Do the thing
|
||||
archive_path = make_archives.make_archive(
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ def submodule_with_commits(tempdir_factory):
|
|||
|
||||
|
||||
def checkout_submodule(rev):
|
||||
cmd_output('git', '-C', 'sub', 'checkout', rev)
|
||||
cmd_output('git', 'checkout', rev, cwd='sub')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue