Fix peer review issues

This commit is contained in:
René Pfeuffer
2020-06-02 21:31:33 +02:00
parent 273bcb6f1a
commit a32bd01c45
6 changed files with 12 additions and 101 deletions

View File

@@ -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());
}
}
}

View File

@@ -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());
}
}