Skip to content

Commit

Permalink
chunk out lfs unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercoms committed Sep 3, 2024
1 parent dceb4f1 commit 9dedca1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pbpy/pbgit.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ def fix_lfs_ro_attr(should_unlock_unmodified):
pblog.warning(message)


def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i : i + n]


def unlock_unmodified():
modified = get_modified_files(paths=False)
pending = pbtools.get_combined_output(
Expand Down Expand Up @@ -239,9 +244,13 @@ def unlock_unmodified():
unlock = list(unlock)
if not unlock:
return True
args = [get_lfs_executable(), "unlock"]
args.extend(unlock)
return pbtools.run(args).returncode == 0
for chunk in chunks(unlock, 50):
args = [get_lfs_executable(), "unlock"]
args.extend(chunk)
proc = pbtools.run(args)
if proc.returncode:
return False
return True


@lru_cache()
Expand Down

0 comments on commit 9dedca1

Please sign in to comment.