Commits

md_5 authored 190add07527
Set a sane autocrlf value on fresh clones.
No tags

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

Modified
51 51 import javax.swing.JLabel;
52 52 import joptsimple.OptionParser;
53 53 import joptsimple.OptionSet;
54 54 import joptsimple.OptionSpec;
55 55 import lombok.RequiredArgsConstructor;
56 56 import org.apache.commons.io.FileUtils;
57 57 import org.apache.commons.io.output.TeeOutputStream;
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 +import org.eclipse.jgit.lib.StoredConfig;
61 62 import org.eclipse.jgit.revwalk.RevCommit;
62 63
63 64 public class Builder
64 65 {
65 66
66 67 public static final String LOG_FILE = "BuildTools.log.txt";
67 68 public static final boolean IS_WINDOWS = System.getProperty( "os.name" ).startsWith( "Windows" );
68 69 public static final File CWD = new File( "." );
70 + private static final boolean autocrlf = !"\n".equals( System.getProperty( "line.separator" ) );
69 71 private static boolean dontUpdate;
70 72 private static boolean skipCompile;
71 73 private static boolean generateSource;
72 74 private static boolean generateDocs;
73 75 private static boolean dev;
74 76
75 77 public static void main(String[] args) throws Exception
76 78 {
77 79 if ( System.console() == null )
78 80 {
603 605 } finally
604 606 {
605 607 is.close();
606 608 os.close();
607 609 }
608 610
609 611 System.out.println( "Extracted: " + outFile );
610 612 }
611 613 }
612 614
613 - public static void clone(String url, File target) throws GitAPIException
615 + public static void clone(String url, File target) throws GitAPIException, IOException
614 616 {
615 617 System.out.println( "Starting clone of " + url + " to " + target );
616 618
617 619 Git result = Git.cloneRepository().setURI( url ).setDirectory( target ).call();
618 620
619 621 try
620 622 {
621 - System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) );
623 + StoredConfig config = result.getRepository().getConfig();
624 + config.setBoolean( "core", null, "autocrlf", autocrlf );
625 + config.save();
622 626
627 + System.out.println( "Cloned git repository " + url + " to " + target.getAbsolutePath() + ". Current HEAD: " + commitHash( result ) );
623 628 } finally
624 629 {
625 630 result.close();
626 631 }
627 632 }
628 633
629 634 public static String commitHash(Git repo) throws GitAPIException
630 635 {
631 636 return Iterables.getOnlyElement( repo.log().setMaxCount( 1 ).call() ).getName();
632 637 }

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

Add shortcut