patching: if 0 files left to commit after config-filtering, don't commit nor rewrite the patches

- this is mostly useful for Makefile's and DT patches which should end be bare instead of null-patched
This commit is contained in:
Ricardo Pardini 2023-10-22 17:50:55 +02:00
parent 4232299a3b
commit 6186a41c2b
2 changed files with 10 additions and 2 deletions

View File

@ -512,6 +512,10 @@ class PatchInPatchFile:
final_files_to_add = [f for f in all_files_to_add if f not in do_not_commit_files]
final_files_to_add = [f for f in final_files_to_add if not any(re.match(r, f) for r in do_not_commit_regexes)]
log.debug(f"Adding (post-config) {len(final_files_to_add)} files to git: {' '.join(final_files_to_add)}")
if len(final_files_to_add) == 0:
log.warning(f"There are 0 files to commit post-config. The whole patch should be removed.")
self.problems.append("no_files_to_commit_after_config")
return None
repo.git.add("-f", final_files_to_add)
if self.failed_to_parse or self.parent.patch_dir.is_autogen_dir or add_all_changes_in_git:

View File

@ -320,7 +320,7 @@ if apply_patches:
if one_patch.applied_ok and apply_patches_to_git:
committed = one_patch.commit_changes_to_git(git_repo, (not rewrite_patches_in_place), split_patches, pconfig)
if not split_patches:
if not split_patches and (committed is not None):
commit_hash = committed['commit_hash']
one_patch.git_commit_hash = commit_hash
@ -354,6 +354,10 @@ if apply_patches:
log.warning(f"Skipping patch {one_patch} from rewrite because it was not applied successfully.")
continue
if one_patch.rewritten_patch is None:
log.warning(f"Skipping patch {one_patch} from rewrite because it was not rewritten.")
continue
if one_patch.parent not in patch_files_by_parent:
patch_files_by_parent[one_patch.parent] = []
patch_files_by_parent[one_patch.parent].append(one_patch)
@ -361,7 +365,7 @@ if apply_patches:
for parent in patch_files_by_parent:
patches = patch_files_by_parent[parent]
parent.rewrite_patch_file(patches)
UNAPPLIED_PATCHES = [one_patch for one_patch in VALID_PATCHES if not one_patch.applied_ok]
UNAPPLIED_PATCHES = [one_patch for one_patch in VALID_PATCHES if (not one_patch.applied_ok) or (one_patch.rewritten_patch is None)]
for failed_patch in UNAPPLIED_PATCHES:
log.info(
f"Consider removing {failed_patch.parent.full_file_path()}(:{failed_patch.counter}); "