mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-12-21 15:59:48 +01:00
Fix peer review issues
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
@@ -54,7 +55,7 @@ class GitWorkingCopyInitializer {
|
||||
|
||||
public ParentAndClone<Repository, Repository> initialize(File target, String initialBranch) {
|
||||
LOG.trace("clone repository {}", context.getRepository().getId());
|
||||
long start = System.nanoTime();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
try {
|
||||
Repository clone = Git.cloneRepository()
|
||||
.setURI(simpleGitWorkingCopyFactory.createScmTransportProtocolUri(context.getDirectory()))
|
||||
@@ -73,9 +74,7 @@ class GitWorkingCopyInitializer {
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new InternalRepositoryException(context.getRepository(), "could not clone working copy of repository", e);
|
||||
} finally {
|
||||
long end = System.nanoTime();
|
||||
long duration = end - start;
|
||||
LOG.trace("took {} ns to clone repository {}", duration, context.getRepository().getId());
|
||||
LOG.trace("took {} to clone repository {}", stopwatch.stop(), context.getRepository().getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
package sonia.scm.repository.spi;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.api.ResetCommand;
|
||||
import org.eclipse.jgit.api.errors.GitAPIException;
|
||||
@@ -49,7 +50,7 @@ class GitWorkingCopyReclaimer {
|
||||
|
||||
public ParentAndClone<Repository, Repository> reclaim(File target, String initialBranch) throws SimpleWorkingCopyFactory.ReclaimFailedException {
|
||||
LOG.trace("reclaim repository {}", context.getRepository().getId());
|
||||
long start = System.nanoTime();
|
||||
Stopwatch stopwatch = Stopwatch.createStarted();
|
||||
Repository repo = openTarget(target);
|
||||
try (Git git = Git.open(target)) {
|
||||
git.reset().setMode(ResetCommand.ResetType.HARD).call();
|
||||
@@ -62,9 +63,7 @@ class GitWorkingCopyReclaimer {
|
||||
} catch (GitAPIException | IOException e) {
|
||||
throw new SimpleWorkingCopyFactory.ReclaimFailedException(e);
|
||||
} finally {
|
||||
long end = System.nanoTime();
|
||||
long duration = end - start;
|
||||
LOG.trace("took {} ns to reclaim repository {}\n", duration, context.getRepository().getId());
|
||||
LOG.trace("took {} to reclaim repository {}", stopwatch.stop(), context.getRepository().getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user