From ae6f6f6a4583f9acb4b98fc4145cc8d76b3d5693 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:13:02 +0200 Subject: [PATCH 01/16] Fix required directory parameter --- gcl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcl.java b/gcl.java index 0ddc0b6..dbec836 100755 --- a/gcl.java +++ b/gcl.java @@ -76,7 +76,7 @@ public class gcl implements Callable { private static final Pattern numberAtEnd = Pattern.compile(".*\\(#(\\d+)\\)$"); private static final Pattern mergeCommit = Pattern.compile("^Merge pull request #(\\d+) from.*"); - @Parameters(index = "0", description = "The path to the git repository to analyse.") + @Parameters(index = "0", arity = "0..1", description = "The path to the git repository to analyse.") private Path repositoryPath = Path.of("."); @Option(names = "--startrevision", description = "The first revision to check (tag or commit id). Excluded.") From bf2e91cd4328d8b09bc047273861e9298fb7213e Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:16:31 +0200 Subject: [PATCH 02/16] Update help in README.md --- README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a686ec5..e623653 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ See for real-wor 4. `jbang gcl@koppor/github-contributors-list` ``` -Usage: jbang gcl.java [-lhV] [--startrevision=] - [--endrevision=] [--owner=] - [--repo=] [--cols=] [--filter=]... +Usage: jbang gcl@koppor/github-contributors-list [-lhV] [--startrevision=] + [--endrevision=] [--repository=] + [--cols=] [--filter=]... [--filter-emails=]... [-m=]... - - The path to the git repository to analyse. + [] + [] The path to the git repository to analyse. --cols= Number of columns --endrevision= The last revision to check (tag or commit id). @@ -40,11 +40,12 @@ Usage: jbang gcl.java [-lhV] [--startrevision=] -h, --help Show this help message and exit. -l, --[no-]github-lookup Should calls be made to GitHub's API for user information - -m, --lgin-mapping= + -m, --login-mapping= Mapping of GitHub logins to names. Format: name=login - --owner= The GitHub owner of the repository - --repo= The GitHub repository name + --repository= + The GitHub repository in the form + owner/repostiory. E.g., JabRef/jabref --startrevision= The first revision to check (tag or commit id). Excluded. From 738cb3a58eb6d8f6594bba6b84d6acf450871e8f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:19:19 +0200 Subject: [PATCH 03/16] Add CI check --- .github/workflows/ci.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..55aac63 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,19 @@ +on: [pull_request] + +jobs: + check: + runs-on: ubuntu-latest + name: Check + steps: + - name: checkout + uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: /root/.jbang + key: $-jbang-$ + restore-keys: | + $-jbang- + - name: jbang + uses: jbangdev/jbang-action@v0.116.0 + with: + script: gcl.java From bef0b0c5ad64fd99189b2b471b66b32cde1cc63c Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:23:45 +0200 Subject: [PATCH 04/16] Fix jbang action version --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55aac63..62d3a2e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,6 +14,6 @@ jobs: restore-keys: | $-jbang- - name: jbang - uses: jbangdev/jbang-action@v0.116.0 + uses: jbangdev/jbang-action@v0.115.0 with: script: gcl.java From eeea6dc488c4859fc68b61f1cbd531cbe0b2f0c0 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:32:07 +0200 Subject: [PATCH 05/16] Try to set token --- .github/workflows/ci.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 62d3a2e..27aa124 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,3 +17,5 @@ jobs: uses: jbangdev/jbang-action@v0.115.0 with: script: gcl.java + env: + GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file From b6962a7486d33505bda487c887ceb8a79ef47927 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:37:05 +0200 Subject: [PATCH 06/16] Some debug --- gcl.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/gcl.java b/gcl.java index dbec836..5b9313e 100755 --- a/gcl.java +++ b/gcl.java @@ -179,15 +179,24 @@ public Integer call() throws Exception { Git git = Git.open(repositoryPath.toFile()); Repository repository = git.getRepository(); RevWalk revWalk = new RevWalk(repository)) { + String remoteOriginUrl = "n/a"; if (!hasRepository) { // Source: https://stackoverflow.com/a/38062680/873282 - ownerRepository = git.getRepository().getConfig().getString("remote", "origin", "url"); - ownerRepository = ownerRepository.substring(ownerRepository.indexOf(':') + 1, ownerRepository.lastIndexOf('.')); + remoteOriginUrl = git.getRepository().getConfig().getString("remote", "origin", "url"); + ownerRepository = remoteOriginUrl.substring(remoteOriginUrl.indexOf(':') + 1, remoteOriginUrl.lastIndexOf('.')); } Logger.info("Connecting to {}...", ownerRepository); GitHub gitHub = GitHub.connect(); - GHRepository gitHubRepository = gitHub.getRepository(ownerRepository); + try { + GHRepository gitHubRepository = gitHub.getRepository(ownerRepository); + } catch (IllegalArgumentException e) { + Logger.error("Error in repository reference {}", ownerRepository); + if (!hasRepository) { + Logger.error("It was automatically derived from {}", remoteOriginUrl); + } + return 1; + } MVMap emailToContributor = store.openMap("emailToContributor"); MVMap loginToContributor = store.openMap("loginToContributor"); From 74bd0aa8088675a383217ee59d3e43071172dd99 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:43:56 +0200 Subject: [PATCH 07/16] Fix variable visibility --- gcl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcl.java b/gcl.java index 5b9313e..8c62e9a 100755 --- a/gcl.java +++ b/gcl.java @@ -188,8 +188,9 @@ public Integer call() throws Exception { Logger.info("Connecting to {}...", ownerRepository); GitHub gitHub = GitHub.connect(); + GHRepository gitHubRepository; try { - GHRepository gitHubRepository = gitHub.getRepository(ownerRepository); + gitHubRepository = gitHub.getRepository(ownerRepository); } catch (IllegalArgumentException e) { Logger.error("Error in repository reference {}", ownerRepository); if (!hasRepository) { From ad733d6ff3dd8d1ab1e3dcf70583d158558815ab Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:50:44 +0200 Subject: [PATCH 08/16] Improved owner repository extraction --- gcl.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gcl.java b/gcl.java index 8c62e9a..4a49e7e 100755 --- a/gcl.java +++ b/gcl.java @@ -183,7 +183,14 @@ public Integer call() throws Exception { if (!hasRepository) { // Source: https://stackoverflow.com/a/38062680/873282 remoteOriginUrl = git.getRepository().getConfig().getString("remote", "origin", "url"); - ownerRepository = remoteOriginUrl.substring(remoteOriginUrl.indexOf(':') + 1, remoteOriginUrl.lastIndexOf('.')); + if (remoteOriginUrl.startsWith("git@")) { + ownerRepository = remoteOriginUrl.substring(remoteOriginUrl.indexOf(':') + 1, remoteOriginUrl.lastIndexOf('.')); + } else { + ownerRepository = remoteOriginUrl.substring(remoteOriginUrl.indexOf("github.com/") + "github.com/".length()); + if (ownerRepository.endsWith(".git")) { + ownerRepository = ownerRepository.substring(0, ownerRepository.length() - ".git".length()); + } + } } Logger.info("Connecting to {}...", ownerRepository); From 312e9fdd69922d24f042445f26283faa49d44b2d Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 13:53:49 +0200 Subject: [PATCH 09/16] Try to get something to output --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 27aa124..63608ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,6 +7,9 @@ jobs: steps: - name: checkout uses: actions/checkout@v4 + with: + fetch-depth: '0' + show-progress: 'false' - uses: actions/cache@v4 with: path: /root/.jbang From c2865fc8afc378b382923f9581218416795ccac9 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:15:07 +0200 Subject: [PATCH 10/16] Fix handling of existing entries --- CHANGELOG.md | 1 + gcl.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d43974a..d6a799a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Commits without any pull request number are also analyzed. - Fixed typo in parameter `--login-mapping`. +- Handling of ignored users. ### Removed diff --git a/gcl.java b/gcl.java index 4a49e7e..957cfce 100755 --- a/gcl.java +++ b/gcl.java @@ -126,6 +126,10 @@ public class gcl implements Callable { private static final String githubUsersEmailSuffix = "@users.noreply.github.com"; private record Contributor(String name, String url, String avatarUrl) implements Serializable { + public String getUserId() { + // Example: https://github.com/LoayGhreeb, then userId is LoeyGhreeb + return url.substring(url.lastIndexOf('/') + 1); + } } private record CoAuthor(String name, String email) { @@ -136,7 +140,7 @@ public CoAuthor(String line) { } } - private SortedSet contributors = new TreeSet<>((a, b) -> String.CASE_INSENSITIVE_ORDER.compare(a.name,b.name)); + private SortedSet contributors = new TreeSet<>((a, b) -> String.CASE_INSENSITIVE_ORDER.compare(a.name, b.name)); private SortedSet fallbacks = new TreeSet<>(); @@ -489,13 +493,15 @@ private Optional lookupContributorData(MVMap e Contributor contributor = emailToContributor.get(email); if (contributor != null) { - // Example: Store "LoyGhreeb" https://github.com/LoayGhreeb in userId - String userId = contributor.url.substring(contributor.url.lastIndexOf('/') + 1); + // We already know this email, just check whether we ignore this one + String userId = contributor.getUserId(); if (ignoredUsers.contains(userId)) { Logger.trace("Ignored because of userId {}: {}", userId, coAuthor); return Optional.empty(); } + return Optional.of(contributor); } + if (!ghLookup) { Logger.trace("Online lookup disabled. Using {} as fallback.", coAuthor.name); fallbacks.add(coAuthor.name); From 2810abdb1487e14dbd5c18b016d211534c0bdedb Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:18:58 +0200 Subject: [PATCH 11/16] Add markdown and log checks --- .github/workflows/ci.yaml | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 63608ca..f7220c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -3,7 +3,6 @@ on: [pull_request] jobs: check: runs-on: ubuntu-latest - name: Check steps: - name: checkout uses: actions/checkout@v4 @@ -21,4 +20,33 @@ jobs: with: script: gcl.java env: - GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + GITHUB_OAUTH: ${{ secrets.GITHUB_TOKEN }} + lint: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v4 + with: + show-progress: 'false' + - name: markdownlint + uses: DavidAnson/markdownlint-cli2-action@v16 + with: + globs: | + *.md + - name: Lint CHANGELOG.md + run: | + # Install jbang + curl -Ls https://sh.jbang.dev | bash -s - app setup + export PATH=$PATH:$HOME/.jbang/bin + + # run heylogs verification + jbang com.github.nbbrd.heylogs:heylogs-cli:0.7.2:bin check CHANGELOG.md > heylogs.txt || true + + # improve output + sed -i 's/all-h2-contain-a-version/all-h2-contain-a-version (ignored)/' heylogs.txt + + cat heylogs.txt + + # exit 1 in case of error + # We have 1 "valid" issue in CHANGELOG.md + grep -q "1 problem" heylogs.txt || exit 1 From 5ce2b33576493f7a79ec45f65af1488362076aca Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:21:39 +0200 Subject: [PATCH 12/16] Add Markdownlint config --- .markdownlint.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .markdownlint.yml diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..1d77064 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,4 @@ +default: true + +# allow arbitrary line length +MD013: false From efeec88812d49b03acabf6db93fc1cac9b4efcde Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:22:20 +0200 Subject: [PATCH 13/16] Fix linting issues --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e623653..be34b4f 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ See for real-wor 3. `cd` to the repository you want to analyze. 4. `jbang gcl@koppor/github-contributors-list` -``` +```terminal Usage: jbang gcl@koppor/github-contributors-list [-lhV] [--startrevision=] [--endrevision=] [--repository=] [--cols=] [--filter=]... @@ -56,7 +56,9 @@ At the end, non-found committers are listed. The format is ` `. Example: - Anish.Pal https://github.com/JabRef/jabref/pull/10829 https://github.com/JabRef/jabref/pull/10829/commits/d2d84923df2c6c7d59559da8d583ae17dc803c3d +```text +Anish.Pal https://github.com/JabRef/jabref/pull/10829 https://github.com/JabRef/jabref/pull/10829/commits/d2d84923df2c6c7d59559da8d583ae17dc803c3d +``` With that information, one can create a mapping from the committer name to the GitHub username. In this case: `Anish.Pal=pal-anish` From f357d45f2ce2946a0c5c60170dc66fb6534c1913 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:26:04 +0200 Subject: [PATCH 14/16] Try to fix CHANGELOG.md linting issues --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6a799a..c5dbdfc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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-04-25 +## [2024-04-25] ### Added @@ -26,6 +26,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Removed some hard-coded JabRef defaults (such as ignored users). -## 2024-04-09 +## [2024-04-09] Initial release. + +[Unreleased]: https://github.com/koppor/github-contributors-list/compare/2024-04-25...main +[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 From 3c72f8d175ed4c9755290338bcfed2c58003514d Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:28:00 +0200 Subject: [PATCH 15/16] Fiux markdown lint issue --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5dbdfc..970baa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,5 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). Initial release. -[Unreleased]: https://github.com/koppor/github-contributors-list/compare/2024-04-25...main [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 From 4b30dd51f4ca3469439642bfa13f0708a3df5fb5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 25 Apr 2024 14:31:15 +0200 Subject: [PATCH 16/16] Ignore CalVer issues --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f7220c1..dce2110 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 "1 problem" heylogs.txt || exit 1 + grep -q "2 problems" heylogs.txt || exit 1