RFR: 1452: Can never notify on first commit [v5]

Erik Joelsson erikj at openjdk.org
Thu Oct 6 21:28:23 UTC 2022


On Thu, 6 Oct 2022 19:23:56 GMT, Zhao Song <zsong at openjdk.org> wrote:

>> I changed the logic when there is no notify history.
>> 
>> Originally, on the first commit of a new repo, the bot would find no notify history, so it will make the first commit as an initial state and it will not make any notification.
>> 
>> Now, on the first commit of a new repo, the bot would find no notify history too, but it will make the initial git hash as the initial state of the repo, so it will treat the first commit as an 'update' operation and will make notifications.
>
> Zhao Song has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix a bug

bots/notify/src/main/java/org/openjdk/skara/bots/notify/RepositoryWorkItem.java line 372:

> 370:                     log.warning("No previous history found for any branch - resetting mark for '" + ref.name());
> 371:                     int existingCommits = localRepo.commitCount();
> 372:                     if (existingCommits <= NEW_REPOSITORY_COMMIT_THRESHOLD) {

Unless the variable name is clarifying something, which it isn't here, then better just inline the call.

bots/notify/src/main/java/org/openjdk/skara/bots/notify/RepositoryWorkItem.java line 373:

> 371:                     int existingCommits = localRepo.commitCount();
> 372:                     if (existingCommits <= NEW_REPOSITORY_COMMIT_THRESHOLD) {
> 373:                         // In this case, the repo will be considered as a new repo, notify bot will notify start from the first commit

This comment is saying the same thing as the log message, so isn't needed.

bots/notify/src/main/java/org/openjdk/skara/bots/notify/RepositoryWorkItem.java line 381:

> 379:                         }
> 380:                     } else {
> 381:                         // In this case, the repo will be considered as an existing repo with history, notify bot will only notify on new commits

This comment is saying the same thing as the log message, so isn't needed.

vcs/src/main/java/org/openjdk/skara/vcs/hg/HgRepository.java line 1500:

> 1498:     @Override
> 1499:     public int commitCount() throws IOException {
> 1500:         try (var p = capture("hg", "id", "--num", "--rev","tip")) {

Suggestion:

        try (var p = capture("hg", "id", "--num", "--rev", "tip")) {

-------------

PR: https://git.openjdk.org/skara/pull/1385


More information about the skara-dev mailing list