Skip to content
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

Fix version label behavior for PRs #75

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions dist/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -42580,7 +42580,8 @@ function init_default(context, config) {
}
if (config.checkPrLabels && import_core.Inputs.newVersion == null) {
const releaseType = yield getPrReleaseType(context, config);
context.version.new = releaseType != null ? require_semver2().inc(context.version.old.split("-")[0], releaseType) : context.version.old.split("-")[0];
const oldVersion = (context.version.new || context.version.old).split("-")[0];
context.version.new = releaseType != null ? require_semver2().inc(oldVersion, releaseType) : oldVersion;
}
});
}
Expand All @@ -42603,7 +42604,8 @@ function getPrReleaseType(context, config) {
return null;
}
const events = yield octokit.issues.listEvents(__spreadProps(__spreadValues({}, context.ci.repo), {
issue_number: prNumber
issue_number: prNumber,
per_page: 100
}));
const collaborators = yield octokit.repos.listCollaborators(context.ci.repo);
const releaseLabels = Array.isArray(config.checkPrLabels) ? config.checkPrLabels : DEFAULT_RELEASE_LABELS;
Expand All @@ -42616,7 +42618,7 @@ function getPrReleaseType(context, config) {
name
}));
}
const oldVersion = context.version.old.split("-")[0];
const oldVersion = (context.version.new || context.version.old).split("-")[0];
const prereleaseSuffix = context.version.prerelease != null ? `-${context.version.prerelease}` : "";
const semverInc = require_inc();
let commentBody = `Version info from a repo admin is required to publish a new version. Please add one of the following labels within ${timeoutInMinutes} minutes:
Expand Down Expand Up @@ -42644,6 +42646,7 @@ function getPrReleaseType(context, config) {
try {
const response = yield octokit.issues.listEvents(__spreadProps(__spreadValues({}, context.ci.repo), {
issue_number: prNumber,
per_page: 100,
headers: { "if-none-match": lastEtag }
}));
approvedLabelEvents = findApprovedLabelEvents(response.data, collaborators.data, releaseLabels);
Expand Down
10 changes: 6 additions & 4 deletions packages/github/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export default async function (context: IContext, config: IPluginConfig): Promis

if (config.checkPrLabels && Inputs.newVersion == null) {
const releaseType = await getPrReleaseType(context, config);
context.version.new = releaseType != null ?
require("semver").inc(context.version.old.split("-")[0], releaseType) : context.version.old.split("-")[0];
const oldVersion = (context.version.new || context.version.old).split("-")[0];
context.version.new = releaseType != null ? require("semver").inc(oldVersion, releaseType) : oldVersion;
}
}

Expand Down Expand Up @@ -57,7 +57,8 @@ async function getPrReleaseType(context: IContext, config: IPluginConfig): Promi

const events = await octokit.issues.listEvents({
...context.ci.repo,
issue_number: prNumber
issue_number: prNumber,
per_page: 100
});
const collaborators = await octokit.repos.listCollaborators(context.ci.repo);
const releaseLabels = Array.isArray(config.checkPrLabels) ? config.checkPrLabels : DEFAULT_RELEASE_LABELS;
Expand All @@ -76,7 +77,7 @@ async function getPrReleaseType(context: IContext, config: IPluginConfig): Promi
}

// Comment on PR to request version approval
const oldVersion = context.version.old.split("-")[0];
const oldVersion = (context.version.new || context.version.old).split("-")[0];
const prereleaseSuffix = (context.version.prerelease != null) ? `-${context.version.prerelease}` : "";
const semverInc = require("semver/functions/inc");
let commentBody = `Version info from a repo admin is required to publish a new version. ` +
Expand Down Expand Up @@ -107,6 +108,7 @@ async function getPrReleaseType(context: IContext, config: IPluginConfig): Promi
const response = await octokit.issues.listEvents({
...context.ci.repo,
issue_number: prNumber,
per_page: 100,
headers: { "if-none-match": lastEtag }
});
approvedLabelEvents = findApprovedLabelEvents(response.data, collaborators.data, releaseLabels);
Expand Down