mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
fix archive permissions for ruby tar.gz roots
This commit is contained in:
parent
bd1658baae
commit
d5eda977ce
5 changed files with 20 additions and 4 deletions
|
|
@ -35,17 +35,20 @@ def make_archive(name: str, repo: str, ref: str, destdir: str) -> str:
|
|||
"""
|
||||
output_path = os.path.join(destdir, f'{name}.tar.gz')
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
# this ensures that the root directory has umask permissions
|
||||
gitdir = os.path.join(tmpdir, 'root')
|
||||
|
||||
# Clone the repository to the temporary directory
|
||||
subprocess.check_call(('git', 'clone', repo, tmpdir))
|
||||
subprocess.check_call(('git', '-C', tmpdir, 'checkout', ref))
|
||||
subprocess.check_call(('git', 'clone', repo, gitdir))
|
||||
subprocess.check_call(('git', '-C', gitdir, 'checkout', ref))
|
||||
|
||||
# We don't want the '.git' directory
|
||||
# It adds a bunch of size to the archive and we don't use it at
|
||||
# runtime
|
||||
shutil.rmtree(os.path.join(tmpdir, '.git'))
|
||||
shutil.rmtree(os.path.join(gitdir, '.git'))
|
||||
|
||||
with tarfile.open(output_path, 'w|gz') as tf:
|
||||
tf.add(tmpdir, name)
|
||||
tf.add(gitdir, name)
|
||||
|
||||
return output_path
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue