Last active
August 29, 2022 10:03
-
-
Save 0bmxa/6ea1e545bce373af1bfa4230009940c4 to your computer and use it in GitHub Desktop.
git diff: YAML based Xcode project diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
############################################################# | |
# Requires the xcodeproj tool: # | |
# https://github.com/CocoaPods/Xcodeproj # | |
# # | |
# Note: # | |
# As this only shows a representation of the project and # | |
# not the project file directly, this is only suitable # | |
# for diffs, not for merges. # | |
# # | |
# Also note: # | |
# In contrast to using "opendiff" as a difftool directly, # | |
# this does not wait for FileMerge to exit. # | |
# # | |
############################################################# | |
LOCAL="$1" | |
REMOTE="$2" | |
TEMP_WORKDIR="/tmp/git_diff_xcodeproj" | |
# Check file extension | |
REMOTE_FILE_NAME=$(basename "$REMOTE") | |
REMOTE_FILE_EXTENSION="${REMOTE_FILE_NAME##*.}" | |
if [[ "$REMOTE_FILE_EXTENSION" == "pbxproj" ]]; | |
then | |
# If extension is "xcodeproj", create the YAML representation | |
# using the xcodeproj tool | |
mkdir -p "$TEMP_WORKDIR/LOCAL.xcodeproj" | |
cp "$LOCAL" "$TEMP_WORKDIR/LOCAL.xcodeproj/project.pbxproj" | |
xcodeproj show "$TEMP_WORKDIR/LOCAL.xcodeproj" > "$TEMP_WORKDIR/local.yaml" | |
xcodeproj show $(dirname "$REMOTE") > "$TEMP_WORKDIR/remote.yaml" | |
opendiff "$TEMP_WORKDIR/local.yaml" "$TEMP_WORKDIR/remote.yaml" | |
rm -rf "$TEMP_WORKDIR" | |
else | |
# Otherwise open your normal difftool. | |
opendiff "$LOCAL" "$REMOTE" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[diff] | |
tool = opendiff_xcodeproj | |
[difftool "opendiff_xcodeproj"] | |
cmd = "/path/to/opendiff_xcodeproj.sh $LOCAL $REMOTE" | |
[difftool] | |
prompt = false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment