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

Guoxiong Li gli at openjdk.org
Fri Oct 7 06:12:33 UTC 2022

On Thu, 6 Oct 2022 21:38:39 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:
>   Deleted some comments

vcs/src/main/java/org/openjdk/skara/vcs/git/GitRepository.java line 51:

> 49:     private final Logger log = Logger.getLogger("org.openjdk.skara.vcs.git");
> 50:     private Path cachedRoot = null;
> 51:     public static final Hash EMPTY_TREE = new Hash("4b825dc642cb6eb9a060e54bf8d69288fbee4904");

It is better to create a new small method in interface `ReadOnlyRepository` to return the empty tree hash (such as named `emptyTreeHash`) and implement this method in `GitRepository` and `HgRepository`. So the code can be run in mercurial(HG) repository rightly. And then this field can be `private` if the new method is implemented.

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

> 1499:     public int commitCount() throws IOException {
> 1500:         try (var p = capture("hg", "id", "--num", "--rev", "tip")) {
> 1501:             return Integer.parseInt(await(p).stdout().get(0)) + 1;

A question: Is the plus one `+ 1` intentional? I don't know HG well.


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

More information about the skara-dev mailing list