diff --git a/common/build.gradle b/common/build.gradle
index ad3c70b00..41505e6d5 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -22,5 +22,8 @@ if (tasks.findByName('trimShadedJar')) {
keep "class com.linecorp.centraldogma.internal.shaded.caffeine.** { *; }"
// Prevent ProGuard from removing all enum values from Option because otherwise it becomes a non-enum class.
keep "class com.linecorp.centraldogma.internal.shaded.jsonpath.Option { *; }"
+
+ // Reduces the verbosity of ProGuardTask when running in parallel.
+ dontnote
}
}
diff --git a/server-mirror-git/src/test/java/com/linecorp/centraldogma/server/internal/mirror/MirroringTaskTest.java b/server-mirror-git/src/test/java/com/linecorp/centraldogma/server/internal/mirror/MirroringTaskTest.java
index 4b9381365..c3ffdc930 100644
--- a/server-mirror-git/src/test/java/com/linecorp/centraldogma/server/internal/mirror/MirroringTaskTest.java
+++ b/server-mirror-git/src/test/java/com/linecorp/centraldogma/server/internal/mirror/MirroringTaskTest.java
@@ -45,10 +45,10 @@ void testSuccessMetrics() {
Mirror mirror = newMirror("git://a.com/b.git", GitMirror.class, "foo", "bar");
mirror = spy(mirror);
doNothing().when(mirror).mirror(any(), any(), anyInt(), anyLong());
- new MirroringTask(mirror, meterRegistry).run(null, null, 0, 0L);
+ new MirroringTask(mirror, "foo", meterRegistry).run(null, null, 0, 0L);
assertThat(MoreMeters.measureAll(meterRegistry))
.contains(entry("mirroring.result#count{direction=LOCAL_TO_REMOTE,localPath=/," +
- "localRepo=bar,remoteBranch=,remotePath=/,success=true}", 1.0));
+ "localRepo=bar,project=foo,remoteBranch=,remotePath=/,success=true}", 1.0));
}
@Test
@@ -58,12 +58,12 @@ void testFailureMetrics() {
mirror = spy(mirror);
final RuntimeException e = new RuntimeException();
doThrow(e).when(mirror).mirror(any(), any(), anyInt(), anyLong());
- final MirroringTask task = new MirroringTask(mirror, meterRegistry);
+ final MirroringTask task = new MirroringTask(mirror, "foo", meterRegistry);
assertThatThrownBy(() -> task.run(null, null, 0, 0L))
.isSameAs(e);
assertThat(MoreMeters.measureAll(meterRegistry))
.contains(entry("mirroring.result#count{direction=LOCAL_TO_REMOTE,localPath=/," +
- "localRepo=bar,remoteBranch=main,remotePath=/," +
+ "localRepo=bar,project=foo,remoteBranch=main,remotePath=/," +
"success=false}", 1.0));
}
@@ -76,11 +76,11 @@ void testTimerMetrics() {
Thread.sleep(1000);
return null;
}).when(mirror).mirror(any(), any(), anyInt(), anyLong());
- new MirroringTask(mirror, meterRegistry).run(null, null, 0, 0L);
+ new MirroringTask(mirror, "foo", meterRegistry).run(null, null, 0, 0L);
assertThat(MoreMeters.measureAll(meterRegistry))
.hasEntrySatisfying(
"mirroring.task#total{direction=LOCAL_TO_REMOTE,localPath=/," +
- "localRepo=bar,remoteBranch=,remotePath=/}",
+ "localRepo=bar,project=foo,remoteBranch=,remotePath=/}",
v -> assertThat(v).isCloseTo(1, withPercentage(30)));
}
}
diff --git a/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ContentServiceV1.java b/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ContentServiceV1.java
index 757194d00..3e8c04fac 100644
--- a/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ContentServiceV1.java
+++ b/server/src/main/java/com/linecorp/centraldogma/server/internal/api/ContentServiceV1.java
@@ -24,6 +24,7 @@
import static com.linecorp.centraldogma.internal.Util.isValidFilePath;
import static com.linecorp.centraldogma.server.internal.api.DtoConverter.convert;
import static com.linecorp.centraldogma.server.internal.api.HttpApiUtil.returnOrThrow;
+import static com.linecorp.centraldogma.server.internal.api.RepositoryServiceV1.increaseCounterIfOldRevisionUsed;
import static com.linecorp.centraldogma.server.internal.storage.repository.DefaultMetaRepository.metaRepoFiles;
import static java.util.Objects.requireNonNull;
@@ -114,11 +115,13 @@ public ContentServiceV1(ProjectManager projectManager, CommandExecutor executor,
*
Returns the list of files in the path.
*/
@Get("regex:/projects/(?[^/]+)/repos/(?[^/]+)/list(?(|/.*))$")
- public CompletableFuture>> listFiles(@Param String path,
+ public CompletableFuture>> listFiles(ServiceRequestContext ctx,
+ @Param String path,
@Param @Default("-1") String revision,
Repository repository) {
final String normalizedPath = normalizePath(path);
final Revision normalizedRev = repository.normalizeNow(new Revision(revision));
+ increaseCounterIfOldRevisionUsed(ctx, repository, normalizedRev);
final CompletableFuture>> future = new CompletableFuture<>();
listFiles(repository, normalizedPath, normalizedRev, false, future);
return future;
@@ -214,12 +217,14 @@ private CompletableFuture push(long commitTimeMills, Author author, Re
*/
@Post("/projects/{projectName}/repos/{repoName}/preview")
public CompletableFuture>> preview(
+ ServiceRequestContext ctx,
@Param @Default("-1") String revision,
Repository repository,
@RequestConverter(ChangesRequestConverter.class) Iterable> changes) {
-
+ final Revision baseRevision = new Revision(revision);
+ increaseCounterIfOldRevisionUsed(ctx, repository, baseRevision);
final CompletableFuture