Commits

Thinkofname authored 65e9b035509
Fix a few issues
No tags

src/main/java/org/spigotmc/builder/Builder.java

Modified
55 55 import org.apache.commons.io.output.TeeOutputStream;
56 56 import org.eclipse.jgit.api.AddCommand;
57 57 import org.eclipse.jgit.api.FetchCommand;
58 58 import org.eclipse.jgit.api.Git;
59 59 import org.eclipse.jgit.api.ResetCommand;
60 60 import org.eclipse.jgit.api.errors.GitAPIException;
61 61 import org.eclipse.jgit.lib.CoreConfig;
62 62 import org.eclipse.jgit.lib.Repository;
63 63 import org.eclipse.jgit.lib.StoredConfig;
64 64 import org.eclipse.jgit.revwalk.RevCommit;
65 +import org.eclipse.jgit.transport.FetchResult;
65 66 import org.eclipse.jgit.transport.RefSpec;
66 67 import org.eclipse.jgit.transport.RemoteConfig;
67 68 import org.eclipse.jgit.transport.TagOpt;
68 69 import org.eclipse.jgit.transport.URIish;
69 70
70 71 public class Builder
71 72 {
72 73
73 74 public static final String LOG_FILE = "BuildTools.log.txt";
74 75 public static final boolean IS_WINDOWS = System.getProperty( "os.name" ).startsWith( "Windows" );
402 403 System.out.println( "Success! Everything compiled successfully. Copying final .jar files now." );
403 404 copyJar( "CraftBukkit/target", "craftbukkit", "craftbukkit-" + versionInfo.getMinecraftVersion() + ".jar" );
404 405 copyJar( "Spigot/Spigot-Server/target", "spigot", "spigot-" + versionInfo.getMinecraftVersion() + ".jar" );
405 406 }
406 407
407 408 public static void applyPatches(File base, File orig, File target, File patches, String branch) throws Exception
408 409 {
409 410 System.out.println( "Applying patches to " + target );
410 411 Git gitOrig = Git.open( orig );
411 412
412 - gitOrig.fetch()
413 - .setRemote( "file://" + base.getAbsolutePath() )
413 + FetchResult fr = gitOrig.fetch()
414 + .setRemote( base.toURI().toString() )
414 415 .setRefSpecs( new RefSpec( "refs/heads/*:refs/remotes/origin/*" ) )
415 416 .call();
416 417 gitOrig.reset()
417 - .setRef( "origin/" + branch )
418 + .setRef( fr.getAdvertisedRef( "refs/heads/" + branch ).getObjectId().getName() )
418 419 .setMode( ResetCommand.ResetType.HARD )
419 420 .call();
420 421 gitOrig.branchCreate()
421 422 .setName( "upstream" )
422 423 .setForce( true )
423 424 .call();
424 425
425 426 clone( orig.toURI().toString(), target );
426 427 Git git = Git.open( target );
427 428
428 429 StoredConfig config = git.getRepository().getConfig();
429 430 config.setString( "remote", "upstream", "url", "file://" + orig.getAbsolutePath() );
430 431 config.save();
431 432
432 433 git.branchCreate()
433 434 .setName( "master" )
434 435 .setForce( true )
435 436 .call();
436 437 git.checkout()
437 438 .setName( "master" )
438 439 .call();
439 - git.fetch()
440 - .setRemote( "upstream" )
441 - .setRefSpecs( new RefSpec( "refs/heads/*:refs/remotes/upstream/*" ) )
442 - .call();
443 440 git.reset()
444 - .setRef( "refs/remotes/upstream/upstream" )
441 + .setRef( "origin/upstream" )
445 442 .setMode( ResetCommand.ResetType.HARD )
446 443 .call();
447 444 git.clean().setCleanDirectories( true ).call();
448 445
449 446 File[] ps = patches.listFiles();
450 447 Arrays.sort( ps );
451 448 for ( File patch : ps )
452 449 {
453 450 if ( !patch.getName().endsWith( ".patch" ) ) continue;
454 451 System.out.println( "Applying " + patch.getName() );
514 511
515 512 public static void pull(Git repo, String ref) throws Exception
516 513 {
517 514 System.out.println( "Pulling updates for " + repo.getRepository().getDirectory() );
518 515
519 516 repo.reset().setRef( "origin/master" ).setMode( ResetCommand.ResetType.HARD ).call();
520 517 repo.fetch().call();
521 518
522 519 System.out.println( "Successfully fetched updates!" );
523 520
524 - repo.reset().setRef( ref ).setMode( ResetCommand.ResetType.HARD ).call();
525 - if ( ref.equals( "master" ) )
526 - {
527 - repo.reset().setRef( "origin/master" ).setMode( ResetCommand.ResetType.HARD ).call();
528 - }
521 + if ( ref.equals( "master" ) ) ref = "origin/master";
522 +
523 +
524 + repo.branchCreate()
525 + .setForce( true )
526 + .setStartPoint( ref )
527 + .setName( "master" )
528 + .call();
529 +
530 + repo.checkout()
531 + .setForce( true )
532 + .setStartPoint( ref )
533 + .setName( "master" )
534 + .call();
529 535 System.out.println( "Checked out: " + ref );
530 536 }
531 537
532 538 public static int maven(File workDir, String... command) throws Exception
533 539 {
534 540 File maven = new File( "apache-maven-3.2.3" );
535 541 if ( !maven.exists() )
536 542 {
537 543 System.out.println( "Maven does not exist, downloading. Please wait." );
538 544

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut