private String push()

in git-server/src/main/java/jetbrains/buildServer/buildTriggers/vcs/git/GitLabelingSupport.java [87:129]


  private String push(@NotNull String label,
                      @NotNull String version,
                      @NotNull GitVcsRoot gitRoot,
                      @NotNull Repository r,
                      @NotNull Ref tagRef,
                      @NotNull RevisionsInfo revisionsInfo) throws VcsException, IOException {
    long pushStart = System.currentTimeMillis();
    final Transport tn = myTransportFactory.createTransport(r, gitRoot.getRepositoryPushURL().get(), gitRoot.getAuthSettings(), myConfig.getPushTimeoutSeconds());
    PushConnection c = null;
    try {
      c = tn.openPush();
      RemoteRefUpdate ru = new RemoteRefUpdate(r, tagRef.getName(), tagRef.getObjectId(), tagRef.getName(), false, null, null);
      PreparePackFunction preparePack = null;
      if (c instanceof BasePackPushConnection) {
        final RevTag tagObject = getTagObject(r, tagRef);
        if (tagObject != null) {
          preparePack = new PreparePackFunction(tagObject, revisionsInfo);
          ((BasePackPushConnection)c).setPreparePack(preparePack);
        } else {
          LOG.debug("Cannot locate the " + tagRef.getName() + " tag object, don't use pack heuristic");
        }
      }
      c.push(NullProgressMonitor.INSTANCE, Collections.singletonMap(tagRef.getName(), ru));
      LOG.info("Tag  " + label + "=" + version + " was pushed with status " + ru.getStatus() + " for " + gitRoot.debugInfo() +
               " in " + (System.currentTimeMillis() - pushStart) + "ms" +
               (preparePack != null ? " (prepare pack " + preparePack.getPreparePackDurationMillis() + "ms)" : ""));
      switch (ru.getStatus()) {
        case UP_TO_DATE:
        case OK:
          break;
        default:
          String msg = ru.getMessage();
          throw new VcsException("The remote '" + label+ "' tag was not created" +
                                 ", status: " + ru.getStatus() +
                                 (!isEmpty(msg) ? ", message: " + msg : ""));
      }
      return label;
    } finally {
      if (c != null)
        c.close();
      tn.close();
    }
  }