-
Notifications
You must be signed in to change notification settings - Fork 28
[code-infra] Add util to fetch changelog commits from github #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Bundle size report
Check out the code infra dashboard for more information about this PR. |
8351765
to
ee8c68c
Compare
ee8c68c
to
0eee37d
Compare
b3a1b63
to
5aba295
Compare
a1a3fc9
to
786bd2b
Compare
* @returns {Promise<string>} | ||
*/ | ||
export async function findLatestTaggedVersion(opts) { | ||
const $$ = $({ cwd: opts.cwd }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, using the -C
option in git
could avoid us from reinstantating execa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any major perf issue here. git
has this option but what if it was some other command.
*/ | ||
export async function fetchCommitsBetweenRefs({ org = 'mui', ...options }) { | ||
if (!options.token) { | ||
throw new Error('Missing "token" option. The token needs `public_repo` permissions.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Is this really necessary for public repos?
- Is this also doable with
git
commands instead of the API?
If possible I'd like to discourage putting tokens in your environment if not strictly necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really necessary for public repos
I am getting API rate limit exceeded for
without the token. But perhaps this is because I have already done a lot of github api calls and it has tagged my ip as rate-limited. For one-off changelog generation (during release PR), it may work. One more scenario is that we do 1+n calls back to back (n calls are parallel actually). So this might result in rate limiting which we don't want for changelog generation.
What we can do is do the call without token and ask for token if any of the calls fail with 403.
Another idea would be do have a backend endpoint exposed somewhere in one of our backend services that abstracts the requirement for GITHUB_TOKEN
which we can then call directly without worrying about individual devs exposing their tokens.
Is this also doable with git commands instead of the API?
We can get all the commits (given the local git history is updated). But our changelog filtering relies on Github labels. So essentially we'll be saving that 1 call and not the next n
calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, we may be able to use the oauth device flow to obtain a token?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think web service makes more sense since it won't introduce a barrier (opening url in browser, entering the code etc) to invoking the cli and will continue the existing flow without requiring major changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could also use keychain
store to store and access the tokens requiring passkeys to access it, but it'll be limited to macOS users.
Or in the cli, we can make sure that the token only has public_repo
permission and nothing else since it only gets data that is already public. If it has other permissions, then throw an error asking user to generate another token.
6cbb6ff
to
41719f2
Compare
@Janpot Added a |
41719f2
to
7f8e1ca
Compare
7f8e1ca
to
10bb624
Compare
10bb624
to
c176950
Compare
c176950
to
71e2624
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 16 out of 19 changed files in this pull request and generated 2 comments.
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
b379550
to
9fe56dc
Compare
and return it as a normalized object array.
Also added device token generation
for github api requests
Co-authored-by: Copilot <[email protected]> Signed-off-by: Brijesh Bittu <[email protected]>
9fe56dc
to
761e99b
Compare
761e99b
to
1dbb06d
Compare
@Janpot I've addressed all of the comments. |
and return it as a normalized object array. This can then be used in the product repos as the starting point to then process the commits as required to generate the changelog.
Update: Changed the fetching behaviour to start with graphql and only use rest as a fallback if gql fetching fails with a server error.Edit: Turns out graphql api can be unreliable for inner node fetching as well, ie, top level data might come in the response, but nested data fetching might fail and just return
null
. So removed graphl altogether. See the example below of gql vs rest data -Also added type generation to the
code-infra
package. Otherwise, gettingCould not find a declaration file for module '@mui/internal-code-infra/changelog'
when importing the module in an.mts
file.Another major change:
token
string tofetchCommitBetweenRefs()
function. The token is now generated on-demand and stored in the os credential manager.Screen.Recording.2025-09-25.at.4.37.09.PM.mov
Part of #639
TODOs -