mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Bazel: properly fix lfs smudge script
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
[lfs]
|
||||
fetchinclude = nothing
|
||||
fetchinclude = /nothing
|
||||
|
||||
@@ -7,6 +7,8 @@ import os
|
||||
|
||||
sources = [pathlib.Path(arg).resolve() for arg in sys.argv[1:]]
|
||||
source_dir = pathlib.Path(os.path.commonpath(src.parent for src in sources))
|
||||
source_dir = subprocess.check_output(["git", "rev-parse", "--show-toplevel"], cwd=source_dir, text=True).strip()
|
||||
|
||||
|
||||
def is_lfs_pointer(fileobj):
|
||||
lfs_header = "version https://git-lfs.github.com/spec".encode()
|
||||
@@ -14,10 +16,14 @@ def is_lfs_pointer(fileobj):
|
||||
fileobj.seek(0)
|
||||
return lfs_header == actual_header
|
||||
|
||||
|
||||
for src in sources:
|
||||
with open(src, 'rb') as input:
|
||||
if is_lfs_pointer(input):
|
||||
lfs_pointer = input.read()
|
||||
rel_src = src.relative_to(source_dir).as_posix()
|
||||
with open(src.name, 'wb') as output:
|
||||
subprocess.run(["git", "lfs", "smudge", "--", src], stdin=input, stdout=output, check=True, cwd=source_dir)
|
||||
subprocess.run(["git", "-c", f"lfs.fetchinclude={rel_src}", "lfs", "smudge", "--", rel_src],
|
||||
input=lfs_pointer, stdout=output, check=True, cwd=source_dir)
|
||||
continue
|
||||
pathlib.Path(src.name).symlink_to(src)
|
||||
|
||||
Reference in New Issue
Block a user