1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2024-12-19 20:12:52 +02:00
nerd-fonts/bin/scripts/update-gitignore.sh
Fini Jastrow 090fbbeebe Sunset in-repo releases
[why]
We struggle with the pack-committing of patched fonts to the repository
on release. This makes our repo grow extremely big. It would be better
to just use release artifacts for the releases and not commit any
patched font back.
There were different approaches discussed, but the problem remains that
I personally have no rights to implement anything of that - neither can
I force push to the default branch, nor can I create new repos in the
organization.

[how]
To make it still possible to add new fonts without a repo size
explosion we do not release NEW fonts back to the repository as commits,
but old fonts are handled as before.
NEW fonts:
 * have a new property set in the fonts.yaml 'database'
 * are released as release artifact via release workflow (but not
   committed back)
 * get a readme in the patched_fonts/ directory that points to the
   release artifact page

The solution is not ideal, but for sure better than not adding any fonts
anymore or having the repo grow in size faster and faster.

At some point in time I would like to phase out all in-repo releases,
also for OLD fonts.

This scheme has been (manually) used / introduced for Intel One.
With this change the .gitignore file is automatically adapted to any new
font that is added with the repoRelease flag set to false (which should
be the default for any added font from now on).

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
2023-09-27 11:20:36 +02:00

62 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Nerd Fonts Version: 3.0.2
# Script Version: 1.0.0
#
# Edits the repo's .gitignore to prevent patched font artifacts
# to be included, if that font is set to be not repo-released.
# to be included, if that font is set to be not repo-released.
#
# Example run
# update-gitignore.sh
# set -x
set -e
# Get script directory to set source and target dirs relative to it
sd="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 || exit ; pwd -P )"
repo_root_dir=$(dirname "$(dirname "${sd}")") # two levels up (i.e. ../../)
gitignore=${repo_root_dir}/.gitignore
gitignore_tmp=${gitignore}~
delimiter="# AUTOGENERATED"
num_comments=$(grep -c "^${delimiter}" "${gitignore}")
if [ "${num_comments}" -ne 2 ]; then
echo "Fatal: Unexpected number of delimiting lines in gitignore file"
exit 1
fi
if [ -f "${gitignore_tmp}" ]; then
echo "Fatal: Temporary file ${gitignore_tmp} already exists"
exit 1
fi
while IFS=$'\n' read -r line; do
if [[ "${line}" =~ ^"${delimiter}" ]]; then
if [ -z "${remove}" ]; then
remove=1
else
unset remove
fi
continue
fi
if [ -z "${remove}" ]; then
printf '%s\n' "$line" >> "${gitignore_tmp}"
fi
done < "$gitignore"
i=0
{
echo "${delimiter} lines follow, do not change or remove the comments"
echo "# Non-Repo-Released fonts, see fonts.json:"
while IFS=$'\n' read -r dir; do
echo "patched-fonts/${dir// /\\ }/*"
echo "!patched-fonts/${dir// /\\ }/README.md"
i=$((i + 1))
done < <(jq -r '.fonts[] | select(.repoRelease == false) | .folderName' lib/fonts.json)
echo "${delimiter} lines end"
} >> "${gitignore_tmp}"
echo "Created entries for ${i} fonts in ${gitignore_tmp}"
mv -v -- "${gitignore_tmp}" "${gitignore}"