mirror of
https://hub.spigotmc.org/stash/scm/spigot/buildtools.git
synced 2025-11-01 09:09:13 +00:00
Support patches without a prelude.
This commit is contained in:
parent
7954aca0ff
commit
9d9ebf6ce5
1 changed files with 18 additions and 1 deletions
|
|
@ -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 ) );
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue