Use GITHUB_REPOSITORY as the default repo when no repo option is configured in changelog-github - #1871
Conversation
🦋 Changeset detectedLatest commit: bf475c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1871 +/- ##
==========================================
+ Coverage 85.49% 86.04% +0.55%
==========================================
Files 70 70
Lines 2550 2558 +8
Branches 687 693 +6
==========================================
+ Hits 2180 2201 +21
+ Misses 339 330 -9
+ Partials 31 27 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| process.env.GITHUB_REPOSITORY = data.repo; | ||
| const [changeset, bump] = getChangeset("fixes #1234 and #5678", data.commit); | ||
| expect(await getReleaseLine(changeset, bump, null)).toMatchInlineSnapshot(` | ||
| " | ||
|
|
||
| - [#1613](https://github.com/emotion-js/emotion/pull/1613) [\`a085003\`](https://github.com/emotion-js/emotion/commit/a085003) Thanks [@Andarist](https://github.com/Andarist)! - something | ||
| fixes [#1234](https://github.com/emotion-js/emotion/issues/1234) and [#5678](https://github.com/emotion-js/emotion/issues/5678)" | ||
| `); | ||
|
|
||
| process.env.GITHUB_REPOSITORY = undefined; |
There was a problem hiding this comment.
Please wrap this in try/catch so the env variable gets reverted correctly. Ideally, we should do this using a helper like this:
function setEnvironmentVariable(name: string, value: string | undefined) {
const hadValue = Object.hasOwn(process.env, name);
const originalValue = process.env[name];
if (typeof value === "string") {
process.env[name] = value;
} else {
delete process.env[name];
}
return () => {
if (hadValue) {
process.env[name] = originalValue;
} else {
delete process.env[name];
}
};
}Feel free to add it to the test-utils
There was a problem hiding this comment.
Should be done if I understood you correctly.
| 'Please provide a repo to this changelog generator like this:\n"changelog": ["@changesets/changelog-github", { "repo": "org/repo" }]' | ||
| ); | ||
| } | ||
| const { GITHUB_REPOSITORY } = readEnv(options); |
There was a problem hiding this comment.
Let's not couple options.repo with env. Please introduce a new util called smth like resolveRepository
GITHUB_REPOSITORY as the default repo when no repo option is configured in changelog-github
Fixes #1870.
Makes the changelog generator options object fully optional, as the env variable is defined in GitHub Actions.
Less configuring, simpler to use.