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 number inference #314

Merged
merged 8 commits into from
Apr 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
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@
"args": ["extract-changelog", "--out"],
"program": "${workspaceFolder}/bin.js"
},
{
"type": "pwa-node",
"request": "launch",
"name": "merge",
"skipFiles": [
"<node_internals>/**"
],
"args": ["merge", "--target", "main", "--source", "next", "--verbose", "--force", "--clean", "--changelog", "--compact"],
"program": "${workspaceFolder}/bin.js"
}
{
"type": "pwa-node",
"request": "launch",
Expand Down
19 changes: 2 additions & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ function groupBy(f, xs){
return idx
}

function getVersionFromReleasePR(x){
return [x]
.filter(Boolean)
.map( x => x.title )
.flatMap( x => x.split('-') )
.map( x => x.trim() )
.find( x => semver.valid(x))
}

async function getPackageJSONVersion({ owner, repo }){
let f; try {
f = await octokit.rest.repos.getContent(
Expand Down Expand Up @@ -342,11 +333,6 @@ async function extractChangelog(options){
,page: 1
})
}

let openBranches =
lastRelease
? await getRecentBranchesFromLastRelease({ owner, repo, lastRelease })
: []

let lines =
lastRelease
Expand Down Expand Up @@ -416,7 +402,7 @@ async function extractChangelog(options){
// this version is the published version + branch inferred versions
// it ignores the version set in the PR description
let nextVersion =
await getNextVersion({ recentBranches: openBranches, version })
await getNextVersion({ recentBranches, version })

let contributors =
[...new Set(recentBranches.map( x => x.user.login))]
Expand Down Expand Up @@ -737,11 +723,10 @@ async function merge(options){
return null;
}

async function inferVersion({ owner, repo, lastRelease }){
async function inferVersion({ owner, repo }){
let versionTypes = {
git: await getGitTagVersion({ owner, repo })
,npm: await getPackageJSONVersion({ owner, repo })
,title: lastRelease && getVersionFromReleasePR(lastRelease)
,default: '0.0.0'
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pr-release",
"version": "0.18.4",
"version": "0.18.7",
"description": "Generate releases from pull request descriptions.",
"main": "dist/pr-release.cjs",
"module": "lib/index.js",
Expand Down