diff --git a/README.md b/README.md
index 6f4c607..18ac65b 100644
--- a/README.md
+++ b/README.md
@@ -123,6 +123,35 @@ that branch until the first workflow deployment succeeds.
5. Imported author lists include contributor-based context and are deduplicated.
6. Review, adjust, and regenerate metadata files before release.
+### Choosing which GitHub contributors to credit
+
+GitHub contributor counts measure commit activity, not authorship, so OpenCite
+treats everyone it finds as a *candidate* and lets you decide:
+
+- Authors listed in `CITATION.cff`, `.zenodo.json` or package metadata are
+ always kept, in their original order.
+- By default the top 5 contributors by commit count (and anyone named in a
+ `Co-authored-by` trailer within the selected date range) are added to the
+ author list. Change this with
+ **Authors to credit automatically** (0-50). Automated accounts never use a slot.
+- Contributors beyond that limit, plus human names found only in recent commit
+ history (up to 100 commits without a token, 1,000 with one), appear in the
+ **GitHub author candidates** panel. Each row says why the person was surfaced
+ (commit count, last commit, source) and has a checkbox that adds or removes
+ them from the author list.
+- For repositories that inherited history from another project, set **Ignore
+ contributions before** to a date. To stop at a point in time, such as a
+ release, also set **Ignore contributions after**; use both for a range.
+ Contributors with no commits in that range are not credited automatically and
+ are flagged in the candidate panel. GitHub's contributor counts are all-time,
+ so the range is checked against the scanned commit window and may miss
+ contributors beyond it; fork metadata is not used because it cannot reliably
+ show where independent development began.
+- GitHub profiles without a usable display name, or whose display name is just
+ the login, are skipped instead of using the account handle as a citation
+ author. Profile enrichment is limited to 25 candidates without a token (70 with
+ one), so add a token for deeper enrichment. Review names before exporting.
+
## Validation Behavior
OpenCite validates metadata at multiple stages:
diff --git a/package-lock.json b/package-lock.json
index d57aecc..24453cb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -15,7 +15,7 @@
"devDependencies": {
"@vitejs/plugin-react": "^6.0.3",
"gh-pages": "^6.3.0",
- "vite": "^8.1.1",
+ "vite": "^8.3.5",
"zenodraft": "0.14.1"
}
},
@@ -58,9 +58,9 @@
}
},
"node_modules/@oxc-project/types": {
- "version": "0.148.0",
- "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.148.0.tgz",
- "integrity": "sha512-Nm4s/jB+4FpFsPhWGEC4h7rzksesmtnMXomo6rCMcg/b8zLQuOziRgkCS1fxDCXOlJB/6Q8oABOZ/OP6RIPj9A==",
+ "version": "0.154.0",
+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.154.0.tgz",
+ "integrity": "sha512-KYOUGQFlLWR+s4QMV2Q9ko38TZm7EdO87Qm7rvZLqk/webse/cDjtyxKhg/47l0byCbs/k46LT8qc4PKjAikzA==",
"dev": true,
"license": "MIT",
"funding": {
@@ -68,9 +68,9 @@
}
},
"node_modules/@rolldown/binding-android-arm-eabi": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.7.tgz",
- "integrity": "sha512-EypzgnYCwyVY4NDHKzGmNJT5b+XaQEBniHxsMdeIQLB/tcCzZnhqrzHpZFbX9iaxx+5RiB8caATBtfvZP7zVxQ==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.14.tgz",
+ "integrity": "sha512-aWR+XKH9+rW7m5fWq/5360J3mHycrx/o6xZM2DQFdJnTMdyP7/WzxPjhtLbVWdKo2y612/4U1bWqb3HQhiF7vg==",
"cpu": [
"arm"
],
@@ -85,9 +85,9 @@
}
},
"node_modules/@rolldown/binding-android-arm64": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.7.tgz",
- "integrity": "sha512-l17HE9EweWaqJZhuUuNBN/FzM62xw+DECVnJyvMsxn8vJFAGLy5QfLDoYAcronkAN8VxKZHezDpulHDPx95vFw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.14.tgz",
+ "integrity": "sha512-QiVxHofl6A8lQU7WAtOUY4QMVZXohxwz7WJJoeh8NBEUyKfIkMRKhYyq8az/1RypNiIXzNTtiS6KwHz0erxYRQ==",
"cpu": [
"arm64"
],
@@ -102,9 +102,9 @@
}
},
"node_modules/@rolldown/binding-darwin-arm64": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.7.tgz",
- "integrity": "sha512-8ED8ELFvHXc6OCETIn4gXObPiaR6bckM/ipXtbzlPVDRMBfEGjCKgO90F9YtfdpDatVx/ZQw7aZ1vUMf/+T3Mw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.14.tgz",
+ "integrity": "sha512-lTQOzHuBIooh3jIr5XINQkjPGEuGy+Dsy0meXDr6Sjty0b99kYgGh4uBC/8mJX1T0kC8d6S0aPP1Y+bHkh6aBw==",
"cpu": [
"arm64"
],
@@ -119,9 +119,9 @@
}
},
"node_modules/@rolldown/binding-darwin-x64": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.7.tgz",
- "integrity": "sha512-/WPripjtiAIZ2tWY7ddijORT0Ujg87wxWW/qcoFVCKAWVDPhtY0xr7Dj0M3GyNGz60jGwTElhro/mkF9dT7dDQ==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.14.tgz",
+ "integrity": "sha512-hyMKEGatjmBYCs/Q4sbIcL/GqpFEqsX3wc+HYVQ/85A4rxc1o7rPm4DUI4GV4k/h0ITddwFSGpqQunI14GXjTA==",
"cpu": [
"x64"
],
@@ -136,9 +136,9 @@
}
},
"node_modules/@rolldown/binding-freebsd-x64": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.7.tgz",
- "integrity": "sha512-14DI4NcqpvbICxSnGLx3PmtDaWqRP/KGSGb6C+JLLVPeZRl6dKdHba3pGsqT3vpdTqhEYIPG0MMQ8c0xYqoJxA==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.14.tgz",
+ "integrity": "sha512-u371GbXoVXrEgP20PwzoGNOdAOqAMhzo19JzzY+V4YmmnC+DTOoqdbMu+O+54emM59Mik/UdrtWgcuEDKWRPKA==",
"cpu": [
"x64"
],
@@ -153,9 +153,9 @@
}
},
"node_modules/@rolldown/binding-linux-arm-gnueabihf": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.7.tgz",
- "integrity": "sha512-bxrWIRvHWQvbJwi+VIie/kDJmQxcNE6xxWwZdqF/ExVAigtHkv54WTLQPb+QsZdnFy18fg7JPfWGL0RH6vwIlQ==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.14.tgz",
+ "integrity": "sha512-BqwKsdZQf6EqVWr8fv2MrDYzAvOZ7+NYFSJESRGs87fkseEhs0TU9TXgRJTkZoRRkxTizyEg1LKUXfU3/78uqg==",
"cpu": [
"arm"
],
@@ -170,9 +170,9 @@
}
},
"node_modules/@rolldown/binding-linux-arm64-gnu": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.7.tgz",
- "integrity": "sha512-toOY2BChBZyuxU7OYX6Tn389di4IzAqPTycVcci0O7FSfBqzRB3RZn+K5Is6ANf4tmgRd/K1yZTsNTXbkXsnLg==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.14.tgz",
+ "integrity": "sha512-SD9kY8M009x/7s57Z1dgUVlP5+uYBgKQK0Tkr1WIWngrtUJmRCW1RJFMY7QDla2khXhmg2i5Io7MUjcmZNZ/KQ==",
"cpu": [
"arm64"
],
@@ -190,9 +190,9 @@
}
},
"node_modules/@rolldown/binding-linux-arm64-musl": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.7.tgz",
- "integrity": "sha512-lAIXTH/aiLRLxsTgQvfhjo4K1ydWIp00+V0voOr9beb/9ZmkUFrSIb03dXNFRgMNvkE6oGsF10ioQ6UsI+vS5Q==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.14.tgz",
+ "integrity": "sha512-BJ2CL19M6uuWesMgnqJzgxoI+N+eV7b0A9O9vLV42y+gitC41fNa8KElau1tHVzuLWX5GzEuxMPhAO0tQXQMkg==",
"cpu": [
"arm64"
],
@@ -210,9 +210,9 @@
}
},
"node_modules/@rolldown/binding-linux-ppc64-gnu": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.7.tgz",
- "integrity": "sha512-kdnwS28Pkenp/mZMRwjXXXwxQ7pIsm+bF919LUK93BOyhcLsrVKdP2p9fxpiPNPAbNuch8ypQt0pm2P2LYCAGg==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.14.tgz",
+ "integrity": "sha512-4+Kl8daPV8NDHaD7mfCcc1pRM+Qg7ab8DyMm5FG5WoZgv4h2i3KFN1CybYBNbQqmuYm7ftJLvmMI1eHYJ22S/Q==",
"cpu": [
"ppc64"
],
@@ -230,9 +230,9 @@
}
},
"node_modules/@rolldown/binding-linux-s390x-gnu": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.7.tgz",
- "integrity": "sha512-516OdsyLdr5E65paF3yBF55t8mfm9+gmtCsK3xI7XKXIT7EfRlHhxL8K/NR6Hu8BWSgF5+1w74lTL0+nxcc8Qw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.14.tgz",
+ "integrity": "sha512-V/h8ePq1fKDrmtFMz6xcCN3DKvuvMRrwwD1q0PkBeeo4DpK64biaKvqWGVxqCeYKqeRk7gE7/iKPxLCn08O97A==",
"cpu": [
"s390x"
],
@@ -250,9 +250,9 @@
}
},
"node_modules/@rolldown/binding-linux-x64-gnu": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.7.tgz",
- "integrity": "sha512-r8/z8n7GFaYRln3xmP1Cxy0HH/HLM0uBUPkEuSVEfKGDA89M0FsZRZJRSwe/tJjRx+fpH/gjorfhB8tmEbSFLA==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.14.tgz",
+ "integrity": "sha512-WxalXzgrLVpKC93xfpaJ3gCXUWzeCr+FRCbDVD2mUAy4L6Vo3lNVz0epUEUpxPWJkLNYUwM4OSIikv36OJ9mLg==",
"cpu": [
"x64"
],
@@ -270,9 +270,9 @@
}
},
"node_modules/@rolldown/binding-linux-x64-musl": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.7.tgz",
- "integrity": "sha512-pAsE8iiDxUg1xBqdhrTfg45AVDVpirjz00sblEYClGNNcMnDb+e8beQgqIAw6LvauX/APvgxUnwrgun/YYGBhw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.14.tgz",
+ "integrity": "sha512-3G3tnAmTpdk9jO3GQtyHXqeFD2SlecfTws/Y3M2mmj9nMBwwuLT4kur8sZKeu7ENUHSpVO3cIsm5A52LEWWwlg==",
"cpu": [
"x64"
],
@@ -290,9 +290,9 @@
}
},
"node_modules/@rolldown/binding-openharmony-arm64": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.7.tgz",
- "integrity": "sha512-lTcIYmmnQQA8Or/2DatS6oSqcdLHvendjS+zLu+FwgToynWMRSmQdpM65fTANJgIS4mjbMOo5KT2lnT9SAb96w==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.14.tgz",
+ "integrity": "sha512-qyr5XiNGxm2ytx17vvtcJ9nXn6v1gENETi503bJx3OGwZ1tSonj7BosxbMa/xeAfSl5iS9X6KjEWYXLu6v1L7Q==",
"cpu": [
"arm64"
],
@@ -307,9 +307,9 @@
}
},
"node_modules/@rolldown/binding-win32-arm64-msvc": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.7.tgz",
- "integrity": "sha512-e3Gu3WxbNk/UqQhxqU7YIYO+9ZBvWNz3U+h/qRFosscMFzdRPbXYSaSWgSnklv2fz1TgzBTcti2z35c/7irsHw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.14.tgz",
+ "integrity": "sha512-oA4o5o0S2yB199YyYXDzKUv1Z56Rc+mgOjwm7Z/vJ9Z8igiDPYvoOuDyo6g7AK/ZaF09nPhDKVnGBcYHO11GXA==",
"cpu": [
"arm64"
],
@@ -324,9 +324,9 @@
}
},
"node_modules/@rolldown/binding-win32-x64-msvc": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.7.tgz",
- "integrity": "sha512-W/jg5qoRSqjsEv0+dZi4e687mcHqmVuU0P4fK6qS/xjetW2Gmc1W8j//z5nAeNcC8Ttm0hV46IjcYeuVwYhuiw==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.14.tgz",
+ "integrity": "sha512-9mE94bf2GZUaR/fUSXCMpBoWkctu421Mi0ORpm4zqfbkjKep7RxzPFa5etcGs5h+2KApoWBOA/hAJa/7saGgEQ==",
"cpu": [
"x64"
],
@@ -534,9 +534,9 @@
}
},
"node_modules/fast-uri": {
- "version": "3.1.7",
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.7.tgz",
- "integrity": "sha512-dOvZVzjdZdz7phd9v6jCbwxrBW3fK6n8Rc0CtdmM4bumzMnxywBYhuph6J819RRw/ku+rLbelwfMunktuzVVHg==",
+ "version": "3.1.9",
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
+ "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
"dev": true,
"funding": [
{
@@ -1207,9 +1207,9 @@
}
},
"node_modules/nanoid": {
- "version": "3.3.18",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",
- "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",
+ "version": "3.3.20",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz",
+ "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==",
"dev": true,
"funding": [
{
@@ -1343,9 +1343,9 @@
}
},
"node_modules/postcss": {
- "version": "8.5.28",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz",
- "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==",
+ "version": "8.5.31",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.31.tgz",
+ "integrity": "sha512-YUbWYCgErwnMAVkjUnYa+KlMBzGpHwiIt/DE7f0G33AuX2LH9UcTk6KgWxd3zRU+pN3u/C+Xl3EnMLM4Hea7Sg==",
"dev": true,
"funding": [
{
@@ -1363,9 +1363,9 @@
],
"license": "MIT",
"dependencies": {
- "nanoid": "^3.3.18",
+ "nanoid": "^3.3.20",
"picocolors": "^1.1.1",
- "source-map-js": "^1.2.1"
+ "source-map-js": "^1.2.2"
},
"engines": {
"node": "^10 || ^12 || >=14"
@@ -1455,13 +1455,13 @@
}
},
"node_modules/rolldown": {
- "version": "1.2.7",
- "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.7.tgz",
- "integrity": "sha512-g0EtLvBjTUB7jhyV0S/TCup3v/XSVl45vUIGbOGU4QPiyjTenCe4mKuFvW9fEgYmS2Fo42AUssRmNuMziXdrig==",
+ "version": "1.2.14",
+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.14.tgz",
+ "integrity": "sha512-eTBTTqMR6uHKLgcUqpJP8ntzDI6V4LYA8negAMBEI7gkgVvOdrx6VsvS2Ym+83KhOPdLCHWJu0w7UQFJZhHKNw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@oxc-project/types": "=0.148.0",
+ "@oxc-project/types": "=0.154.0",
"@rolldown/pluginutils": "^1.0.0"
},
"bin": {
@@ -1471,21 +1471,21 @@
"node": "^20.19.0 || >=22.12.0"
},
"optionalDependencies": {
- "@rolldown/binding-android-arm-eabi": "1.2.7",
- "@rolldown/binding-android-arm64": "1.2.7",
- "@rolldown/binding-darwin-arm64": "1.2.7",
- "@rolldown/binding-darwin-x64": "1.2.7",
- "@rolldown/binding-freebsd-x64": "1.2.7",
- "@rolldown/binding-linux-arm-gnueabihf": "1.2.7",
- "@rolldown/binding-linux-arm64-gnu": "1.2.7",
- "@rolldown/binding-linux-arm64-musl": "1.2.7",
- "@rolldown/binding-linux-ppc64-gnu": "1.2.7",
- "@rolldown/binding-linux-s390x-gnu": "1.2.7",
- "@rolldown/binding-linux-x64-gnu": "1.2.7",
- "@rolldown/binding-linux-x64-musl": "1.2.7",
- "@rolldown/binding-openharmony-arm64": "1.2.7",
- "@rolldown/binding-win32-arm64-msvc": "1.2.7",
- "@rolldown/binding-win32-x64-msvc": "1.2.7"
+ "@rolldown/binding-android-arm-eabi": "1.2.14",
+ "@rolldown/binding-android-arm64": "1.2.14",
+ "@rolldown/binding-darwin-arm64": "1.2.14",
+ "@rolldown/binding-darwin-x64": "1.2.14",
+ "@rolldown/binding-freebsd-x64": "1.2.14",
+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.14",
+ "@rolldown/binding-linux-arm64-gnu": "1.2.14",
+ "@rolldown/binding-linux-arm64-musl": "1.2.14",
+ "@rolldown/binding-linux-ppc64-gnu": "1.2.14",
+ "@rolldown/binding-linux-s390x-gnu": "1.2.14",
+ "@rolldown/binding-linux-x64-gnu": "1.2.14",
+ "@rolldown/binding-linux-x64-musl": "1.2.14",
+ "@rolldown/binding-openharmony-arm64": "1.2.14",
+ "@rolldown/binding-win32-arm64-msvc": "1.2.14",
+ "@rolldown/binding-win32-x64-msvc": "1.2.14"
}
},
"node_modules/run-parallel": {
@@ -1551,9 +1551,9 @@
}
},
"node_modules/source-map-js": {
- "version": "1.2.1",
- "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
- "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
+ "version": "1.2.2",
+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
+ "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
@@ -1646,16 +1646,16 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
"node_modules/vite": {
- "version": "8.2.2",
- "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz",
- "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==",
+ "version": "8.3.5",
+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.5.tgz",
+ "integrity": "sha512-z1YpjieJ9g0ebTmQpLBv/oq9E3F9EIlOe+7LahW8SrE3LTiG3udBRUXQOlYXP9b+IC2q2phHeVxj9xGlw34OEQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"lightningcss": "^1.33.0",
- "picomatch": "^4.0.5",
- "postcss": "^8.5.26",
- "rolldown": "~1.2.4",
+ "picomatch": "^4.0.7",
+ "postcss": "^8.5.30",
+ "rolldown": "~1.2.14",
"tinyglobby": "^0.2.17"
},
"bin": {
@@ -1672,7 +1672,7 @@
},
"peerDependencies": {
"@types/node": "^20.19.0 || >=22.12.0",
- "@vitejs/devtools": "^0.4.0 || ^0.5.0",
+ "@vitejs/devtools": "^0.7.1 || ^0.8.0",
"esbuild": "^0.27.0 || ^0.28.0",
"jiti": ">=1.21.0",
"less": "^4.0.0",
diff --git a/package.json b/package.json
index a780061..06ce28f 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"devDependencies": {
"@vitejs/plugin-react": "^6.0.3",
"gh-pages": "^6.3.0",
- "vite": "^8.1.1",
+ "vite": "^8.3.5",
"zenodraft": "0.14.1"
}
}
diff --git a/src/App.jsx b/src/App.jsx
index 992b93b..b585f66 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,6 +1,8 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import JSZip from 'jszip';
import { MetadataForm } from './components/MetadataForm.jsx';
+import { AuthorCandidates, ContributorImportOptions } from './components/AuthorCandidates.jsx';
+import { findMatchingAuthorIndex } from './services/githubImporterAuthorCandidates.js';
import { normalizeMetadata } from './metadata/normalizeMetadata.js';
import { importGithubMetadata } from './services/githubImporter.js';
import { pickPreferredOrcidCandidate, searchOrcidCandidates } from './services/orcidSearch.js';
@@ -394,6 +396,11 @@ export default function App() {
const [form, setForm] = useState(initialForm);
const [githubUrl, setGithubUrl] = useState('');
const [githubToken, setGithubToken] = useState('');
+ const [contributorLimit, setContributorLimit] = useState('');
+ const [contributorSince, setContributorSince] = useState('');
+ const [contributorUntil, setContributorUntil] = useState('');
+ const [authorCandidates, setAuthorCandidates] = useState([]);
+ const [candidateCutoff, setCandidateCutoff] = useState({ since: '', until: '' });
const [importStatus, setImportStatus] = useState({ loading: false, warnings: [], errors: [], review: null, healthScan: [], comparisons: [] });
const [isZipping, setIsZipping] = useState(false);
const [isDownloadingCitation, setIsDownloadingCitation] = useState(false);
@@ -614,6 +621,33 @@ export default function App() {
}));
}
+ function toggleAuthorCandidate(candidate, checked) {
+ if (!checked) {
+ const index = findMatchingAuthorIndex(form.authors, candidate, authorCandidates);
+ if (index !== -1) {
+ removeAuthor(index);
+ }
+ return;
+ }
+
+ setForm((current) => {
+ if (findMatchingAuthorIndex(current.authors, candidate, authorCandidates) !== -1) {
+ return current;
+ }
+
+ const next = {
+ id: createAuthorId(),
+ givenNames: candidate.givenNames,
+ familyNames: candidate.familyNames,
+ orcid: candidate.orcid ?? '',
+ affiliation: candidate.affiliation ?? '',
+ };
+ const [first] = current.authors;
+ const onlyBlank = current.authors.length === 1 && !first.givenNames && !first.familyNames && !first.orcid;
+ return { ...current, authors: onlyBlank ? [next] : [...current.authors, next] };
+ });
+ }
+
function addAuthor() {
setForm((current) => ({
...current,
@@ -746,8 +780,10 @@ export default function App() {
try {
const result = await importGithubMetadata(repoUrl, {
- contributorFallbackLimit: 5,
authToken: githubToken.trim(),
+ ...(contributorLimit !== '' ? { contributorFallbackLimit: contributorLimit } : {}),
+ contributorSince,
+ contributorUntil,
});
if (importRequestIdRef.current !== requestId) {
@@ -794,6 +830,8 @@ export default function App() {
if (result.errors.length === 0) {
setForm(nextForm);
setOrcidSuggestions(nextSuggestions);
+ setAuthorCandidates(Array.isArray(result.authorCandidates) ? result.authorCandidates : []);
+ setCandidateCutoff({ since: result.contributorSince ?? '', until: result.contributorUntil ?? '' });
}
} catch (error) {
if (importRequestIdRef.current !== requestId) {
@@ -1185,6 +1223,14 @@ export default function App() {
autoComplete="off"
/>
+
Use a fine-grained token with public repository read access for higher API limits. This works even when the repository does not have a CITATION.cff file.
@@ -1243,6 +1289,14 @@ export default function App() {
autoComplete="off"
/>
+
{importStatus.loading ? 'Importing…' : 'Import GitHub metadata'}
@@ -1385,6 +1439,13 @@ export default function App() {
{activePage === 'generator' && (
<>
+
+ GitHub contributor options
+
+ Authors to credit automatically
+ onLimitChange(event.target.value)}
+ placeholder="5"
+ />
+
+
+ Ignore contributions before (optional)
+ onSinceChange(event.target.value)} />
+
+
+ Ignore contributions after (optional)
+ onUntilChange(event.target.value)} />
+
+
+ Everyone found is listed as a candidate you can add or remove. Set a date when a repository inherited
+ history from another project, or to stop at a release date; contributors with no commits in that range are not credited automatically.
+
+
+ );
+}
+
+export function AuthorCandidates({ candidates, authors, since, until, onToggle }) {
+ if (!Array.isArray(candidates) || candidates.length === 0) {
+ return null;
+ }
+
+ const isSelected = (candidate) => findMatchingAuthorIndex(authors, candidate, candidates) !== -1;
+ const selectedCount = candidates.filter(isSelected).length;
+
+ return (
+
+
+ GitHub author candidates
+
+ {selectedCount} of {candidates.length} selected. Commit counts show activity, not authorship; check
+ only the people who should be credited.
+ {since || until ? ` Contributors with no commits ${formatWindow(since, until)} are flagged.` : ''}
+
+
+
+
+ );
+}
diff --git a/src/services/github.examples.js b/src/services/github.examples.js
index 0e03713..52b97e7 100644
--- a/src/services/github.examples.js
+++ b/src/services/github.examples.js
@@ -74,20 +74,23 @@ export async function exampleWithRepositoryFileInspection() {
}
/**
- * Example: Custom contributor fallback limit
- * Adjusts how many top contributors by commit count are used as author fallback.
- * Default is 4; can be 1-20.
+ * Example: Custom contributor fallback limit and history cutoff
+ * Bounds the number of contributors credited automatically (0-50, default 5) and ignores
+ * contributors with no commits in the given date range (`contributorSince` / `contributorUntil`). Everyone else is still returned in
+ * `authorCandidates` with the reason they were surfaced.
*/
export async function exampleCustomContributorLimit() {
try {
const repoUrl = 'https://github.com/imageomics/OpenCite';
- // Increase contributor fallback to 10 instead of default 4
- const { metadata, warnings } = await importGithubMetadata(repoUrl, {
+ const { metadata, warnings, authorCandidates } = await importGithubMetadata(repoUrl, {
contributorFallbackLimit: 10,
+ contributorSince: '2025-01-01',
+ contributorUntil: '2025-12-31',
});
console.log('Authors (from contributor fallback):', metadata.authors);
+ console.log('Candidates to review:', authorCandidates);
console.log('Warnings:', warnings);
return { metadata };
diff --git a/src/services/githubApi.js b/src/services/githubApi.js
index 9e4376f..5ad5b0f 100644
--- a/src/services/githubApi.js
+++ b/src/services/githubApi.js
@@ -104,10 +104,13 @@ export function buildGithubReleaseListApiUrl(owner, repo, perPage = 1) {
return `${API_BASE}/repos/${owner}/${repo}/releases?per_page=${safePerPage}`;
}
-export function buildGithubCommitListApiUrl(owner, repo, defaultBranch = '', perPage = 1) {
+export function buildGithubCommitListApiUrl(owner, repo, defaultBranch = '', perPage = 1, page = null, since = '', until = '') {
const safePerPage = Number.isInteger(perPage) ? Math.min(Math.max(perPage, 1), 100) : 1;
const branchFilter = defaultBranch ? `&sha=${encodeURIComponent(defaultBranch)}` : '';
- return `${API_BASE}/repos/${owner}/${repo}/commits?per_page=${safePerPage}${branchFilter}`;
+ const pageFilter = Number.isInteger(page) && page > 1 ? `&page=${page}` : '';
+ const sinceFilter = since ? `&since=${encodeURIComponent(since)}` : '';
+ const untilFilter = until ? `&until=${encodeURIComponent(until)}` : '';
+ return `${API_BASE}/repos/${owner}/${repo}/commits?per_page=${safePerPage}${branchFilter}${sinceFilter}${untilFilter}${pageFilter}`;
}
export function buildGithubBranchApiUrl(owner, repo, branch) {
diff --git a/src/services/githubImporter.js b/src/services/githubImporter.js
index 3ce8ddf..5b752a1 100644
--- a/src/services/githubImporter.js
+++ b/src/services/githubImporter.js
@@ -28,11 +28,14 @@ import {
stripWrappingQuotes as utilStripWrappingQuotes,
} from './githubImporterUtils.js';
import {
- extractCoAuthorNamesFromCommitMessage,
fetchContributorAuthors,
resolveContributorFallbackLimit,
+ resolveContributorSince,
+ resolveContributorUntil,
} from './githubImporterContributors.js';
import { dedupeAuthors } from './githubImporterAuthors.js';
+import { scanCommitHistory } from './githubImporterCommitAuthors.js';
+import { buildAuthorCandidates } from './githubImporterAuthorCandidates.js';
import { addCitationConsistencyWarnings, mergeMetadata } from './githubImporterMerge.js';
export { addCitationConsistencyWarnings, mergeMetadata };
import {
@@ -510,13 +513,30 @@ function parseFile(path, text, warnings, errors) {
return null;
}
+const DEFAULT_AUTO_CREDIT_LIMIT = 5;
+const MIN_CANDIDATE_POOL = 10;
+
export async function importGithubMetadata(repoUrl, options = {}) {
const warnings = [];
const errors = [];
const emptyMetadata = createMetadata({ authors: [], keywords: [], references: [], grants: [] });
const authToken = resolveGithubToken(options);
const inspectRepositoryFiles = shouldInspectRepositoryFiles(options);
- const contributorFallbackLimit = resolveContributorFallbackLimit(options);
+ const requestedFallbackLimit = options.contributorFallbackLimit;
+ const contributorFallbackLimit = resolveContributorFallbackLimit({
+ contributorFallbackLimit: requestedFallbackLimit == null || requestedFallbackLimit === ''
+ ? DEFAULT_AUTO_CREDIT_LIMIT
+ : requestedFallbackLimit,
+ });
+ const contributorSince = resolveContributorSince(options.contributorSince);
+ let contributorUntil = resolveContributorUntil(options.contributorUntil);
+ if ((options.contributorSince && !contributorSince) || (options.contributorUntil && !contributorUntil)) {
+ addWarning(warnings, 'authors', 'invalid-contributor-cutoff', 'Ignored a contribution date because it is not a valid date.');
+ }
+ if (contributorSince && contributorUntil && contributorUntil < contributorSince) {
+ addWarning(warnings, 'authors', 'invalid-contributor-cutoff', 'Ignored the end date because it is before the start date.');
+ contributorUntil = '';
+ }
let owner;
let repo;
@@ -549,7 +569,7 @@ export async function importGithubMetadata(repoUrl, options = {}) {
);
const releaseData = Array.isArray(releaseList) && releaseList.length > 0 ? releaseList[0] : null;
const recentCommitPayload = await fetchOptionalJson(
- buildGithubCommitListApiUrl(owner, repo, defaultBranch, 10),
+ buildGithubCommitListApiUrl(owner, repo, defaultBranch, 100),
buildGithubRequestConfig({
authToken,
source: 'commits',
@@ -563,13 +583,6 @@ export async function importGithubMetadata(repoUrl, options = {}) {
authToken,
onWarning: (source, code, message, details = {}) => addWarning(warnings, source, code, message, details),
});
- const commitCoAuthorNames = Array.from(
- new Set(
- (Array.isArray(recentCommitPayload) ? recentCommitPayload : [])
- .flatMap((commit) => extractCoAuthorNamesFromCommitMessage(commit?.commit?.message ?? '')),
- ),
- );
-
const parsedFiles = {};
const fileContents = {};
@@ -707,8 +720,8 @@ export async function importGithubMetadata(repoUrl, options = {}) {
repo,
warnings,
authToken,
- contributorFallbackLimit,
- emitFallbackWarning: !hasPrimaryAuthors,
+ contributorFallbackLimit: Math.max(contributorFallbackLimit, MIN_CANDIDATE_POOL),
+ emitFallbackWarning: false,
cleanString,
normalizeAuthor,
normalizeAuthors,
@@ -716,16 +729,42 @@ export async function importGithubMetadata(repoUrl, options = {}) {
fetchOptionalJson,
extractOrcidFromGithubProfile,
});
- const coAuthorAuthors = normalizeAuthors(commitCoAuthorNames.map((name) => normalizeAuthor({ name })));
- const contributors = dedupeAuthors([
- ...coAuthorAuthors,
- ...contributorResult.fallbackAuthors.filter(Boolean),
- ]);
+ const commitHistory = await scanCommitHistory({
+ owner, repo, defaultBranch, initialCommits: recentCommitPayload,
+ knownGithubLogins: contributorResult.githubLogins,
+ since: contributorSince,
+ until: contributorUntil,
+ warnings, authToken, cleanString, addWarning, fetchOptionalJson,
+ });
+ const authorCandidates = buildAuthorCandidates({
+ contributorCandidates: contributorResult.candidates,
+ commitNames: commitHistory.names,
+ coAuthorNames: commitHistory.coAuthorNames,
+ loginCounts: commitHistory.loginCounts,
+ since: contributorSince,
+ until: contributorUntil,
+ autoCreditLimit: contributorFallbackLimit,
+ normalizeAuthor,
+ });
+ const autoCreditedAuthors = normalizeAuthors(
+ authorCandidates.filter((candidate) => candidate.autoSelected).map((candidate) => normalizeAuthor(candidate)),
+ );
+ const contributors = dedupeAuthors(autoCreditedAuthors);
const contributorLookupAuthors = dedupeAuthors([
- ...coAuthorAuthors,
...contributorResult.lookupAuthors.filter(Boolean),
+ ...normalizeAuthors(commitHistory.coAuthorNames.map((name) => normalizeAuthor({ name }))),
]);
+ if (!hasPrimaryAuthors && contributors.length > 0) {
+ addWarning(
+ warnings,
+ 'authors',
+ 'commit-based-fallback',
+ `Using ${contributors.length} GitHub contributor(s) as fallback authors. Review the author candidates below to choose who to credit.`,
+ { owner, repo },
+ );
+ }
+
addRateLimitHintIfNeeded(warnings, authToken);
if (!firstNonEmpty(citation?.authors, zenodo?.authors, packageMeta?.authors, contributors).length) {
@@ -813,6 +852,5 @@ export async function importGithubMetadata(repoUrl, options = {}) {
contributorLookupAuthors,
});
- return { metadata, warnings, errors, review, healthScan, comparisons };
+ return { metadata, warnings, errors, review, healthScan, comparisons, authorCandidates, contributorSince, contributorUntil };
}
-
diff --git a/src/services/githubImporterAuthorCandidates.js b/src/services/githubImporterAuthorCandidates.js
new file mode 100644
index 0000000..c41bbef
--- /dev/null
+++ b/src/services/githubImporterAuthorCandidates.js
@@ -0,0 +1,271 @@
+import { authorsLikelyMatch } from './githubImporterAuthors.js';
+import { normalizeOrcid } from '../utils/orcid.js';
+
+function normalizedNameKey(author) {
+ return [author.givenNames, author.familyNames].filter(Boolean).join(' ').toLowerCase();
+}
+
+function normalizedOrcid(author) {
+ return normalizeOrcid(author?.orcid).toLowerCase();
+}
+
+function firstGivenName(author) {
+ return String(author?.givenNames ?? '')
+ .toLowerCase()
+ .replace(/[^a-z0-9\s]/g, ' ')
+ .trim()
+ .split(/\s+/)[0] ?? '';
+}
+
+function firstGivenNamesMatch(author, candidate) {
+ const authorFirst = firstGivenName(author);
+ const candidateFirst = firstGivenName(candidate);
+ return authorFirst === candidateFirst
+ || (authorFirst.length === 1 && candidateFirst.startsWith(authorFirst))
+ || (candidateFirst.length === 1 && authorFirst.startsWith(candidateFirst));
+}
+
+function authorNamesMatch(author, candidate) {
+ return normalizedNameKey(author) === normalizedNameKey(candidate)
+ || (firstGivenNamesMatch(author, candidate) && authorsLikelyMatch(author, candidate));
+}
+
+function candidateKey(author) {
+ const name = normalizedNameKey(author);
+ const orcid = normalizedOrcid(author);
+ return orcid ? `${name}|orcid:${orcid}` : name;
+}
+
+// Uses the importer's fuzzy matcher so "Elizabeth G. Campolongo" counts as "Elizabeth Campolongo".
+export function findMatchingAuthorIndex(authors, candidate, candidates = []) {
+ const orcid = normalizedOrcid(candidate);
+ if (orcid) {
+ const orcidIndex = authors.findIndex((author) => normalizedOrcid(author) === orcid);
+ if (orcidIndex !== -1) {
+ return orcidIndex;
+ }
+ }
+
+ const matchingIndexes = authors.flatMap((author, index) => {
+ const authorOrcid = normalizedOrcid(author);
+ if (authorOrcid && orcid && authorOrcid !== orcid) {
+ return [];
+ }
+ if (!authorNamesMatch(author, candidate)) {
+ return [];
+ }
+
+ const exactUnidentifiedMatch = !orcid
+ && !authorOrcid
+ && normalizedNameKey(author) === normalizedNameKey(candidate);
+ const conflictingCandidate = !exactUnidentifiedMatch && candidates.some((other) => {
+ if (other === candidate || (other.id && other.id === candidate.id)) {
+ return false;
+ }
+ const otherOrcid = normalizedOrcid(other);
+ return otherOrcid
+ && otherOrcid !== orcid
+ && otherOrcid !== authorOrcid
+ && authorNamesMatch(author, other);
+ });
+ return conflictingCandidate ? [] : [index];
+ });
+
+ const identityPool = [...authors, ...candidates];
+ const candidateFirst = firstGivenName(candidate);
+ if (candidateFirst.length === 1) {
+ const distinctFullFirstNames = new Set(
+ identityPool
+ .filter((other) => authorNamesMatch(other, candidate))
+ .map(firstGivenName)
+ .filter((name) => name.length > 1)
+ );
+ if (distinctFullFirstNames.size > 1) {
+ return -1;
+ }
+ }
+
+ const ambiguousInitialMatch = matchingIndexes.some((index) => {
+ const author = authors[index];
+ const matchingFullFirstNames = new Set(
+ identityPool
+ .filter((other) => authorNamesMatch(author, other))
+ .map(firstGivenName)
+ .filter((name) => name.length > 1)
+ );
+ return matchingFullFirstNames.size > 1;
+ });
+ if (ambiguousInitialMatch) {
+ return -1;
+ }
+
+ const exactNameMatches = matchingIndexes.filter((index) => normalizedNameKey(authors[index]) === normalizedNameKey(candidate));
+ if (exactNameMatches.length === 1) {
+ return exactNameMatches[0];
+ }
+
+ const distinctOrcids = new Set(matchingIndexes.map((index) => normalizedOrcid(authors[index])).filter(Boolean));
+ if (!orcid && distinctOrcids.size > 1) {
+ return matchingIndexes.find((index) => !normalizedOrcid(authors[index])) ?? -1;
+ }
+ return matchingIndexes[0] ?? -1;
+}
+
+export function formatWindow(since, until) {
+ const from = since ? since.split('T')[0] : '';
+ const to = until ? until.split('T')[0] : '';
+ if (from && to) {
+ return `between ${from} and ${to}`;
+ }
+ return from ? `since ${from}` : `until ${to}`;
+}
+
+function plural(count, word) {
+ return `${count} ${word}${count === 1 ? '' : 's'}`;
+}
+
+/**
+ * Merges every GitHub-derived person into one reviewable candidate list and decides who is
+ * credited automatically. Contributors are ranked by all-time contribution count, which is
+ * only a hint; commit-history names are never credited automatically.
+ */
+export function buildAuthorCandidates({
+ contributorCandidates = [],
+ commitNames = [],
+ coAuthorNames = [],
+ loginCounts = new Map(),
+ since = '',
+ until = '',
+ autoCreditLimit,
+ normalizeAuthor,
+}) {
+ const windowLabel = formatWindow(since, until);
+ const byKey = new Map();
+ const byOrcid = new Map();
+
+ function upsert(author, { source, reason, autoSelected = false, order, ...details }) {
+ if (!author) {
+ return;
+ }
+
+ const nameKey = normalizedNameKey(author);
+ const orcidKey = normalizedOrcid(author);
+ if (!nameKey) {
+ return;
+ }
+
+ const sameNameCandidates = [...byKey.values()].filter((candidate) => authorNamesMatch(candidate, author));
+ let existing = orcidKey ? byOrcid.get(orcidKey) : null;
+ if (!existing && sameNameCandidates.length === 1) {
+ const sameNameCandidate = sameNameCandidates[0];
+ const existingOrcid = normalizedOrcid(sameNameCandidate);
+ if (!orcidKey || !existingOrcid) {
+ existing = sameNameCandidate;
+ }
+ }
+
+ if (existing) {
+ existing.order = Math.min(existing.order, order);
+ existing.sources.push(source);
+ existing.reasons.push(reason);
+ existing.autoSelected = existing.autoSelected || autoSelected;
+ existing.orcid ||= author.orcid;
+ existing.affiliation ||= author.affiliation;
+ Object.assign(existing, details);
+ const updatedKey = candidateKey(existing);
+ if (updatedKey !== existing.id) {
+ byKey.delete(existing.id);
+ existing.id = updatedKey;
+ byKey.set(updatedKey, existing);
+ }
+ if (orcidKey) {
+ byOrcid.set(orcidKey, existing);
+ }
+ return;
+ }
+
+ const baseKey = !orcidKey && sameNameCandidates.length > 1
+ ? `${nameKey}|ambiguous:${sameNameCandidates.length + 1}`
+ : candidateKey(author);
+ let key = baseKey;
+ let suffix = 2;
+ while (byKey.has(key)) {
+ key = `${baseKey}|${suffix}`;
+ suffix += 1;
+ }
+ const candidate = {
+ id: key,
+ order,
+ givenNames: author.givenNames,
+ familyNames: author.familyNames,
+ orcid: author.orcid,
+ affiliation: author.affiliation,
+ sources: [source],
+ reasons: [reason],
+ autoSelected,
+ ...details,
+ };
+ byKey.set(key, candidate);
+ if (orcidKey) {
+ byOrcid.set(orcidKey, candidate);
+ }
+ }
+
+ const records = coAuthorNames.map((name) => ({
+ author: normalizeAuthor({ name }),
+ source: 'co-author',
+ reason: 'Named in a Co-authored-by trailer in recent commits',
+ autoSelected: true,
+ }));
+
+ let credited = 0;
+ for (const { author, login, contributions } of contributorCandidates) {
+ const hasWindow = Boolean(since || until);
+ const recentCommits = hasWindow ? (loginCounts.get(login.toLowerCase()) ?? 0) : null;
+ const withinWindow = !hasWindow || recentCommits > 0;
+ const autoSelected = withinWindow && credited < autoCreditLimit;
+ if (autoSelected) {
+ credited += 1;
+ }
+
+ const parts = [`GitHub contributor @${login}`, plural(contributions, 'commit')];
+ if (hasWindow) {
+ parts.push(recentCommits > 0
+ ? `${recentCommits} ${windowLabel}`
+ : `none found ${windowLabel} (may be outside the relevant history)`);
+ }
+
+ records.push({ author, source: 'github-contributor', reason: parts.join(' · '), autoSelected, login, contributions, recentCommits });
+ }
+
+ for (const { name, commits, lastCommitDate } of commitNames) {
+ const last = lastCommitDate ? ` · last ${lastCommitDate.split('T')[0]}` : '';
+ records.push({
+ author: normalizeAuthor({ name }),
+ source: 'commit-history',
+ reason: `Commit author name · ${plural(commits, 'scanned commit')}${last}`,
+ commitHistoryCommits: commits,
+ });
+ }
+
+ records.forEach((record, order) => {
+ record.order = order;
+ });
+ records.sort((left, right) => {
+ const leftIsInitial = firstGivenName(left.author).length === 1;
+ const rightIsInitial = firstGivenName(right.author).length === 1;
+ return Number(leftIsInitial) - Number(rightIsInitial) || left.order - right.order;
+ });
+ for (const record of records) {
+ const { author, ...details } = record;
+ upsert(author, details);
+ }
+
+ return [...byKey.values()]
+ .sort((left, right) => left.order - right.order)
+ .map(({ order, sources, reasons, ...candidate }) => ({
+ ...candidate,
+ sources,
+ reason: reasons.join('; '),
+ }));
+}
diff --git a/src/services/githubImporterAuthors.js b/src/services/githubImporterAuthors.js
index 65dee34..4e8dbd9 100644
--- a/src/services/githubImporterAuthors.js
+++ b/src/services/githubImporterAuthors.js
@@ -76,7 +76,7 @@ export function authorsLikelyMatch(sourceAuthor, contributorAuthor) {
export function enrichAuthorsWithContributorData(sourceAuthors, contributorAuthors) {
const normalizedSourceAuthors = normalizeAuthors(Array.isArray(sourceAuthors) ? sourceAuthors : []);
if (normalizedSourceAuthors.length === 0) {
- return normalizeAuthors(Array.isArray(contributorAuthors) ? contributorAuthors : []);
+ return [];
}
const normalizedContributorAuthors = normalizeAuthors(Array.isArray(contributorAuthors) ? contributorAuthors : []);
diff --git a/src/services/githubImporterCommitAuthors.js b/src/services/githubImporterCommitAuthors.js
new file mode 100644
index 0000000..dd27366
--- /dev/null
+++ b/src/services/githubImporterCommitAuthors.js
@@ -0,0 +1,102 @@
+import { buildGithubCommitListApiUrl, buildGithubRequestConfig } from './githubApi.js';
+import { extractCoAuthorNamesFromCommitMessage, isAutomatedContributorIdentity } from './githubImporterContributors.js';
+import { dedupeAuthors } from './githubImporterAuthors.js';
+
+const COMMIT_PAGE_SIZE = 100;
+const UNAUTHENTICATED_PAGE_LIMIT = 1;
+const AUTHENTICATED_PAGE_LIMIT = 10;
+
+function isUsableCommitName(name, login, knownLogins, cleanString) {
+ const normalized = name.toLowerCase();
+ if (!name || normalized === String(login ?? '').toLowerCase() || knownLogins.has(normalized)) {
+ return false;
+ }
+ if (
+ /\d/.test(name)
+ || /[_@]/.test(name)
+ || isAutomatedContributorIdentity(name, cleanString)
+ || isAutomatedContributorIdentity(login, cleanString)
+ ) {
+ return false;
+ }
+ if (!/\s/.test(name) && name.includes('-') && !name.split('-').every((segment) => /^[A-Z][a-z]+$/.test(segment))) {
+ return false;
+ }
+ return true;
+}
+
+/**
+ * Scans a bounded window of commit history. Returns usable human author names (with commit
+ * counts and last-seen dates) plus per-login commit counts, so callers can tell who was
+ * active inside an optional `since`/`until` window.
+ */
+export async function scanCommitHistory({
+ owner, repo, defaultBranch, initialCommits = [], knownGithubLogins = [], since = '', until = '',
+ warnings, authToken = '', cleanString, addWarning, fetchOptionalJson,
+}) {
+ const knownLogins = new Set(knownGithubLogins.map((login) => cleanString(login).toLowerCase()));
+ const names = new Map();
+ const loginCounts = new Map();
+ const coAuthorNames = new Set();
+ const maxPages = authToken ? AUTHENTICATED_PAGE_LIMIT : UNAUTHENTICATED_PAGE_LIMIT;
+ // Initial commits come from an unfiltered request, so a date range needs its own first page.
+ let commits = (since || until) ? null : (Array.isArray(initialCommits) ? initialCommits : []);
+ let page = 1;
+
+ const fetchPage = async (pageNumber) => {
+ const result = await fetchOptionalJson(
+ buildGithubCommitListApiUrl(owner, repo, defaultBranch, COMMIT_PAGE_SIZE, pageNumber, since, until),
+ buildGithubRequestConfig({
+ authToken,
+ source: 'commit-authors',
+ label: `commit authors page ${pageNumber}`,
+ onWarning: (source, code, message, details = {}) => addWarning(warnings, source, code, message, details),
+ }),
+ );
+ return Array.isArray(result) ? result : [];
+ };
+
+ if (commits === null) {
+ commits = await fetchPage(1);
+ }
+
+ while (true) {
+ for (const commit of commits) {
+ const name = cleanString(commit?.commit?.author?.name ?? '');
+ const login = cleanString(commit?.author?.login ?? '');
+ const date = cleanString(commit?.commit?.author?.date ?? '');
+ for (const coAuthorName of extractCoAuthorNamesFromCommitMessage(commit?.commit?.message ?? '')) {
+ coAuthorNames.add(coAuthorName);
+ }
+ if (commit?.author?.type && commit.author.type !== 'User') continue;
+ if (login) {
+ loginCounts.set(login.toLowerCase(), (loginCounts.get(login.toLowerCase()) ?? 0) + 1);
+ }
+ if (isUsableCommitName(name, login, knownLogins, cleanString)) {
+ const entry = names.get(name) ?? { name, login, commits: 0, lastCommitDate: '' };
+ entry.commits += 1;
+ if (date > entry.lastCommitDate) entry.lastCommitDate = date;
+ names.set(name, entry);
+ }
+ }
+
+ if (commits.length < COMMIT_PAGE_SIZE) break;
+ if (page >= maxPages) {
+ addWarning(warnings, 'commit-authors', 'commit-author-scan-limited',
+ `Scanned the first ${page * COMMIT_PAGE_SIZE} commits for contributor author names.`,
+ { owner, repo, scannedPages: page, scannedCommits: page * COMMIT_PAGE_SIZE });
+ break;
+ }
+
+ page += 1;
+ commits = await fetchPage(page);
+ if (commits.length === 0) break;
+ }
+
+ return { names: [...names.values()], loginCounts, coAuthorNames: [...coAuthorNames] };
+}
+
+export async function fetchCommitAuthors({ normalizeAuthor, normalizeAuthors, ...scanOptions }) {
+ const { names } = await scanCommitHistory(scanOptions);
+ return dedupeAuthors(normalizeAuthors(names.map(({ name }) => normalizeAuthor({ name }))));
+}
\ No newline at end of file
diff --git a/src/services/githubImporterContributors.js b/src/services/githubImporterContributors.js
index 3c63d18..cbec608 100644
--- a/src/services/githubImporterContributors.js
+++ b/src/services/githubImporterContributors.js
@@ -6,11 +6,16 @@ import {
} from './githubApi.js';
import { dedupeAuthors } from './githubImporterAuthors.js';
-const TOP_CONTRIBUTOR_FALLBACK_LIMIT = 4;
-const MAX_CONTRIBUTOR_FALLBACK_LIMIT = 20;
+const DEFAULT_CONTRIBUTOR_FALLBACK_LIMIT = 50;
+const MAX_CONTRIBUTOR_FALLBACK_LIMIT = 50;
+const CONTRIBUTOR_CANDIDATE_EXAMINATION_OVERHEAD = 20;
+const MAX_CONTRIBUTOR_CANDIDATE_EXAMINATION = 70;
+const UNAUTHENTICATED_CONTRIBUTOR_CANDIDATE_EXAMINATION_LIMIT = 25;
+const UNAUTHENTICATED_CONTRIBUTOR_PAGE_LIMIT = 2;
+const AUTHENTICATED_CONTRIBUTOR_PAGE_LIMIT = 10;
const GITHUB_PAGE_SIZE = 100;
-function isAutomatedContributorIdentity(value, cleanString) {
+export function isAutomatedContributorIdentity(value, cleanString) {
const text = cleanString(value ?? '').trim();
if (!text) {
return false;
@@ -120,6 +125,15 @@ function isAutomatedContributor(contributor, profile, cleanString) {
async function fetchAllContributors(owner, repo, warnings, authToken, maxContributors, { fetchOptionalJson, addWarning }) {
const contributors = [];
let page = 1;
+ const maxPages = authToken ? AUTHENTICATED_CONTRIBUTOR_PAGE_LIMIT : UNAUTHENTICATED_CONTRIBUTOR_PAGE_LIMIT;
+ const sortByContributionCount = (left, right) => {
+ const leftCount = Number(left?.contributions);
+ const rightCount = Number(right?.contributions);
+ if (Number.isFinite(leftCount) && Number.isFinite(rightCount) && leftCount !== rightCount) {
+ return rightCount - leftCount;
+ }
+ return 0;
+ };
while (true) {
const pageContributors = await fetchOptionalJson(
@@ -136,38 +150,71 @@ async function fetchAllContributors(owner, repo, warnings, authToken, maxContrib
break;
}
- contributors.push(...pageContributors);
+ const eligiblePageContributors = pageContributors.filter((contributor) => !isAutomatedContributor(contributor, null, (value) => String(value ?? '')));
+ const excludedAutomatedCount = pageContributors.length - eligiblePageContributors.length;
+ if (excludedAutomatedCount > 0) {
+ addWarning(warnings, 'authors', 'automated-contributors-excluded',
+ `Excluded ${excludedAutomatedCount} automated account(s) from fallback authors.`, { owner, repo });
+ }
+ contributors.push(...eligiblePageContributors);
- if (maxContributors && contributors.length >= maxContributors) {
- return contributors.slice(0, maxContributors);
+ if (contributors.length >= maxContributors) {
+ return contributors.sort(sortByContributionCount).slice(0, maxContributors);
}
if (pageContributors.length < GITHUB_PAGE_SIZE) {
break;
}
+ if (page >= maxPages) {
+ addWarning(warnings, 'authors', 'contributor-scan-limited',
+ `Scanned the first ${page * GITHUB_PAGE_SIZE} contributor entries; stopped after ${page} pages to limit API requests.`,
+ { owner, repo, scannedPages: page, scannedContributors: page * GITHUB_PAGE_SIZE });
+ break;
+ }
+
page += 1;
}
- return contributors;
+ return contributors.sort(sortByContributionCount);
}
export function resolveContributorFallbackLimit(options = {}) {
- if (!Object.prototype.hasOwnProperty.call(options, 'contributorFallbackLimit')) {
- return TOP_CONTRIBUTOR_FALLBACK_LIMIT;
+ const rawLimit = options?.contributorFallbackLimit;
+ if (rawLimit === undefined || rawLimit === null || rawLimit === '') {
+ return DEFAULT_CONTRIBUTOR_FALLBACK_LIMIT;
}
+ const limit = Number(rawLimit);
+ return Number.isFinite(limit)
+ ? Math.min(MAX_CONTRIBUTOR_FALLBACK_LIMIT, Math.max(0, Math.trunc(limit)))
+ : DEFAULT_CONTRIBUTOR_FALLBACK_LIMIT;
+}
- if (options.contributorFallbackLimit == null || options.contributorFallbackLimit === '') {
- return null;
+// Accepts a YYYY-MM-DD date (or a full ISO timestamp) and returns an ISO string, or '' if unusable.
+// A plain end date is inclusive, so it resolves to the end of that day.
+function resolveContributorDate(value, endOfDay = false) {
+ const text = String(value ?? '').trim();
+ if (!text) {
+ return '';
}
- const rawLimit = Number(options.contributorFallbackLimit);
-
- if (!Number.isFinite(rawLimit)) {
- return TOP_CONTRIBUTOR_FALLBACK_LIMIT;
+ const isPlainDate = /^\d{4}-\d{2}-\d{2}$/.test(text);
+ const date = isPlainDate ? new Date(`${text}T${endOfDay ? '23:59:59' : '00:00:00'}Z`) : new Date(text);
+ if (Number.isNaN(date.getTime())) {
+ return '';
+ }
+ if (isPlainDate && date.toISOString().slice(0, 10) !== text) {
+ return '';
}
+ return date.toISOString().replace('.000Z', 'Z');
+}
+
+export function resolveContributorSince(value) {
+ return resolveContributorDate(value);
+}
- return Math.min(Math.max(Math.trunc(rawLimit), 1), MAX_CONTRIBUTOR_FALLBACK_LIMIT);
+export function resolveContributorUntil(value) {
+ return resolveContributorDate(value, true);
}
export function extractCoAuthorNamesFromCommitMessage(message) {
@@ -200,7 +247,7 @@ export async function fetchContributorAuthors({
repo,
warnings,
authToken = '',
- contributorFallbackLimit = TOP_CONTRIBUTOR_FALLBACK_LIMIT,
+ contributorFallbackLimit = DEFAULT_CONTRIBUTOR_FALLBACK_LIMIT,
emitFallbackWarning = true,
cleanString,
normalizeAuthor,
@@ -209,7 +256,17 @@ export async function fetchContributorAuthors({
fetchOptionalJson,
extractOrcidFromGithubProfile,
}) {
- const contributors = await fetchAllContributors(owner, repo, warnings, authToken, null, {
+ const safeContributorFallbackLimit = resolveContributorFallbackLimit({ contributorFallbackLimit });
+ const candidateExaminationCeiling = authToken
+ ? MAX_CONTRIBUTOR_CANDIDATE_EXAMINATION
+ : UNAUTHENTICATED_CONTRIBUTOR_CANDIDATE_EXAMINATION_LIMIT;
+ const candidateExaminationLimit = safeContributorFallbackLimit === 0
+ ? 0
+ : Math.min(candidateExaminationCeiling, safeContributorFallbackLimit + CONTRIBUTOR_CANDIDATE_EXAMINATION_OVERHEAD);
+ if (candidateExaminationLimit === 0) {
+ return { fallbackAuthors: [], lookupAuthors: [], candidates: [] };
+ }
+ const contributors = await fetchAllContributors(owner, repo, warnings, authToken, candidateExaminationLimit, {
fetchOptionalJson,
addWarning,
});
@@ -218,6 +275,7 @@ export async function fetchContributorAuthors({
return {
fallbackAuthors: [],
lookupAuthors: [],
+ candidates: [],
};
}
@@ -226,8 +284,8 @@ export async function fetchContributorAuthors({
warnings,
'authors',
'commit-based-fallback',
- contributorFallbackLimit
- ? `Using top ${contributorFallbackLimit} contributors as fallback authors.`
+ safeContributorFallbackLimit
+ ? `Using top ${safeContributorFallbackLimit} contributors as fallback authors.`
: 'Using contributors as fallback authors.',
{ owner, repo },
);
@@ -273,23 +331,23 @@ export async function fetchContributorAuthors({
contributor,
profile: null,
socialAccounts: [],
- author: /\d/.test(login)
- ? null
- : normalizeAuthor({ name: login }),
+ author: null,
autoFilledOrcid: false,
excludedAutomated: false,
};
}
- const socialAccounts = await fetchOptionalJson(
- buildGithubUserSocialAccountsApiUrl(login),
- buildGithubRequestConfig({
- authToken,
- source: 'contributor-profile-links',
- label: `the profile links for ${login}`,
- onWarning: (source, code, message, details = {}) => addWarning(warnings, source, code, message, details),
- }),
- ) || [];
+ const socialAccounts = authToken
+ ? await fetchOptionalJson(
+ buildGithubUserSocialAccountsApiUrl(login),
+ buildGithubRequestConfig({
+ authToken,
+ source: 'contributor-profile-links',
+ label: `the profile links for ${login}`,
+ onWarning: (source, code, message, details = {}) => addWarning(warnings, source, code, message, details),
+ }),
+ ) || []
+ : [];
if (isAutomatedContributor(contributor, profile, cleanString)) {
return {
@@ -304,7 +362,7 @@ export async function fetchContributorAuthors({
let profileOrcid = extractOrcidFromGithubProfile(profile, socialAccounts);
- if (profile?.name) {
+ if (profile?.name && cleanString(profile.name).toLowerCase() !== login.toLowerCase()) {
return {
contributor,
profile,
@@ -319,27 +377,12 @@ export async function fetchContributorAuthors({
};
}
- if (/\d/.test(login)) {
- return {
- contributor,
- profile,
- socialAccounts,
- author: null,
- autoFilledOrcid: false,
- excludedAutomated: false,
- };
- }
-
return {
contributor,
profile,
socialAccounts,
- author: normalizeAuthor({
- name: login,
- affiliation: '',
- orcid: profileOrcid,
- }),
- autoFilledOrcid: Boolean(profileOrcid),
+ author: null,
+ autoFilledOrcid: false,
excludedAutomated: false,
};
}),
@@ -368,12 +411,22 @@ export async function fetchContributorAuthors({
}
const fallbackAuthors = profiles
- .slice(0, contributorFallbackLimit ?? profiles.length)
- .map((entry) => entry?.author);
+ .filter((entry) => !entry?.excludedAutomated)
+ .map((entry) => entry?.author)
+ .filter(Boolean)
+ .slice(0, safeContributorFallbackLimit);
const lookupAuthors = profiles.map((entry) => entry?.author);
return {
fallbackAuthors: dedupeAuthors(normalizeAuthors(fallbackAuthors)),
lookupAuthors: dedupeAuthors(normalizeAuthors(lookupAuthors)),
+ githubLogins: contributors.map((contributor) => cleanString(contributor?.login ?? '').toLowerCase()).filter(Boolean),
+ candidates: profiles
+ .filter((entry) => !entry?.excludedAutomated && entry?.author)
+ .map((entry) => ({
+ author: entry.author,
+ login: cleanString(entry.contributor?.login ?? ''),
+ contributions: Number(entry.contributor?.contributions) || 0,
+ })),
};
}
diff --git a/src/services/githubImporterMerge.js b/src/services/githubImporterMerge.js
index f3b2caf..80cb484 100644
--- a/src/services/githubImporterMerge.js
+++ b/src/services/githubImporterMerge.js
@@ -12,7 +12,6 @@ import {
import {
dedupeAuthors,
enrichAuthorsWithContributorData,
- orderAuthorsByContributorRank,
} from './githubImporterAuthors.js';
function addWarning(warnings, source, code, message) {
@@ -64,11 +63,10 @@ export function mergeMetadata({
const grants = normalizeGrants(firstNonEmpty(zenodo?.grants));
const enrichedAuthors = enrichAuthorsWithContributorData(authors, contributorLookupAuthors);
const dedupedAuthors = dedupeAuthors(enrichedAuthors);
- const orderedAuthors = orderAuthorsByContributorRank(dedupedAuthors, contributorLookupAuthors);
return createMetadata({
title: cleanString(firstNonEmpty(citation?.title, zenodo?.title, packageMeta?.title, repo?.name)),
- authors: orderedAuthors,
+ authors: dedupedAuthors,
keywords,
license: cleanString(firstNonEmpty(citation?.license, zenodo?.license, packageMeta?.license, repo?.license?.spdx_id)),
typeOfWork: mapTypeOfWork(firstNonEmpty(zenodo?.typeOfWork, citation?.typeOfWork, 'software')),
diff --git a/src/styles.css b/src/styles.css
index 9f9bec3..9a14ab8 100644
--- a/src/styles.css
+++ b/src/styles.css
@@ -716,6 +716,49 @@ select::-ms-expand {
margin-bottom: 22px;
}
+.contributor-options {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: 12px;
+ margin: 12px 0 0;
+ padding: 10px 12px;
+ border: 1px solid var(--border-color, #d0d7de);
+ border-radius: 8px;
+}
+
+.contributor-options .import-note {
+ grid-column: 1 / -1;
+ margin: 0;
+}
+
+.candidate-list {
+ display: grid;
+ gap: 6px;
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+.candidate-row {
+ display: flex;
+ align-items: flex-start;
+ gap: 10px;
+ padding: 8px 10px;
+ border: 1px solid var(--border-color, #d0d7de);
+ border-radius: 8px;
+ cursor: pointer;
+}
+
+.candidate-row input {
+ margin-top: 4px;
+ width: auto;
+}
+
+.candidate-row small {
+ display: block;
+ color: var(--text-secondary);
+}
+
.import-note {
margin: 10px 0 0;
color: var(--text-secondary);
diff --git a/tests/services/authorCandidates.test.js b/tests/services/authorCandidates.test.js
new file mode 100644
index 0000000..8ef5992
--- /dev/null
+++ b/tests/services/authorCandidates.test.js
@@ -0,0 +1,302 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+
+import { buildAuthorCandidates, findMatchingAuthorIndex } from '../../src/services/githubImporterAuthorCandidates.js';
+import { scanCommitHistory } from '../../src/services/githubImporterCommitAuthors.js';
+import { resolveContributorSince, resolveContributorUntil } from '../../src/services/githubImporterContributors.js';
+import { cleanString, normalizeAuthor } from '../../src/services/githubImporterUtils.js';
+
+const contributor = (name, login, contributions, orcid = '') => ({ author: normalizeAuthor({ name, orcid }), login, contributions });
+const fullName = (candidate) => `${candidate.givenNames} ${candidate.familyNames}`;
+
+test('only the top contributors up to the limit are credited automatically', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [
+ contributor('Ada Lovelace', 'ada', 50),
+ contributor('Grace Hopper', 'grace', 20),
+ contributor('Alan Turing', 'alan', 5),
+ ],
+ autoCreditLimit: 2,
+ normalizeAuthor,
+ });
+
+ assert.deepEqual(candidates.map((candidate) => [fullName(candidate), candidate.autoSelected]), [
+ ['Ada Lovelace', true],
+ ['Grace Hopper', true],
+ ['Alan Turing', false],
+ ]);
+ assert.match(candidates[0].reason, /GitHub contributor @ada · 50 commits/);
+});
+
+test('fallback author order follows contributor rank when names include initials', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [
+ contributor('J. Doe', 'j-doe', 100),
+ contributor('Ada Lovelace', 'ada', 50),
+ ],
+ autoCreditLimit: 2,
+ normalizeAuthor,
+ });
+
+ assert.deepEqual(candidates.map(fullName), ['J Doe', 'Ada Lovelace']);
+ assert.deepEqual(candidates.map((candidate) => candidate.autoSelected), [true, true]);
+});
+
+test('a cutoff skips contributors with no commits in the window and explains why', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [contributor('Old Maintainer', 'old', 900), contributor('New Author', 'new', 12)],
+ loginCounts: new Map([['new', 7]]),
+ since: '2025-01-01T00:00:00Z',
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ const [old, recent] = candidates;
+ assert.equal(old.autoSelected, false);
+ assert.match(old.reason, /none found since 2025-01-01/);
+ assert.equal(recent.autoSelected, true);
+ assert.match(recent.reason, /7 since 2025-01-01/);
+});
+
+test('commit-history names are candidates but never credited automatically, and merge with contributors', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [contributor('Ada Lovelace', 'ada', 3)],
+ commitNames: [
+ { name: 'Ada Lovelace', commits: 4, lastCommitDate: '2026-02-03T10:00:00Z' },
+ { name: 'Dana Example', commits: 2, lastCommitDate: '' },
+ ],
+ coAuthorNames: ['Pair Partner'],
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ const byName = Object.fromEntries(candidates.map((candidate) => [fullName(candidate), candidate]));
+ assert.deepEqual(byName['Ada Lovelace'].sources, ['github-contributor', 'commit-history']);
+ assert.equal(byName['Dana Example'].autoSelected, false);
+ assert.equal(byName['Pair Partner'].autoSelected, true);
+ assert.equal(candidates.length, 3);
+});
+
+test('commit scans with a cutoff request the filtered first page and count logins', async () => {
+ const urls = [];
+ const result = await scanCommitHistory({
+ owner: 'o', repo: 'r', defaultBranch: 'main', since: '2025-01-01T00:00:00Z',
+ initialCommits: [{ commit: { author: { name: 'Ignored Unfiltered' } }, author: { login: 'ignored', type: 'User' } }],
+ warnings: [], cleanString, addWarning: () => {},
+ fetchOptionalJson: async (url) => {
+ urls.push(url);
+ return [
+ { commit: { author: { name: 'Ada Lovelace', date: '2026-01-02T00:00:00Z' } }, author: { login: 'ada', type: 'User' } },
+ { commit: { author: { name: 'Ada Lovelace', date: '2026-03-04T00:00:00Z' } }, author: { login: 'ada', type: 'User' } },
+ ];
+ },
+ });
+
+ assert.deepEqual(urls, ['https://api.github.com/repos/o/r/commits?per_page=100&sha=main&since=2025-01-01T00%3A00%3A00Z']);
+ assert.equal(result.loginCounts.get('ada'), 2);
+ assert.deepEqual(result.names.map(({ name, commits, lastCommitDate }) => [name, commits, lastCommitDate]), [
+ ['Ada Lovelace', 2, '2026-03-04T00:00:00Z'],
+ ]);
+});
+
+test('resolveContributorSince accepts dates and rejects garbage', () => {
+ assert.equal(resolveContributorSince('2025-06-01'), '2025-06-01T00:00:00Z');
+ assert.equal(resolveContributorSince(''), '');
+ assert.equal(resolveContributorSince('not a date'), '');
+ assert.equal(resolveContributorSince('2025-02-30'), '');
+ assert.equal(resolveContributorUntil('2025-02-30'), '');
+});
+
+test('findMatchingAuthorIndex treats a middle initial as the same person', () => {
+ const authors = [
+ { givenNames: 'Elizabeth G.', familyNames: 'Campolongo' },
+ { givenNames: 'Matthew J.', familyNames: 'Thompson' },
+ ];
+ const candidate = (name) => ({ id: name.toLowerCase(), ...normalizeAuthor({ name }) });
+
+ assert.equal(findMatchingAuthorIndex(authors, candidate('Elizabeth Campolongo')), 0);
+ assert.equal(findMatchingAuthorIndex(authors, candidate('Matthew Thompson')), 1);
+ assert.equal(findMatchingAuthorIndex(authors, candidate('Dana Example')), -1);
+});
+
+test('findMatchingAuthorIndex matches a full first name to an unambiguous initial', () => {
+ const authors = [{ givenNames: 'J.', familyNames: 'Doe', orcid: '' }];
+
+ assert.equal(findMatchingAuthorIndex(authors, normalizeAuthor({ name: 'Jane Doe' })), 0);
+});
+
+test('findMatchingAuthorIndex leaves an initial ambiguous between full namesakes', () => {
+ const authors = [
+ { givenNames: 'Jane', familyNames: 'Doe', orcid: '' },
+ { givenNames: 'John', familyNames: 'Doe', orcid: '' },
+ ];
+
+ assert.equal(findMatchingAuthorIndex(authors, normalizeAuthor({ name: 'J. Doe' })), -1);
+});
+
+test('findMatchingAuthorIndex does not map multiple full-name candidates to one initial-only author', () => {
+ const authors = [{ givenNames: 'J.', familyNames: 'Doe', orcid: '' }];
+ const candidates = ['Jane Doe', 'John Doe'].map((name) => ({
+ ...normalizeAuthor({ name }),
+ id: name,
+ }));
+
+ assert.equal(findMatchingAuthorIndex(authors, candidates[0], candidates), -1);
+ assert.equal(findMatchingAuthorIndex(authors, candidates[1], candidates), -1);
+});
+
+test('findMatchingAuthorIndex leaves an initial-only candidate ambiguous across the full candidate pool', () => {
+ const candidates = ['Jane Doe', 'John Doe', 'J. Doe'].map((name) => ({
+ ...normalizeAuthor({ name }),
+ id: name,
+ }));
+ const authors = [candidates[0]];
+
+ assert.equal(findMatchingAuthorIndex(authors, candidates[2], candidates), -1);
+});
+
+test('findMatchingAuthorIndex avoids matching different first names with the same initials', () => {
+ const authors = [
+ { givenNames: 'Jane', familyNames: 'Smith' },
+ { givenNames: 'John', familyNames: 'Smith' },
+ ];
+
+ assert.equal(findMatchingAuthorIndex(authors, normalizeAuthor({ name: 'John Smith' })), 1);
+});
+
+test('candidate identities and matching keep namesakes with distinct ORCIDs separate', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [
+ contributor('Alex Smith', 'alex-one', 5, 'https://orcid.org/0000-0001-1111-1111'),
+ contributor('Alex Smith', 'alex-two', 4, 'https://orcid.org/0000-0002-2222-2222'),
+ ],
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+ const authors = [
+ { givenNames: 'Alex', familyNames: 'Smith', orcid: 'https://orcid.org/0000-0001-1111-1111' },
+ { givenNames: 'Alex', familyNames: 'Smith', orcid: 'https://orcid.org/0000-0002-2222-2222' },
+ ];
+
+ assert.equal(candidates.length, 2);
+ assert.notEqual(candidates[0].id, candidates[1].id);
+ assert.equal(findMatchingAuthorIndex(authors, candidates[1]), 1);
+ assert.equal(findMatchingAuthorIndex(authors, normalizeAuthor({ name: 'Alex Smith' })), -1);
+});
+
+test('candidate matching normalizes bare and URL ORCIDs', () => {
+ const authors = [{ givenNames: 'Jane', familyNames: 'Doe', orcid: '0000-0002-1825-0097' }];
+ const candidate = {
+ ...normalizeAuthor({ name: 'Jane Doe', orcid: 'https://orcid.org/0000-0002-1825-0097' }),
+ id: 'jane-doe',
+ };
+
+ assert.equal(findMatchingAuthorIndex(authors, candidate, [candidate]), 0);
+});
+
+test('candidates with conflicting ORCIDs do not share an ORCID-less author selection', () => {
+ const candidates = [
+ { ...normalizeAuthor({ name: 'Alex Smith', orcid: '0000-0002-1825-0097' }), id: 'alex-one' },
+ { ...normalizeAuthor({ name: 'Alex Smith', orcid: '0000-0002-1694-233X' }), id: 'alex-two' },
+ ];
+ const authors = [{ givenNames: 'Alex', familyNames: 'Smith', orcid: '' }];
+
+ assert.equal(findMatchingAuthorIndex(authors, candidates[0], candidates), -1);
+ assert.equal(findMatchingAuthorIndex(authors, candidates[1], candidates), -1);
+});
+
+test('an exact ORCID-less candidate matches its author despite identified namesakes', () => {
+ const authors = [
+ { givenNames: 'Alex', familyNames: 'Smith', orcid: 'https://orcid.org/0000-0001-1111-1111' },
+ { givenNames: 'Alex', familyNames: 'Smith', orcid: 'https://orcid.org/0000-0002-2222-2222' },
+ { givenNames: 'Alex', familyNames: 'Smith', orcid: '' },
+ ];
+ const candidates = [
+ { ...normalizeAuthor({ name: 'Alex Smith', orcid: '0000-0001-1111-1111' }), id: 'alex-one' },
+ { ...normalizeAuthor({ name: 'Alex Smith', orcid: '0000-0002-2222-2222' }), id: 'alex-two' },
+ { ...normalizeAuthor({ name: 'Alex Smith' }), id: 'alex-unidentified' },
+ ];
+
+ assert.equal(findMatchingAuthorIndex(authors, candidates[2], candidates), 2);
+});
+
+test('candidate sources with middle-initial name variants merge', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [contributor('Elizabeth G. Campolongo', 'elizabeth', 3)],
+ commitNames: [{ name: 'Elizabeth Campolongo', commits: 2, lastCommitDate: '' }],
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ assert.equal(candidates.length, 1);
+ assert.deepEqual(candidates[0].sources, ['github-contributor', 'commit-history']);
+});
+
+test('abbreviated co-author names merge only when one full-name match exists', () => {
+ const uniqueMatch = buildAuthorCandidates({
+ coAuthorNames: ['J. Doe'],
+ contributorCandidates: [contributor('Jane Doe', 'jane', 3)],
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ assert.equal(uniqueMatch.length, 1);
+ assert.equal(fullName(uniqueMatch[0]), 'Jane Doe');
+ assert.deepEqual(uniqueMatch[0].sources, ['github-contributor', 'co-author']);
+
+ const ambiguousMatches = buildAuthorCandidates({
+ coAuthorNames: ['J. Doe'],
+ contributorCandidates: [
+ contributor('Jane Doe', 'jane', 3),
+ contributor('John Doe', 'john', 2),
+ ],
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ assert.equal(ambiguousMatches.length, 3);
+ assert.deepEqual(
+ ambiguousMatches.map(({ givenNames, familyNames, sources }) => [`${givenNames} ${familyNames}`, sources]),
+ [
+ ['J Doe', ['co-author']],
+ ['Jane Doe', ['github-contributor']],
+ ['John Doe', ['github-contributor']],
+ ]
+ );
+});
+
+test('an end date alone or with a start date flags contributors outside the range', () => {
+ const candidates = buildAuthorCandidates({
+ contributorCandidates: [contributor('Early Author', 'early', 40), contributor('Late Author', 'late', 9)],
+ loginCounts: new Map([['early', 3]]),
+ since: '2020-01-01T00:00:00Z',
+ until: '2021-12-31T23:59:59Z',
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+
+ assert.equal(candidates[0].autoSelected, true);
+ assert.match(candidates[0].reason, /3 between 2020-01-01 and 2021-12-31/);
+ assert.equal(candidates[1].autoSelected, false);
+ assert.match(candidates[1].reason, /none found between 2020-01-01 and 2021-12-31/);
+
+ const untilOnly = buildAuthorCandidates({
+ contributorCandidates: [contributor('Late Author', 'late', 9)],
+ until: '2021-12-31T23:59:59Z',
+ autoCreditLimit: 5,
+ normalizeAuthor,
+ });
+ assert.match(untilOnly[0].reason, /none found until 2021-12-31/);
+});
+
+test('commit scans send the until filter and an end date is inclusive of that day', async () => {
+ const urls = [];
+ await scanCommitHistory({
+ owner: 'o', repo: 'r', defaultBranch: 'main', until: resolveContributorUntil('2021-12-31'),
+ warnings: [], cleanString, addWarning: () => {},
+ fetchOptionalJson: async (url) => { urls.push(url); return []; },
+ });
+
+ assert.deepEqual(urls, ['https://api.github.com/repos/o/r/commits?per_page=100&sha=main&until=2021-12-31T23%3A59%3A59Z']);
+ assert.equal(resolveContributorUntil('not a date'), '');
+});
diff --git a/tests/services/commitAuthors.test.js b/tests/services/commitAuthors.test.js
new file mode 100644
index 0000000..256b25b
--- /dev/null
+++ b/tests/services/commitAuthors.test.js
@@ -0,0 +1,70 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+
+import { fetchCommitAuthors } from '../../src/services/githubImporterCommitAuthors.js';
+import { cleanString, normalizeAuthor, normalizeAuthors } from '../../src/services/githubImporterUtils.js';
+
+function commit(name, login = '') {
+ return { commit: { author: { name } }, author: login ? { login, type: 'User' } : null };
+}
+
+test('authenticated scans continue to page two for human author names', async () => {
+ const urls = [];
+ const warnings = [];
+ const result = await fetchCommitAuthors({
+ owner: 'test-owner', repo: 'test-repo', defaultBranch: 'feature/new', authToken: 'token',
+ initialCommits: Array.from({ length: 100 }, () => commit('known-login')),
+ knownGithubLogins: ['known-login'], warnings,
+ cleanString, normalizeAuthor, normalizeAuthors,
+ addWarning: (items, source, code) => items.push({ source, code }),
+ fetchOptionalJson: async (url) => {
+ urls.push(url);
+ return [commit('Ada Lovelace'), commit('bot-123'), commit('name-handle'), commit('Alice Example', 'Alice Example')];
+ },
+ });
+ assert.equal(urls.length, 1);
+ assert.equal(urls[0].endsWith('commits?per_page=100&sha=feature%2Fnew&page=2'), true);
+ assert.deepEqual(result.map((author) => `${author.givenNames} ${author.familyNames}`), ['Ada Lovelace']);
+ assert.equal(warnings.length, 0);
+});
+
+test('unauthenticated scans stop after the first 100 commits', async () => {
+ const warnings = [];
+ const result = await fetchCommitAuthors({
+ owner: 'test-owner', repo: 'test-repo', initialCommits: Array.from({ length: 100 }, () => commit('Dana Example')),
+ warnings, cleanString, normalizeAuthor, normalizeAuthors,
+ addWarning: (items, source, code) => items.push({ source, code }),
+ fetchOptionalJson: async () => { throw new Error('Should not request another page'); },
+ });
+ assert.equal(result.length, 1);
+ assert.equal(warnings.some((warning) => warning.code === 'commit-author-scan-limited'), true);
+});
+
+test('commit history excludes automated identities but accepts hyphenated full names', async () => {
+ const result = await fetchCommitAuthors({
+ owner: 'test-owner',
+ repo: 'test-repo',
+ initialCommits: [
+ commit('Mary-Jane Watson'),
+ commit('Claude Code'),
+ commit('Claude Fable'),
+ commit('GitHub Actions'),
+ commit('GitHub Actions Bot'),
+ commit('Jane Doe', 'bot-builder'),
+ commit('Dana Example'),
+ commit('name_handle'),
+ commit('dev@example.com'),
+ ],
+ warnings: [],
+ cleanString,
+ normalizeAuthor,
+ normalizeAuthors,
+ addWarning: () => {},
+ fetchOptionalJson: async () => [],
+ });
+
+ assert.deepEqual(result.map((author) => `${author.givenNames} ${author.familyNames}`), [
+ 'Mary Jane Watson',
+ 'Dana Example',
+ ]);
+});
\ No newline at end of file
diff --git a/tests/services/contributorFallback.test.js b/tests/services/contributorFallback.test.js
new file mode 100644
index 0000000..88fd8e4
--- /dev/null
+++ b/tests/services/contributorFallback.test.js
@@ -0,0 +1,86 @@
+import test from 'node:test';
+import assert from 'node:assert/strict';
+
+import { fetchContributorAuthors, resolveContributorFallbackLimit } from '../../src/services/githubImporterContributors.js';
+import { cleanString, normalizeAuthor, normalizeAuthors } from '../../src/services/githubImporterUtils.js';
+
+test('fallback fills human slots across a bot-only page without using login-only names', async () => {
+ const urls = [];
+ const warnings = [];
+ const result = await fetchContributorAuthors({
+ owner: 'test-owner', repo: 'test-repo', warnings, contributorFallbackLimit: 2,
+ cleanString, normalizeAuthor, normalizeAuthors,
+ addWarning: (items, source, code, message) => items.push({ source, code, message }),
+ fetchOptionalJson: async (url) => {
+ urls.push(url);
+ if (url.endsWith('&page=1')) {
+ return Array.from({ length: 100 }, (_, index) => ({ login: `bot-${index}`, type: 'Bot' }));
+ }
+ if (url.endsWith('&page=2')) {
+ return [
+ { login: 'no-name', type: 'User', contributions: 5 },
+ { login: 'alice', type: 'User', contributions: 4 },
+ { login: 'bob', type: 'User', contributions: 3 },
+ ];
+ }
+ if (url.endsWith('/users/no-name')) return { login: 'no-name', name: 'no-name', type: 'User' };
+ if (url.endsWith('/users/alice')) return { login: 'alice', name: 'Alice Example', type: 'User' };
+ if (url.endsWith('/users/bob')) return { login: 'bob', name: 'Bob Example', type: 'User' };
+ throw new Error(`Unexpected URL: ${url}`);
+ },
+ extractOrcidFromGithubProfile: () => '',
+ });
+ assert.equal(urls.some((url) => url.endsWith('&page=2')), true);
+ assert.deepEqual(result.fallbackAuthors.map((author) => `${author.givenNames} ${author.familyNames}`), [
+ 'Alice Example', 'Bob Example',
+ ]);
+ assert.equal(warnings.some((warning) => warning.code === 'automated-contributors-excluded'), true);
+});
+
+test('unauthenticated fallback caps profile requests at 25', async () => {
+ let profileRequests = 0;
+ const result = await fetchContributorAuthors({
+ owner: 'test-owner', repo: 'test-repo', warnings: [], contributorFallbackLimit: 50,
+ cleanString, normalizeAuthor, normalizeAuthors, addWarning: () => {},
+ fetchOptionalJson: async (url) => {
+ if (url.includes('/contributors?')) {
+ return Array.from({ length: 100 }, (_, index) => ({ login: `person-${index}`, type: 'User' }));
+ }
+ if (url.includes('/users/person-')) {
+ profileRequests += 1;
+ return { name: `Person ${String.fromCharCode(64 + profileRequests)}`, type: 'User' };
+ }
+ throw new Error(`Unexpected URL: ${url}`);
+ },
+ extractOrcidFromGithubProfile: () => '',
+ });
+ assert.equal(profileRequests, 25);
+ assert.equal(result.fallbackAuthors.length, 25);
+ assert.equal(resolveContributorFallbackLimit({ contributorFallbackLimit: 500 }), 50);
+});
+
+test('unauthenticated contributor scans stop after a bounded number of bot-only pages', async () => {
+ const warnings = [];
+ let pageRequests = 0;
+ await fetchContributorAuthors({
+ owner: 'test-owner',
+ repo: 'test-repo',
+ warnings,
+ contributorFallbackLimit: 5,
+ cleanString,
+ normalizeAuthor,
+ normalizeAuthors,
+ addWarning: (items, source, code, message, details) => items.push({ source, code, message, details }),
+ fetchOptionalJson: async () => {
+ pageRequests += 1;
+ return Array.from({ length: 100 }, (_, index) => ({
+ login: `automation-${pageRequests}-${index}`,
+ type: 'Bot',
+ }));
+ },
+ extractOrcidFromGithubProfile: () => '',
+ });
+
+ assert.equal(pageRequests, 2);
+ assert.equal(warnings.some((warning) => warning.code === 'contributor-scan-limited'), true);
+});
\ No newline at end of file
diff --git a/tests/services/githubImporter.test.js b/tests/services/githubImporter.test.js
index 83fbd12..5b4cf35 100644
--- a/tests/services/githubImporter.test.js
+++ b/tests/services/githubImporter.test.js
@@ -9,6 +9,7 @@ import {
import {
addCitationConsistencyWarnings,
importGithubMetadata,
+ mergeMetadata,
parseCitationCff,
parseZenodoJson,
resolvePreferredCitationPath,
@@ -17,6 +18,49 @@ import {
} from '../../src/services/githubImporter.js';
import { stripWrappingQuotes } from '../../src/services/githubImporterUtils.js';
+function jsonResponse(data) {
+ return {
+ ok: true,
+ status: 200,
+ statusText: 'OK',
+ headers: { get: () => null },
+ text: async () => JSON.stringify(data),
+ };
+}
+
+function createImporterFetch({ initialCommits = [], filteredCommits = [], contributors = [] } = {}) {
+ return async (url) => {
+ const value = String(url);
+ if (value.endsWith('/repos/test-owner/test-repo')) {
+ return jsonResponse({
+ name: 'test-repo',
+ html_url: 'https://github.com/test-owner/test-repo',
+ default_branch: 'main',
+ topics: [],
+ license: { spdx_id: 'MIT' },
+ created_at: '2020-01-01T00:00:00Z',
+ });
+ }
+ if (value.endsWith('/releases?per_page=1')) return jsonResponse([]);
+ if (value.endsWith('/commits?per_page=1&sha=main')) {
+ return jsonResponse([{ commit: { committer: { date: '2025-01-02T00:00:00Z' } } }]);
+ }
+ if (value.includes('/commits?per_page=100&sha=main')) {
+ return jsonResponse(value.includes('&since=') || value.includes('&until=') ? filteredCommits : initialCommits);
+ }
+ if (value.includes('/contributors?')) return jsonResponse(contributors);
+ const profileMatch = value.match(/\/users\/([^/?]+)$/);
+ if (profileMatch) {
+ return jsonResponse({
+ login: profileMatch[1],
+ type: 'User',
+ name: profileMatch[1] === 'alice' ? 'Alice Example' : 'Other Example',
+ });
+ }
+ throw new Error(`Unexpected fetch URL: ${value}`);
+ };
+}
+
test('parseCitationCff extracts top-level fields from common CFF content', () => {
const parsed = parseCitationCff(`cff-version: 1.2.0
@@ -456,6 +500,61 @@ test('importGithubMetadata inspects repository files by default and decodes UTF-
}
});
+test('importGithubMetadata uses the default automatic credit limit for a blank option', async () => {
+ const originalFetch = globalThis.fetch;
+ const jsonResponse = (data) => ({
+ ok: true,
+ status: 200,
+ statusText: 'OK',
+ headers: { get: () => null },
+ text: async () => JSON.stringify(data),
+ });
+ globalThis.fetch = async (url) => {
+ const value = String(url);
+ if (value.endsWith('/repos/test-owner/test-repo')) {
+ return jsonResponse({
+ name: 'test-repo',
+ html_url: 'https://github.com/test-owner/test-repo',
+ default_branch: 'main',
+ topics: [],
+ created_at: '2025-01-01T00:00:00Z',
+ });
+ }
+ if (value.endsWith('/releases?per_page=1')) return jsonResponse([]);
+ if (value.endsWith('/commits?per_page=100&sha=main')) return jsonResponse([]);
+ if (value.endsWith('/commits?per_page=1&sha=main')) return jsonResponse([]);
+ if (value.includes('/contributors?')) {
+ return jsonResponse(Array.from({ length: 25 }, (_, index) => ({
+ login: `author-${index}`,
+ type: 'User',
+ contributions: 25 - index,
+ })));
+ }
+ const profileMatch = value.match(/\/users\/author-(\d+)$/);
+ if (profileMatch) {
+ return jsonResponse({
+ login: `author-${profileMatch[1]}`,
+ type: 'User',
+ name: `Author Person ${String.fromCharCode(65 + Number(profileMatch[1]))}`,
+ });
+ }
+ throw new Error(`Unexpected fetch URL: ${value}`);
+ };
+
+ try {
+ const result = await importGithubMetadata('https://github.com/test-owner/test-repo', {
+ inspectRepositoryFiles: false,
+ lookupExternalDoi: false,
+ contributorFallbackLimit: '',
+ });
+
+ assert.equal(result.errors.length, 0);
+ assert.equal(result.authorCandidates.filter((candidate) => candidate.autoSelected).length, 5);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
test('importGithubMetadata checks the release list instead of hitting the 404-prone latest-release endpoint', async () => {
const originalFetch = globalThis.fetch;
const calledUrls = [];
@@ -996,7 +1095,7 @@ test('importGithubMetadata ignores username-like contributors when no real profi
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1075,7 +1174,7 @@ test('importGithubMetadata excludes AI bot co-authors and contributor accounts w
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1238,7 +1337,7 @@ test('importGithubMetadata ignores GitHub usernames in co-author names and prefe
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1318,7 +1417,7 @@ test('importGithubMetadata prefers commit co-author names over username fallback
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1397,7 +1496,7 @@ test('importGithubMetadata includes co-authored contributor names from commit me
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1475,7 +1574,7 @@ test('importGithubMetadata includes co-authored contributor names from recent hi
return new Response(JSON.stringify({ message: 'Not Found' }), { status: 404, headers: { 'Content-Type': 'application/json' } });
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1554,7 +1653,7 @@ test('importGithubMetadata includes co-authored contributor names when a release
});
}
- if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=10&sha=main')) {
+ if (value.endsWith('/repos/test-owner/test-repo/commits?per_page=100&sha=main')) {
return Response.json([
{
commit: {
@@ -1614,7 +1713,7 @@ test('importGithubMetadata includes co-authored contributor names when a release
}
});
-test('importGithubMetadata orders imported authors by contributor rank', async () => {
+test('importGithubMetadata preserves metadata author order before contributor authors', async () => {
const originalFetch = globalThis.fetch;
const citationText = `cff-version: 1.2.0\ntitle: "OpenCite"\nversion: "1.0.0"\ndate-released: "2025-01-02"\nrepository-code: "https://github.com/test-owner/test-repo"\nauthors:\n - family-names: "Doe"\n given-names: "Jane"\n - family-names: "Smith"\n given-names: "John"\n`;
@@ -1655,7 +1754,6 @@ test('importGithubMetadata orders imported authors by contributor rank', async (
}
if (value.includes('/repos/test-owner/test-repo/contributors?')) {
- // John appears first => highest contributor rank.
return Response.json([
{ login: 'johnsmith', type: 'User' },
{ login: 'janedoe', type: 'User' },
@@ -1700,8 +1798,109 @@ test('importGithubMetadata orders imported authors by contributor rank', async (
assert.equal(result.errors.length, 0);
assert.equal(result.metadata.authors.length >= 2, true);
- assert.equal(result.metadata.authors[0].givenNames, 'John');
- assert.equal(result.metadata.authors[0].familyNames, 'Smith');
+ assert.equal(result.metadata.authors[0].givenNames, 'Jane');
+ assert.equal(result.metadata.authors[0].familyNames, 'Doe');
+ assert.equal(result.metadata.authors[1].givenNames, 'John');
+ assert.equal(result.metadata.authors[1].familyNames, 'Smith');
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
+test('mergeMetadata preserves primary author order before selected contributors', () => {
+ const metadata = mergeMetadata({
+ citation: {
+ authors: [
+ { givenNames: 'Jane', familyNames: 'Doe' },
+ { givenNames: 'John', familyNames: 'Smith' },
+ ],
+ },
+ contributors: [{ givenNames: 'Grace', familyNames: 'Hopper' }],
+ contributorLookupAuthors: [
+ { givenNames: 'John', familyNames: 'Smith' },
+ { givenNames: 'Jane', familyNames: 'Doe' },
+ ],
+ });
+
+ assert.deepEqual(metadata.authors.map((author) => `${author.givenNames} ${author.familyNames}`), [
+ 'Jane Doe',
+ 'John Smith',
+ 'Grace Hopper',
+ ]);
+});
+
+test('importGithubMetadata keeps authors empty when the automatic credit limit is zero', async () => {
+ const originalFetch = globalThis.fetch;
+ globalThis.fetch = createImporterFetch({
+ initialCommits: [],
+ contributors: [{ login: 'alice', type: 'User', contributions: 20 }],
+ });
+
+ try {
+ const result = await importGithubMetadata('https://github.com/test-owner/test-repo', {
+ inspectRepositoryFiles: false,
+ lookupExternalDoi: false,
+ contributorFallbackLimit: 0,
+ });
+
+ assert.equal(result.errors.length, 0);
+ assert.deepEqual(result.metadata.authors, []);
+ assert.equal(result.authorCandidates.some((candidate) => candidate.givenNames === 'Alice' && candidate.autoSelected), false);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
+test('importGithubMetadata keeps authors empty when the cutoff excludes every contributor', async () => {
+ const originalFetch = globalThis.fetch;
+ globalThis.fetch = createImporterFetch({
+ initialCommits: [],
+ filteredCommits: [],
+ contributors: [{ login: 'alice', type: 'User', contributions: 20 }],
+ });
+
+ try {
+ const result = await importGithubMetadata('https://github.com/test-owner/test-repo', {
+ inspectRepositoryFiles: false,
+ lookupExternalDoi: false,
+ contributorFallbackLimit: 5,
+ contributorSince: '2025-01-01',
+ });
+
+ assert.equal(result.errors.length, 0);
+ assert.deepEqual(result.metadata.authors, []);
+ assert.equal(result.authorCandidates.some((candidate) => candidate.givenNames === 'Alice' && candidate.autoSelected), false);
+ } finally {
+ globalThis.fetch = originalFetch;
+ }
+});
+
+test('importGithubMetadata uses co-authors only from the date-filtered commit scan', async () => {
+ const originalFetch = globalThis.fetch;
+ const coAuthorCommit = (name) => ({
+ commit: {
+ author: { name: 'Commit Author', date: '2020-06-01T00:00:00Z' },
+ committer: { date: '2020-06-01T00:00:00Z' },
+ message: `Feature work\n\nCo-authored-by: ${name} `,
+ },
+ });
+ globalThis.fetch = createImporterFetch({
+ initialCommits: [coAuthorCommit('After Cutoff')],
+ filteredCommits: [coAuthorCommit('Within Cutoff')],
+ contributors: [],
+ });
+
+ try {
+ const result = await importGithubMetadata('https://github.com/test-owner/test-repo', {
+ inspectRepositoryFiles: false,
+ lookupExternalDoi: false,
+ contributorFallbackLimit: 5,
+ contributorSince: '2020-01-01',
+ contributorUntil: '2020-12-31',
+ });
+
+ assert.equal(result.errors.length, 0);
+ assert.deepEqual(result.metadata.authors.map((author) => `${author.givenNames} ${author.familyNames}`), ['Within Cutoff']);
} finally {
globalThis.fetch = originalFetch;
}