Skip to content

Instantly share code, notes, and snippets.

@tofi86
Created February 13, 2019 22:24
Show Gist options
  • Save tofi86/a8e61a7611ef9e43c592fda83823c62e to your computer and use it in GitHub Desktop.
Save tofi86/a8e61a7611ef9e43c592fda83823c62e to your computer and use it in GitHub Desktop.
oXygen XML Editor Diff for Git Tower

oXygen XML Editor Diff for Git Tower

These scripts add oXygen XML Editor "Diff Files" to the list of Diff & Merge Tools in Git Tower.

Place the files in the following folder:

~/Library/Application Support/com.fournova.Tower3/CompareTools/

Make the shell script executable:

chmod +x oxygen20diff.sh

Restart Git Tower.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>ApplicationIdentifier</key>
<string>ro.sync.exml.DiffFiles</string>
<key>ApplicationName</key>
<string>Diff Files</string>
<key>DisplayName</key>
<string>oXygen 20 Diff Files</string>
<key>LaunchScript</key>
<string>oxygen20diff.sh</string>
<key>Identifier</key>
<string>oxygen20</string>
<key>SupportsMergeTool</key>
<true/>
<key>SupportsDiffChangeset</key>
<true/>
</dict>
</array>
</plist>
#!/bin/sh
LOCAL="$1"
REMOTE="$2"
# Sanitize LOCAL path
if [[ ! "$LOCAL" =~ ^/ ]]; then
LOCAL=$(echo "$LOCAL" | sed -e 's/^\.\///')
LOCAL="$PWD/$LOCAL"
fi
# Sanitize REMOTE path
if [[ ! "$REMOTE" =~ ^/ ]]; then
REMOTE=$(echo "$REMOTE" | sed -e 's/^\.\///')
REMOTE="$PWD/$REMOTE"
fi
MERGING="$4"
BACKUP="/tmp/$(date +"%Y%d%m%H%M%S")"
CMD="/Applications/oxygen-20/diffFiles.sh"
if [ -n "$MERGING" ]; then
BASE="$3"
MERGE="$4"
# Sanitize BASE path
if [[ ! "$BASE" =~ ^/ ]]; then
BASE=$(echo "$BASE" | sed -e 's/^\.\///')
BASE="$PWD/$BASE"
if [ ! -f "$BASE" ]; then
BASE=/dev/null
fi
fi
# Sanitize MERGE path
if [[ ! "$MERGE" =~ ^/ ]]; then
MERGE=$(echo "$MERGE" | sed -e 's/^\.\///')
MERGE="$PWD/$MERGE"
if [ ! -f "$MERGE" ]; then
# For conflict "Both Added", Git does not pass the merge param correctly in current versions
MERGE=$(echo "$LOCAL" | sed -e 's/\.LOCAL\.[0-9]*//')
fi
fi
sleep 1 # required to create different modification timestamp
touch "$BACKUP"
"$CMD" -ext "$LOCAL" "$REMOTE" "$BASE" "$MERGE"
else
MERGE="$3"
if [ -n "$MERGE" ]; then
"$CMD" -ext "$REMOTE" "$LOCAL" "$LOCAL"
else
"$CMD" -ext "$REMOTE" "$LOCAL"
fi
fi
if [ -n "$MERGING" ]; then
# Check if the merged file has changed
if [ "$MERGE" -ot "$BACKUP" ]; then
exit 1
fi
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment