nerd-fonts icon indicating copy to clipboard operation
nerd-fonts copied to clipboard

patch-em-all: Purge destination dirs if possible

Open Finii opened this issue 3 years ago • 2 comments

[why] When the file names of the source files change which happened for example with these commits:

  ac432eb20 Updated Inconsolata source to latest upstream version of 2.001 (WIP #289)
  9c5ad2c78 Updated Inconsolata source to latest upstream version of 2.001 (WIP #289)

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

  • The FontnameParser is used where Nerd Font moves forward before the style in the font name
  • We will finally create font files without blanks in them, but conventional Name-Weight.ttf

Requirements / Checklist

What does this Pull Request (PR) do?

Remove font files from patched-fonts that 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-all and see those vanish.

Any background context you can provide?

What are the relevant tickets (if any)?

#786

Screenshots (if appropriate or helpful)

Finii avatar Feb 16 '22 09:02 Finii

What I did not check is if the https://github.com/EndBug/add-and-commit action works like ordinary (command line) git add.

On the command line, adding a directory marks all missing files in that directory as deleted on the stage and in the later commit. The action allows also remove: so I'm not sure they changed that behavior (I believe: no, they just call git add and git rm without any special logic added).

Finii avatar Feb 16 '22 09:02 Finii

Here is an instance where the present behavior (keeping old files laying around after renaming etc) results in an Issue... https://github.com/termux/termux-styling/pull/77

This seems to have gone unnoticed here as because the old Fura* files remain (unupdated) in the Nerd Fonts repo (by mistake, I presume), the download script didn't break

Finii avatar Jun 08 '22 05:06 Finii