RFR: 2077: GitLabRepository.recentCommitComments may miss commits on non default branch
Erik Joelsson
erikj at openjdk.org
Wed Oct 25 22:20:10 UTC 2023
The recentCommitComments method on GitLabRepository is a big hack to overcome shortcomings in the GitLab APIs that has caused trouble for us at several occasions. I have now discovered another flaw in the implementation.
The sub method `getCommitTitleToCommitsMap` is used to build a map of commit messages to a list of commits. On first call, it builds the bulk of the map from a local repository. This is then kept up to date by calling the rest endpoint `GET /projects/:id/repository/commits` using the `since` argument to get all commits created after the newest commit already present in the map. The problem is that this API point will only return commits on the default branch. This means that after a bot restart, any new commits on other branches will not be found when looking for commit commands.
To fix this, I found the parameter `all=true` for this [endpoint](https://docs.gitlab.com/ee/api/commits.html). According to my testing, this will include commits not on the default branch while still letting us filter using `since`.
-------------
Commit messages:
- SKARA-2077
Changes: https://git.openjdk.org/skara/pull/1576/files
Webrev: https://webrevs.openjdk.org/?repo=skara&pr=1576&range=00
Issue: https://bugs.openjdk.org/browse/SKARA-2077
Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/skara/pull/1576.diff
Fetch: git fetch https://git.openjdk.org/skara.git pull/1576/head:pull/1576
PR: https://git.openjdk.org/skara/pull/1576
More information about the skara-dev
mailing list