CheckerUpdate: Remove support for specifying updated timestamp
None of the callers of CheckersUpdate needs to explicitly set an updated
timestamp, hence this functionality is unused and can be removed.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I09250bbdd9942753ef2aa1fc3835d889e33f9774
diff --git a/java/com/google/gerrit/plugins/checks/CheckerUpdate.java b/java/com/google/gerrit/plugins/checks/CheckerUpdate.java
index e555180..97165f6 100644
--- a/java/com/google/gerrit/plugins/checks/CheckerUpdate.java
+++ b/java/com/google/gerrit/plugins/checks/CheckerUpdate.java
@@ -19,7 +19,6 @@
import com.google.gerrit.plugins.checks.api.BlockingCondition;
import com.google.gerrit.plugins.checks.api.CheckerStatus;
import com.google.gerrit.reviewdb.client.Project;
-import java.sql.Timestamp;
import java.util.Optional;
@AutoValue
@@ -60,16 +59,6 @@
/** Defines the new query for the checker. If not specified, the query remains unchanged. */
public abstract Optional<String> getQuery();
- /**
- * Defines the {@code Timestamp} to be used for the NoteDb commits of the update. If not
- * specified, the current {@code Timestamp} when creating the commit will be used.
- *
- * <p>If this {@code CheckerUpdate} is passed next to a {@link CheckerCreation} during a checker
- * creation, this {@code Timestamp} is used for the NoteDb commits of the new checker. Hence, the
- * {@link Checker#getCreatedOn()} field will match this {@code Timestamp}.
- */
- public abstract Optional<Timestamp> getUpdatedOn();
-
public abstract Builder toBuilder();
public static Builder builder() {
@@ -93,8 +82,6 @@
public abstract Builder setQuery(String query);
- public abstract Builder setUpdatedOn(Timestamp timestamp);
-
public abstract CheckerUpdate build();
}
}
diff --git a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
index 1518ca2..eebbcfa 100644
--- a/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
+++ b/java/com/google/gerrit/plugins/checks/db/CheckerConfig.java
@@ -278,10 +278,7 @@
// Commit timestamps are internally truncated to seconds. To return the correct 'createdOn' time
// for new checkers, we explicitly need to truncate the timestamp here.
Timestamp commitTimestamp =
- TimeUtil.truncateToSecond(
- checkerUpdate
- .flatMap(CheckerUpdate::getUpdatedOn)
- .orElseGet(() -> new Timestamp(commit.getCommitter().getWhen().getTime())));
+ TimeUtil.truncateToSecond(new Timestamp(commit.getCommitter().getWhen().getTime()));
commit.setAuthor(new PersonIdent(commit.getAuthor(), commitTimestamp));
commit.setCommitter(new PersonIdent(commit.getCommitter(), commitTimestamp));
diff --git a/javatests/com/google/gerrit/plugins/checks/db/CheckerConfigTest.java b/javatests/com/google/gerrit/plugins/checks/db/CheckerConfigTest.java
index a473eef..5fb8a95 100644
--- a/javatests/com/google/gerrit/plugins/checks/db/CheckerConfigTest.java
+++ b/javatests/com/google/gerrit/plugins/checks/db/CheckerConfigTest.java
@@ -35,10 +35,6 @@
import com.google.gerrit.testing.GerritBaseTests;
import java.io.IOException;
import java.sql.Timestamp;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.Month;
-import java.time.ZoneId;
import java.util.TimeZone;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription;
@@ -231,18 +227,6 @@
}
@Test
- public void specifiedCreatedOnIsRespectedForNewChecker() throws Exception {
- Timestamp createdOn = toTimestamp(LocalDate.of(2017, Month.DECEMBER, 11).atTime(13, 44, 10));
-
- CheckerCreation checkerCreation = getPrefilledCheckerCreationBuilder().build();
- CheckerUpdate checkerUpdate = CheckerUpdate.builder().setUpdatedOn(createdOn).build();
- createChecker(checkerCreation, checkerUpdate);
-
- CheckerConfig checkerConfig = loadChecker(checkerCreation.getCheckerUuid());
- assertThat(checkerConfig).hasCreatedOnThat().isEqualTo(createdOn);
- }
-
- @Test
public void uuidInConfigMayNotBeUndefined() throws Exception {
populateCheckerConfig(checkerUuid, "[checker]");
@@ -585,8 +569,4 @@
return assertThat(commit.getFullMessage()).named("commit message");
}
}
-
- private static Timestamp toTimestamp(LocalDateTime localDateTime) {
- return Timestamp.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
- }
}