Skip to content

Overhaul get-github-info - #2121

Merged
Andarist merged 6 commits into
mainfrom
overhaul-get-github-info
Jun 25, 2026
Merged

Overhaul get-github-info#2121
Andarist merged 6 commits into
mainfrom
overhaul-get-github-info

Conversation

@bluwy

@bluwy bluwy commented Jun 24, 2026

Copy link
Copy Markdown
Member

fix #795

See the changesets for the main changes by this PR.

Context

Sorry for the huge PR. I ended up changing a lot of things here because:

  1. If the data is null for TypeError: Cannot read properties of null (reading 'author') #795 case, I believe the function should return null/undefined and let users decide how to handle missing data. The leads to changing the function return type.
  2. Since it was breaking, I thought to rename the functions to be consistent.
  3. Then, I changed the return type completely to without markdown links so it's more flexible to handle the data, e.g. we may return co-authors in the future, so it's nicer if the data is structural.
  4. Then, I wanted to add types for the graphql data so I had to refactor a bit.
  5. Then, index.ts become large and I split into multiple files.

At some point I decided that many changes had already happen, so I just completely cleaned up the setup (in my opinion), which leads to also:

  1. The dataloader query is cleaned up and properly formatted.
  2. The query also uses fragments to reduce query size.
  3. Add batch size as suggested by Chris on Discord. (This might indirectly fix the rate limit issue too?)
  4. Split the commit and pull requests APIs and tests so it's more readable.

Potentially controversial

outdated note about returning markdown

Maybe we still want the APIs to return the Markdown directly? I agree that it'll make usage slightly less verbose, but I also think it's not too much work to construct in case they prefer formatting differently.

If we want to, maybe we can support info.commit.formatted and info.pull.formatted or something.

I have decided to return markdownLink for the preformatted markdown.

One thing left on the table is whether to still add compat APIs for getInfo and getInfoFromPullRequest (the old APIs). It shouldn't be hard to add if we want to.

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 175d608

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@changesets/get-github-info Major
@changesets/changelog-github Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.83193% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.51%. Comparing base (3aae903) to head (175d608).

Files with missing lines Patch % Lines
packages/get-github-info/src/env.ts 31.25% 11 Missing ⚠️
packages/get-github-info/src/dataloader.ts 90.56% 5 Missing ⚠️
packages/changelog-github/src/index.ts 76.47% 3 Missing and 1 partial ⚠️
packages/get-github-info/src/get-commit-info.ts 90.00% 2 Missing ⚠️
...kages/get-github-info/src/get-pull-request-info.ts 77.77% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2121      +/-   ##
==========================================
+ Coverage   85.34%   85.51%   +0.17%     
==========================================
  Files          66       70       +4     
  Lines        2545     2548       +3     
  Branches      699      686      -13     
==========================================
+ Hits         2172     2179       +7     
+ Misses        343      338       -5     
- Partials       30       31       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread packages/get-github-info/README.md
Comment thread .changeset/ten-nights-chew.md Outdated
Comment thread packages/get-github-info/src/dataloader.ts Outdated
Comment thread packages/get-github-info/src/dataloader.ts Outdated
Comment thread packages/get-github-info/src/get-pull-request-info.test.ts Outdated
commit: changeset.commit,
});
if (info == null) {
// may be null if referenced the wrong repo, or the commit has not been pushed

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the comment, this is useful stuff for future us ❤️

@beeequeue beeequeue left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add batch size as suggested by Chris on Discord. (This might indirectly fix the rate limit issue too?)

since batching the requests fixed it for them, i imagine their issue is that github only allows X queries in one GQL request

.split("\n")
.map((l) => l.trimEnd());

const links = await (async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await (async () => {

truly cursed

Comment thread packages/changelog-github/src/index.ts Outdated
Comment thread packages/get-github-info/src/dataloader.ts Outdated
Comment thread packages/get-github-info/src/dataloader.ts Outdated
Comment thread packages/get-github-info/src/get-commit-info.test.ts
Comment thread packages/get-github-info/src/get-commit-info.ts Outdated
@@ -0,0 +1,127 @@
import nock from "nock";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd love if we could move from nock to mentoss, but when i tried last i ran into some issue i can't remember anymore...

@Andarist
Andarist added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit dae394c Jun 25, 2026
11 of 12 checks passed
@Andarist
Andarist deleted the overhaul-get-github-info branch June 25, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeError: Cannot read properties of null (reading 'author')

3 participants