/** * {@inheritDoc} * <p> * Decrement the use count, and maybe close resources. */ @Override public void close() { int newCount = useCnt.decrementAndGet(); if (newCount == 0) { if (RepositoryCache.isCached(this)) { closedAt.set(System.currentTimeMillis()); } else { doClose(); } } else if (newCount == -1) { // should not happen, only log when useCnt became negative to // minimize number of log entries String message = MessageFormat.format(JGitText.get().corruptUseCnt, toString()); if (LOG.isDebugEnabled()) { LOG.debug(message, new IllegalStateException()); } else { LOG.warn(message); } if (RepositoryCache.isCached(this)) { closedAt.set(System.currentTimeMillis()); } } }
public String getRepoRelativePath(){ /* String rel_path = null; Collection<SVNDirEntry> SVNentry = this.rootRepo.getDir("tags/", -1, null,(Collection<SVNDirEntry>) null); Iterator<SVNDirEntry> iterator = SVNentry.iterator(); if (iterator.hasNext()) { SVNDirEntry entry = (SVNDirEntry) iterator.next(); // remove the root repository part from the whole url (object: SVNDirEntry) rel_path = entry.getURL().toString().replaceAll(entry.getRepositoryRoot().toString(), ""); }else{ SvnClient.log.error("[Error] while getting the relative path for tag directory"); } rel_path = rel_path.substring(0, rel_path.lastIndexOf('/')); return rel_path; */ //TODO: To be tested return url.toString().replace(repository.toString(), ""); }
private String repoName() { final File gitDir = db.getDirectory(); if (gitDir == null) return db.toString(); String n = gitDir.getName(); if (Constants.DOT_GIT.equals(n)) n = gitDir.getParentFile().getName(); return n; } }
/** * {@inheritDoc} * <p> * Decrement the use count, and maybe close resources. */ @Override public void close() { int newCount = useCnt.decrementAndGet(); if (newCount == 0) { if (RepositoryCache.isCached(this)) { closedAt.set(System.currentTimeMillis()); } else { doClose(); } } else if (newCount == -1) { // should not happen, only log when useCnt became negative to // minimize number of log entries String message = MessageFormat.format(JGitText.get().corruptUseCnt, toString()); if (LOG.isDebugEnabled()) { LOG.debug(message, new IllegalStateException()); } else { LOG.warn(message); } if (RepositoryCache.isCached(this)) { closedAt.set(System.currentTimeMillis()); } } }
} finally { final long endTime = System.currentTimeMillis(); log.info("{} hook for repository {} took {}ms", hook, repository.toString(), (endTime - startTime));
public static boolean addRemote(Repository repository, String remoteUrl) { boolean remoteAdded = false; StoredConfig config = repository.getConfig(); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.URL, remoteUrl); config.setString(GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN, GitDeploymentSynchronizerConstants.FETCH, GitDeploymentSynchronizerConstants.FETCH_LOCATION); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.REMOTE, GitDeploymentSynchronizerConstants.ORIGIN); config.setString(GitDeploymentSynchronizerConstants.BRANCH, GitDeploymentSynchronizerConstants.MASTER, GitDeploymentSynchronizerConstants.MERGE, GitDeploymentSynchronizerConstants.GIT_REFS_HEADS_MASTER); try { config.save(); remoteAdded = true; } catch (IOException e) { log.error("Error in adding remote origin " + remoteUrl + " for local repository " + repository.toString(), e); } return remoteAdded; }