Beispiel #1
1
 @NotNull
 private Map<String, Ref> getRemoteRefs(@NotNull Repository db, @NotNull GitVcsRoot gitRoot)
     throws Exception {
   long retryInterval = myConfig.getConnectionRetryIntervalMillis();
   int attemptsLeft = myConfig.getConnectionRetryAttempts();
   while (true) {
     final long start = System.currentTimeMillis();
     Transport transport = null;
     FetchConnection connection = null;
     try {
       transport =
           myTransportFactory.createTransport(
               db, gitRoot.getRepositoryFetchURL(), gitRoot.getAuthSettings());
       connection = transport.openFetch();
       return connection.getRefsMap();
     } catch (NotSupportedException nse) {
       throw friendlyNotSupportedException(gitRoot, nse);
     } catch (TransportException te) {
       attemptsLeft--;
       if (isRecoverable(te) && attemptsLeft > 0) {
         LOG.warn(
             "List remote refs failed: "
                 + te.getMessage()
                 + ", "
                 + attemptsLeft
                 + " attempt(s) left");
       } else {
         throw friendlyTransportException(te, gitRoot);
       }
     } catch (WrongPassphraseException e) {
       throw new VcsException(e.getMessage(), e);
     } finally {
       if (connection != null) connection.close();
       if (transport != null) transport.close();
       final long finish = System.currentTimeMillis();
       PERFORMANCE_LOG.debug(
           "[getRemoteRefs] repository: "
               + LogUtil.describe(gitRoot)
               + ", took "
               + (finish - start)
               + "ms");
     }
     Thread.sleep(retryInterval);
     retryInterval *= 2;
   }
 }
Beispiel #2
0
 /**
  * Expected fullPath format:
  *
  * <p>"<git revision hash>|<repository url>|<file relative path>"
  *
  * @param rootEntry indicates the association between VCS root and build configuration
  * @param fullPath change path from IDE patch
  * @return the mapped path
  */
 @NotNull
 public Collection<String> mapFullPath(
     @NotNull final VcsRootEntry rootEntry, @NotNull final String fullPath) {
   OperationContext context = createContext(rootEntry.getVcsRoot(), "map full path");
   try {
     return myMapFullPath.mapFullPath(context, rootEntry, fullPath);
   } catch (VcsException e) {
     LOG.warnAndDebugDetails(
         "Error while mapping path for root " + LogUtil.describe(rootEntry.getVcsRoot()), e);
     return Collections.emptySet();
   } catch (Throwable t) {
     LOG.error("Error while mapping path for root " + LogUtil.describe(rootEntry.getVcsRoot()), t);
     return Collections.emptySet();
   } finally {
     context.close();
   }
 }
Beispiel #3
0
 private void logBuildPatch(
     @NotNull VcsRoot root, @Nullable String fromRevision, @NotNull String toRevision) {
   StringBuilder msg = new StringBuilder();
   msg.append("Build");
   if (fromRevision != null) msg.append(" incremental");
   msg.append(" patch in VCS root ").append(LogUtil.describe(root));
   if (fromRevision != null) msg.append(" from revision ").append(fromRevision);
   msg.append(" to revision ").append(toRevision);
   LOG.info(msg.toString());
 }
Beispiel #4
0
 @NotNull
 public Map<String, Ref> getRemoteRefs(@NotNull final VcsRoot root) throws VcsException {
   OperationContext context = createContext(root, "list remote refs");
   GitVcsRoot gitRoot = context.getGitRoot();
   try {
     Repository db = context.getRepository();
     Map<String, Ref> remoteRefs = getRemoteRefs(db, gitRoot);
     if (LOG.isDebugEnabled())
       LOG.debug("Remote refs for VCS root " + LogUtil.describe(root) + ": " + remoteRefs);
     return remoteRefs;
   } catch (Exception e) {
     throw context.wrapException(e);
   } finally {
     context.close();
   }
 }
Beispiel #5
0
 @NotNull
 public RepositoryStateData getCurrentState(@NotNull GitVcsRoot gitRoot) throws VcsException {
   String refInRoot = gitRoot.getRef();
   String fullRef = GitUtils.expandRef(refInRoot);
   Map<String, String> branchRevisions = new HashMap<String, String>();
   for (Ref ref : getRemoteRefs(gitRoot.getOriginalRoot()).values()) {
     if (!ref.getName().startsWith("ref")) continue;
     if (!gitRoot.isReportTags() && isTag(ref) && !fullRef.equals(ref.getName())) continue;
     branchRevisions.put(ref.getName(), getRevision(ref));
   }
   if (branchRevisions.get(fullRef) == null && !gitRoot.isIgnoreMissingDefaultBranch()) {
     throw new VcsException(
         "Cannot find revision of the default branch '"
             + refInRoot
             + "' of vcs root "
             + LogUtil.describe(gitRoot));
   }
   return RepositoryStateData.createVersionState(fullRef, branchRevisions);
 }