forked from Mirror/pmbootstrap
pmbootstrap ci: fix error with deleted files
Check if each file listed by the two git ls-files commands still exists, and only add the existing ones to the tarball. Otherwise it would crash when a file has been deleted without having the change commited yet. Link: https://lists.sr.ht/~postmarketos/pmbootstrap-devel/%3C20221031111614.1377-1-ollieparanoid@postmarketos.org%3E
This commit is contained in:
parent
397225667f
commit
f8d186e776
2 changed files with 27 additions and 3 deletions
|
@ -253,3 +253,22 @@ def get_topdir(args, path):
|
|||
empty string if it's not a git repository. """
|
||||
return pmb.helpers.run.user(args, ["git", "rev-parse", "--show-toplevel"],
|
||||
path, output_return=True, check=False).rstrip()
|
||||
|
||||
|
||||
def get_files(args, path):
|
||||
""" Get all files inside a git repository, that are either already in the
|
||||
git tree or are not in gitignore. Do not list deleted files. To be used
|
||||
for creating a tarball of the git repository.
|
||||
:param path: top dir of the git repository
|
||||
:returns: all files in a git repository as list, relative to path """
|
||||
ret = []
|
||||
files = pmb.helpers.run.user(args, ["git", "ls-files"], path,
|
||||
output_return=True).split("\n")
|
||||
files += pmb.helpers.run.user(args, ["git", "ls-files",
|
||||
"--exclude-standard", "--other"], path,
|
||||
output_return=True).split("\n")
|
||||
for file in files:
|
||||
if os.path.exists(f"{path}/{file}"):
|
||||
ret += [file]
|
||||
|
||||
return ret
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue