This commit is contained in:
Franjo Mindek 2025-05-12 13:25:19 +02:00
parent 48cfd62666
commit 0b3e37909b
2 changed files with 14 additions and 13 deletions

View File

@ -26,18 +26,6 @@ If you're running the `patch.sh` or `diff.sh` scripts on Mac, you need to instal
- `gpatch`, - `gpatch`,
- and `diffutils`. - and `diffutils`.
You should also create aliases for `realpath` and `patch`:
```sh
brew install coreutils # contains grealpath
brew install gpatch
brew install diffutils
echo 'alias realpath="grealpath"' >> ~/.zshrc
echo 'alias patch="gpatch"' >> ~/.zshrc
source ~/.zshrc
```
Make sure not to commit `app/` to git. It is currently (until we resolve this) not added to .gitignore because that messes up diffing for us. Make sure not to commit `app/` to git. It is currently (until we resolve this) not added to .gitignore because that messes up diffing for us.
### Blog (blog/) ### Blog (blog/)

View File

@ -5,6 +5,19 @@
# Allows you to easily create a diff between the two projects (base and derived), or to patch those diffs onto the base project to get the derived one. # Allows you to easily create a diff between the two projects (base and derived), or to patch those diffs onto the base project to get the derived one.
# Useful when derived project has only small changes on top of base project and you want to keep it in a dir in the same repo as main project. # Useful when derived project has only small changes on top of base project and you want to keep it in a dir in the same repo as main project.
# Determine the patch command to use based on OS
PATCH_CMD="patch"
if [[ "$(uname)" == "Darwin" ]]; then
# On macOS, require gpatch to be installed
if command -v gpatch &> /dev/null; then
PATCH_CMD="gpatch"
else
echo "Error: GNU patch (gpatch) not found. On MacOS, this script requires GNU patch."
echo "Install it with: brew install gpatch"
exit 1
fi
fi
# List all the source files in the specified dir. # List all the source files in the specified dir.
# "Source" files are any files that are not gitignored. # "Source" files are any files that are not gitignored.
list_source_files() { list_source_files() {
@ -92,7 +105,7 @@ recreate_derived_dir() {
local patch_output local patch_output
local patch_exit_code local patch_exit_code
patch_output=$(patch --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}") patch_output=$("${PATCH_CMD}" --no-backup-if-mismatch --merge "${DERIVED_DIR}/${derived_filepath}" < "${diff_filepath}")
patch_exit_code=$? patch_exit_code=$?
if [ ${patch_exit_code} -eq 0 ]; then if [ ${patch_exit_code} -eq 0 ]; then
echo "${patch_output}" echo "${patch_output}"