From 1556101a983f4c56430b93978c074a89744db876 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 19 Nov 2019 15:10:36 +0000 Subject: [PATCH] java based merging? --- .gitattributes | 1 + .gitconfig | 3 +++ build.gradle.kts | 12 ++++++------ gradle.properties | 4 ++-- merge-imports.sh | 3 +++ merge/Merge.class | Bin 0 -> 1312 bytes merge/Merge.java | 36 ++++++++++++++++++++++++++++++++++++ 7 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 .gitconfig create mode 100644 merge-imports.sh create mode 100644 merge/Merge.class create mode 100644 merge/Merge.java diff --git a/.gitattributes b/.gitattributes index 36b113264..4af28b5a7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ *.java diff=java +#*.java merge=import-driver #TODO not implemented, I'm just using a merge tool instead \ No newline at end of file diff --git a/.gitconfig b/.gitconfig new file mode 100644 index 000000000..6057a39c2 --- /dev/null +++ b/.gitconfig @@ -0,0 +1,3 @@ +[merge "import-driver"] + name = Java merge driver used to resolve conflicts + driver = merge-imports.sh %O %A %B %L %P \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index ad2600d24..a208e540e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -85,9 +85,9 @@ if (!project.hasProperty("gitCommitHash")) { } } -buildScan { - setTermsOfServiceUrl("https://gradle.com/terms-of-service") - setTermsOfServiceAgree("yes") - - publishAlways() -} +//buildScan { +// setTermsOfServiceUrl("https://gradle.com/terms-of-service") +// setTermsOfServiceAgree("yes") +// +// publishAlways() +//} diff --git a/gradle.properties b/gradle.properties index 35ae55661..911076493 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=com.sk89q.worldedit #version=7.1.0-SNAPSHOT -org.gradle.jvmargs=-Xmx1G -#org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 +#org.gradle.jvmargs=-Xmx1G +org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 org.gradle.daemon=true org.gradle.configureondemand=true org.gradle.parallel=true diff --git a/merge-imports.sh b/merge-imports.sh new file mode 100644 index 000000000..9d9e9725d --- /dev/null +++ b/merge-imports.sh @@ -0,0 +1,3 @@ +javac merge/Merge.java +java -cp merge Merge "$1" "$2" "$3" "$4" "$5" +exit $? \ No newline at end of file diff --git a/merge/Merge.class b/merge/Merge.class new file mode 100644 index 0000000000000000000000000000000000000000..781b5219fcf6e6950d03bce1e78ce7de233c10b3 GIT binary patch literal 1312 zcmaJ=%TgOh6g`b*)M6O%kSv0dVB{ATdVr(YBoPDxwz091a9NbAu&byVqy`VsD|*Dv z4`i8TmdTQ}voKVsvUe=(2%$2|*CT#*>J z(1WWMB1l@8K&qD}9YV%J7Ly@NNnDfo%0eG<7A$VNK9K8#5WS(N_-~}oOSDN zXHFoHoOmQ)+-y{oz`%-ISH*5^Q?=Hd%_=iS&2j4j!^tNrJI>F}RMn|(Pn9|?x4u22 z4_ddMmsPXlHtKDOynxx{R!3kc>EqqT)RJ3O9yVO+IOQJ;PSdOHah;Z!VOy+IYIIv= zrLhbOsXhZrQkvB^!4%si+6^6j^)PYCO}5*|>{k%HVY% zFn9`C-P}=SD&wDGE6b}V+WiaYt1A#YmhiulpQ%~;rQK0APDwp?S=vZ0>zM=^T?Vm} z0X)znVO8bSX3pGyCM_Vnxm7vp=;`GA=Dpd4c)Frrhrqey#Q)y{TP{}{ZElC1N~P3o zHe0IQRuzGfvu&K{#G<&scO2#W1_EGN#At^ZjdJBMVW##VUeFQvj5g>cd(n###Q7a) z=rb4`Ixv5Lp7m59w}-%r=Nj5Ac&@44Vk(%+8!4H~n>racnac+=`!I}sn5UPFvpo3y z^ugu@VRG!pI0lgB$1{x~+HB~BF=xa1ML{2m|m1hD`B literal 0 HcmV?d00001 diff --git a/merge/Merge.java b/merge/Merge.java new file mode 100644 index 000000000..a1be81689 --- /dev/null +++ b/merge/Merge.java @@ -0,0 +1,36 @@ +import java.awt.Desktop; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class Merge { + public static void main(String[] args) throws IOException { + File ancestor = new File(args[0]); + File current = new File(args[1]); + File other = new File(args[2]); + int markerLenth = Integer.parseInt(args[3]); + File original = new File(args[4]); + + // HOWTO: + // 1. Add contents of .gitconfig to your local .git/config + // 2. This script will run for any merge conflicts + + // TODO auto resolve merge conflicts in `current` + // - imports + + boolean failed = true; + if (failed) { + System.exit(1); // Auto merge failed + } + } + + private static String read(File file) throws IOException { + byte[] encoded = Files.readAllBytes(file.toPath()); + return new String(encoded, StandardCharsets.UTF_8); + } +}