Use repo name from GITHUB_REPOSITORY env variable#1871
Use repo name from GITHUB_REPOSITORY env variable#1871mihkeleidast wants to merge 5 commits intochangesets:mainfrom
Conversation
🦋 Changeset detectedLatest commit: d37fdac The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 81.84% 81.80% -0.04%
==========================================
Files 55 55
Lines 2396 2413 +17
Branches 725 729 +4
==========================================
+ Hits 1961 1974 +13
- Misses 429 433 +4
Partials 6 6 ☔ View full report in Codecov by Sentry. 🚀 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
Fixes #1870.
Makes the changelog generator options object fully optional, as the env variable is defined in GitHub Actions.
Less configuring, simpler to use.