summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2014-12-24 09:32:10 +1100
committermd_5 <git@md-5.net>2014-12-24 09:32:10 +1100
commit9d9ebf6ce537e2dd60411701ce7344c9d8ad2643 (patch)
tree857b809b6f33e9a129610bc7e5280bee05fe80de /src/main/java/org
parent7954aca0ff43647dbe0825fe4eb562bcfdef44db (diff)
downloadbuildtools-9d9ebf6ce537e2dd60411701ce7344c9d8ad2643.tar
buildtools-9d9ebf6ce537e2dd60411701ce7344c9d8ad2643.tar.gz
buildtools-9d9ebf6ce537e2dd60411701ce7344c9d8ad2643.tar.lz
buildtools-9d9ebf6ce537e2dd60411701ce7344c9d8ad2643.tar.xz
buildtools-9d9ebf6ce537e2dd60411701ce7344c9d8ad2643.zip
Support patches without a prelude.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/spigotmc/builder/Builder.java19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main/java/org/spigotmc/builder/Builder.java b/src/main/java/org/spigotmc/builder/Builder.java
index 2cbe573..cc0b8b7 100644
--- a/src/main/java/org/spigotmc/builder/Builder.java
+++ b/src/main/java/org/spigotmc/builder/Builder.java
@@ -246,7 +246,24 @@ public class Builder
System.out.println( "Patching with " + file.getName() );
- Patch parsedPatch = DiffUtils.parseUnifiedDiff( Files.readLines( file, Charsets.UTF_8 ) );
+ List<String> readFile = Files.readLines( file, Charsets.UTF_8 );
+
+ // Manually append prelude if it is not found in the first few lines.
+ boolean preludeFound = false;
+ for ( int i = 0; i < Math.min( 3, readFile.size() ); i++ )
+ {
+ if ( readFile.get( i ).startsWith( "+++" ) )
+ {
+ preludeFound = true;
+ break;
+ }
+ }
+ if ( !preludeFound )
+ {
+ readFile.add( 0, "+++" );
+ }
+
+ Patch parsedPatch = DiffUtils.parseUnifiedDiff( readFile );
List<?> modifiedLines = DiffUtils.patch( Files.readLines( clean, Charsets.UTF_8 ), parsedPatch );
BufferedWriter bw = new BufferedWriter( new FileWriter( t ) );