From 7cd4ce1d00f8b22329f2dfdd5ca5f952b20f0b93 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Mon, 15 Mar 2021 13:21:16 +0100 Subject: [PATCH 1/4] feat: add insiders support --- CompareTools.plist | 16 ++++++++++++ vscode-insiders.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100755 vscode-insiders.sh diff --git a/CompareTools.plist b/CompareTools.plist index 3fa67dd..0829192 100644 --- a/CompareTools.plist +++ b/CompareTools.plist @@ -18,5 +18,21 @@ SupportsDiffChangeset + + ApplicationIdentifier + com.microsoft.VSCodeInsiders + ApplicationName + Visual Studio Code Insiders + DisplayName + Visual Studio Code Insiders + LaunchScript + vscode-insiders.sh + Identifier + code-insiders + SupportsMergeTool + + SupportsDiffChangeset + + diff --git a/vscode-insiders.sh b/vscode-insiders.sh new file mode 100755 index 0000000..558d0c1 --- /dev/null +++ b/vscode-insiders.sh @@ -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' 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 From 60887e704ef25288ec7e7730ef8ace6c6b9ae0e9 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Mon, 15 Mar 2021 13:23:53 +0100 Subject: [PATCH 2/4] feat: codium support --- CompareTools.plist | 16 ++++++++++++ vscode-insiders.sh | 2 +- vscodium.sh | 63 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100755 vscodium.sh diff --git a/CompareTools.plist b/CompareTools.plist index 0829192..3ceabdf 100644 --- a/CompareTools.plist +++ b/CompareTools.plist @@ -34,5 +34,21 @@ SupportsDiffChangeset + + ApplicationIdentifier + com.visualstudio.code.oss + ApplicationName + Visual Studio Code Insiders + DisplayName + VSCodium + LaunchScript + vscodium.sh + Identifier + code-insiders + SupportsMergeTool + + SupportsDiffChangeset + + diff --git a/vscode-insiders.sh b/vscode-insiders.sh index 558d0c1..9d7207a 100755 --- a/vscode-insiders.sh +++ b/vscode-insiders.sh @@ -27,7 +27,7 @@ if [ ! $CMD ] >/dev/null; then fi if [ ! -x "$CMD" ]; then - echo "Visual Studio Code command line tool 'code' could not be found. Please make sure it has been installed in /usr/local/bin/." >&2 + 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 diff --git a/vscodium.sh b/vscodium.sh new file mode 100755 index 0000000..1e681a7 --- /dev/null +++ b/vscodium.sh @@ -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 From c062d2ef60b4aa96d9bf7081625bce246038292a Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Mon, 15 Mar 2021 13:25:31 +0100 Subject: [PATCH 3/4] fix: name fix --- CompareTools.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CompareTools.plist b/CompareTools.plist index 3ceabdf..1861ae3 100644 --- a/CompareTools.plist +++ b/CompareTools.plist @@ -38,7 +38,7 @@ ApplicationIdentifier com.visualstudio.code.oss ApplicationName - Visual Studio Code Insiders + VSCodium DisplayName VSCodium LaunchScript From 7bece022416da7247fd3a761ba957bb43bf470c1 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Mon, 15 Mar 2021 13:26:13 +0100 Subject: [PATCH 4/4] fix: codium fix --- CompareTools.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CompareTools.plist b/CompareTools.plist index 1861ae3..f520d2f 100644 --- a/CompareTools.plist +++ b/CompareTools.plist @@ -44,7 +44,7 @@ LaunchScript vscodium.sh Identifier - code-insiders + codium SupportsMergeTool SupportsDiffChangeset