patch-em-all: Purge destination dirs if possible #787
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[why]
When the file names of the source files change which happened for example
with these commits:
or the patched font files naming changes because of any other reason (*):
The patched-font directory will contain the new files along with the
unchanged old ones (because they where not overwritten).
Typically when manually updating the patched-fonts this is not a
problem, as the maintainer can clean this up by hand (if it is noticed).
But with a github action we might want to have that automatized.
To not deter the usability of the script for end-users or for patching
single fonts of a collection we do NOT want to purge 'all old files'
because we can not know if they are really old or not.
[how]
For each directory that we process from the source fonts we check if all
font files therein match our search criterion (pattern, $2). If we are
going to patch all files that are in that source directory we delete all
font files in the destination directory; expecting that all files will
be recreated.
If we do not patch all files, we can do nothing, because we can not
decide if the existing files originate from one of the
not-to-be-processed source font files or are zombies.
Fixes: #786
(*) For example when the font naming changes because
Nerd Fontmoves forward before the style in the font nameName-Weight.ttfRequirements / Checklist
What does this Pull Request (PR) do?
Remove font files from
patched-fontsthat are not created on the most recent complete patch run.How should this be manually tested?
Inconsolata has some orphan font files, run the patched
patch-em-alland see those vanish.Any background context you can provide?
What are the relevant tickets (if any)?
#786
Screenshots (if appropriate or helpful)