From d3cefb574b39efeead39cadcf6c324aa18fc8c79 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 15 Jul 2024 23:42:16 +0200 Subject: [PATCH] Three fixes (#23) --- .github/workflows/ci.yaml | 2 +- CHANGELOG.md | 9 +++++++++ README.md | 10 ++++++++++ gcl.java | 38 ++++++++++++++++++++++++++++++++------ 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5584de2..1e3e54f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -49,4 +49,4 @@ jobs: # exit 1 in case of error # We have 1 "valid" issue in CHANGELOG.md - grep -q "3 problems" heylogs.txt || exit 1 + grep -q "4 problems" heylogs.txt || exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bca192..f6dc5d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [2024-07-15] + +### Fixed + +- Fixed a null pointer exception when running. [#22](https://github.com/koppor/github-contributors-list/issues/22) +- Fixed ignoring of users when logins are used in the filter and the commit was on the main branch. +- Fixed parsing of multiple ignored users. + ## [2024-04-26] ### Added @@ -45,6 +53,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Initial release. +[2024-07-15]: https://github.com/koppor/github-contributors-list/compare/2024-04-26...2024-07-15 [2024-04-26]: https://github.com/koppor/github-contributors-list/compare/2024-04-25...2024-04-26 [2024-04-25]: https://github.com/koppor/github-contributors-list/compare/2024-04-09...2024-04-25 [2024-04-09]: https://github.com/koppor/github-contributors-list/releases/tag/2024-04-09 diff --git a/README.md b/README.md index be34b4f..186d135 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,12 @@ Usage: jbang gcl@koppor/github-contributors-list [-lhV] [--startrevision= `. Example: @@ -70,6 +76,10 @@ For instance, if a user first appears as "Co-authored-by:" and later as a pull r In case of issues, try to delete `gcl.mv` to start with a fresh cache. +## FAQ + +⚠ In case contributors are not ignored, please delete `gcl.mv` and try again. ⚠ + ## Implementation details - `gcl.mv` is an [MVStore](https://www.h2database.com/html/mvstore.html) caching contributor information returned by GitHub's API. diff --git a/gcl.java b/gcl.java index a4c2fca..454d68f 100755 --- a/gcl.java +++ b/gcl.java @@ -8,6 +8,7 @@ //DEPS info.picocli:picocli:4.7.6 //DEPS one.util:streamex:0.8.2 //DEPS me.tongfei:progressbar:0.10.1 +//DEPS org.jline:jline-terminal:3.26.2 //DEPS org.eclipse.collections:eclipse-collections:11.1.0 //DEPS org.tinylog:tinylog-api:2.7.0 @@ -89,13 +90,13 @@ public class gcl implements Callable { @Option(names = "--endrevision", description = "The last revision to check (tag or commit id). Included.") private String endCommitRevStr; - @Option(names = "--repository", description = "The GitHub repository in the form owner/repostiory. E.g., JabRef/jabref") + @Option(names = "--repository", description = "The GitHub repository in the form owner/repository. E.g., JabRef/jabref") private String ownerRepository; @Option(names = "--cols", description = "Number of columns") private Integer cols = 6; - @Option(names = "--filter") + @Option(names = "--filter", split = ",") private List ignoredUsers = List.of( "allcontributors[bot]", "dependabot[bot]", @@ -105,7 +106,7 @@ public class gcl implements Callable { "renovate[bot]", "renovate-bot"); - @Option(names = "--filter-emails") + @Option(names = "--filter-emails", split = ",") private List ignoredEmails = List.of( "49699333+dependabot[bot]@users.noreply.github.com", "bot@renovateapp.com", @@ -388,9 +389,14 @@ private void addContributorFromRevCommit(RevCommit commit, MVMap loginToContributor, MVMap emailToContributor, GHUser ghUser, String prCommitNumber) { Logger.trace("Handling {}", ghUser); String login = ghUser.getLogin(); + Logger.trace("Login: {}", login); if (ignoredUsers.contains(login)) { Logger.trace("Ignored because of login {}", login); return; + } else { + Logger.trace("Not ignored because of login {}", login); } Contributor contributor = loginToContributor.get(login); Logger.trace("Found contributor {}", contributor); if (contributor != null) { - contributors.add(contributor); + addContributor(contributor); putIntoEmailToContributorMap(emailToContributor, ghUser, contributor); return; } @@ -560,7 +580,7 @@ private void storeContributorData(MVMap loginToContributor, Contributor newContributor = new Contributor(name, ghUser.getHtmlUrl().toString(), ghUser.getAvatarUrl(), prCommitNumber); Logger.trace("Created new contributor {} based on PR data", newContributor); loginToContributor.put(login, newContributor); - contributors.add(newContributor); + addContributor(newContributor); putIntoEmailToContributorMap(emailToContributor, ghUser, newContributor); } @@ -581,6 +601,12 @@ private static void putIntoEmailToContributorMap(MVMap emai emailToContributor.put(email, contributor); } + /** + * Looks up the contributor data for the given co-author. If the co-author is already in the contributors set, the lookup is skipped. + * If the co-author is in the ignoredUsers or ignoredEmails lists, the lookup is skipped and an empty Optional is returned. + * + * @return an Optional with the contributor data if the lookup was successful, otherwise an empty Optional. + */ private Optional lookupContributorData(MVMap emailToContributor, GitHub gitHub, String prNumber, String commitName, CoAuthor coAuthor) { Logger.trace("Looking up {}", coAuthor); if (alreadyChecked.contains(coAuthor)) {