mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 16:24:40 +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
|
|
@ -34,17 +34,17 @@ def _update_repo(repo_config, runner, tags_only):
|
|||
"""
|
||||
repo_path = runner.store.clone(repo_config['repo'], repo_config['rev'])
|
||||
|
||||
cmd_output('git', '-C', repo_path, 'fetch')
|
||||
tag_cmd = ('git', '-C', repo_path, 'describe', 'origin/master', '--tags')
|
||||
cmd_output('git', 'fetch', cwd=repo_path)
|
||||
tag_cmd = ('git', 'describe', 'origin/master', '--tags')
|
||||
if tags_only:
|
||||
tag_cmd += ('--abbrev=0',)
|
||||
else:
|
||||
tag_cmd += ('--exact',)
|
||||
try:
|
||||
rev = cmd_output(*tag_cmd)[1].strip()
|
||||
rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()
|
||||
except CalledProcessError:
|
||||
tag_cmd = ('git', '-C', repo_path, 'rev-parse', 'origin/master')
|
||||
rev = cmd_output(*tag_cmd)[1].strip()
|
||||
tag_cmd = ('git', 'rev-parse', 'origin/master')
|
||||
rev = cmd_output(*tag_cmd, cwd=repo_path)[1].strip()
|
||||
|
||||
# Don't bother trying to update if our rev is the same
|
||||
if rev == repo_config['rev']:
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ def make_archive(name, repo, ref, destdir):
|
|||
with tmpdir() as tempdir:
|
||||
# Clone the repository to the temporary directory
|
||||
cmd_output('git', 'clone', repo, tempdir)
|
||||
cmd_output('git', '-C', tempdir, 'checkout', ref)
|
||||
cmd_output('git', 'checkout', ref, cwd=tempdir)
|
||||
|
||||
# We don't want the '.git' directory
|
||||
# It adds a bunch of size to the archive and we don't use it at
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ class Store(object):
|
|||
env = no_git_env()
|
||||
|
||||
def _git_cmd(*args):
|
||||
return cmd_output('git', '-C', directory, *args, env=env)
|
||||
return cmd_output('git', *args, cwd=directory, env=env)
|
||||
|
||||
_git_cmd('clone', '--no-checkout', repo, '.')
|
||||
_git_cmd('reset', ref, '--hard')
|
||||
|
|
@ -163,7 +163,7 @@ class Store(object):
|
|||
|
||||
# initialize the git repository so it looks more like cloned repos
|
||||
def _git_cmd(*args):
|
||||
cmd_output('git', '-C', directory, *args, env=env)
|
||||
cmd_output('git', *args, cwd=directory, env=env)
|
||||
|
||||
_git_cmd('init', '.')
|
||||
_git_cmd('config', 'remote.origin.url', '<<unknown>>')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue