public static void main()

in git-server/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/patch/GitPatchProcess.java [28:80]


  public static void main(String... args) throws Exception {
    Map<String, String> properties = VcsUtil.stringToProperties(GitServerUtil.readInput());
    GitPatchProcessSettings settings = new GitPatchProcessSettings(properties);
    GitServerUtil.configureInternalProperties(settings.getInternalProperties());
    GitServerUtil.configureStreamFileThreshold(Integer.MAX_VALUE);
    GitServerUtil.configureExternalProcessLogger(settings.isDebugEnabled());
    GitServerUtil.setupMemoryMappedIndexReading();
    JSchConfigInitializer.initJSchConfig(JSch.class);

    PluginConfigImpl config = new PluginConfigImpl(new ConstantCachePaths(settings.getGitCachesDir()));
    RepositoryManager repositoryManager = new RepositoryManagerImpl(
      config, new MirrorManagerImpl(config, new HashCalculatorImpl(), new RemoteRepositoryUrlInvestigatorImpl()));
    GitMapFullPath mapFullPath = new GitMapFullPath(config, new RevisionsCache(config));
    VcsRootSshKeyManager sshKeyManager = new ConstantSshKeyManager(settings.getKeyBytes());
    SshKnownHostsManager knownHostsManager = new ConstantServerSshKnownHostsManager();
    TransportFactory transportFactory = new TransportFactoryImpl(config, sshKeyManager, settings.getGitTrustStoreProvider(), knownHostsManager);
    FetcherProperties fetcherProperties = new FetcherProperties(config);
    FetchCommand fetchCommand = new FetchCommandImpl(config, transportFactory, fetcherProperties, sshKeyManager, settings.getGitTrustStoreProvider(), knownHostsManager);
    GitRepoOperations repoOperations = new GitRepoOperationsImpl(config, transportFactory, sshKeyManager, fetchCommand, knownHostsManager);
    CommitLoader commitLoader = new CommitLoaderImpl(repositoryManager, repoOperations, mapFullPath, config, new FetchSettingsFactoryImpl());

    OperationContext context = new OperationContext(commitLoader, repositoryManager, settings.getRoot(), "build patch", GitProgress.NO_OP, config, null);
    OutputStream fos = new BufferedOutputStream(new FileOutputStream(settings.getPatchFile()));
    try {
      PatchBuilderImpl patchBuilder = new PatchBuilderImpl(fos);
      new GitPatchBuilder(context,
                          patchBuilder,
                          settings.getFromRevision(),
                          settings.getToRevision(),
                          settings.getCheckoutRules(),
                          settings.isVerboseTreeWalkLog(),
                          new PrintFile(), transportFactory).buildPatch();
      patchBuilder.close();
    } catch (Throwable t) {
      if (settings.isDebugEnabled() || isImportant(t)) {
        System.err.println(t.getMessage());
        t.printStackTrace(System.err);
      } else {
        String msg = t.getMessage();
        boolean printStackTrace = false;
        if (t instanceof SubmoduleFetchException) {
          Throwable cause = t.getCause();
          printStackTrace = cause != null && isImportant(cause);
        }
        System.err.println(msg);
        if (printStackTrace)
          t.printStackTrace(System.err);
      }
      System.exit(1);
    } finally {
      fos.close();
    }
  }