Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions CompareTools.plist
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,37 @@
<key>SupportsDiffChangeset</key>
<true/>
</dict>
<dict>
<key>ApplicationIdentifier</key>
<string>com.microsoft.VSCodeInsiders</string>
<key>ApplicationName</key>
<string>Visual Studio Code Insiders</string>
<key>DisplayName</key>
<string>Visual Studio Code Insiders</string>
<key>LaunchScript</key>
<string>vscode-insiders.sh</string>
<key>Identifier</key>
<string>code-insiders</string>
<key>SupportsMergeTool</key>
<true/>
<key>SupportsDiffChangeset</key>
<true/>
</dict>
<dict>
<key>ApplicationIdentifier</key>
<string>com.visualstudio.code.oss</string>
<key>ApplicationName</key>
<string>VSCodium</string>
<key>DisplayName</key>
<string>VSCodium</string>
<key>LaunchScript</key>
<string>vscodium.sh</string>
<key>Identifier</key>
<string>codium</string>
<key>SupportsMergeTool</key>
<true/>
<key>SupportsDiffChangeset</key>
<true/>
</dict>
</array>
</plist>
63 changes: 63 additions & 0 deletions vscode-insiders.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/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=$(which code-insiders)

if [ ! $CMD ] >/dev/null; then
if [ -e '/usr/local/bin/code-insiders' ]; then
CMD='/usr/local/bin/code-insiders'
fi
fi

if [ ! -x "$CMD" ]; then
echo "Visual Studio Code command line tool 'code-insiders' could not be found. Please make sure it has been installed in /usr/local/bin/." >&2
exit 128
fi

if [ -n "$MERGING" ]; then
MERGE="$4"

# 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" --wait "$MERGE"
else
"$CMD" --wait --diff "$LOCAL" "$REMOTE"
fi

if [ -n "$MERGING" ]; then
# Check if the merged file has changed
if [ "$MERGE" -ot "$BACKUP" ]; then
exit 1
fi
fi

exit 0
63 changes: 63 additions & 0 deletions vscodium.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/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=$(which codium)

if [ ! $CMD ] >/dev/null; then
if [ -e '/usr/local/bin/codium' ]; then
CMD='/usr/local/bin/codium'
fi
fi

if [ ! -x "$CMD" ]; then
echo "Visual Studio Code command line tool 'codium' could not be found. Please make sure it has been installed in /usr/local/bin/." >&2
exit 128
fi

if [ -n "$MERGING" ]; then
MERGE="$4"

# 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" --wait "$MERGE"
else
"$CMD" --wait --diff "$LOCAL" "$REMOTE"
fi

if [ -n "$MERGING" ]; then
# Check if the merged file has changed
if [ "$MERGE" -ot "$BACKUP" ]; then
exit 1
fi
fi

exit 0