Skip to content

Commit

Permalink
fix: handle when no PR has been opened
Browse files Browse the repository at this point in the history
  • Loading branch information
DaRaFF committed May 2, 2023
1 parent c1e67f1 commit 8c05488
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env node
console.log('release-notes-patch -> v1.6.0 (define patch path based on data/releases.json)')
console.log('release-notes-patch -> v1.6.1 (handle when no PR has been opened)')
const argv = require('yargs')
.demandOption(['token', 'owner', 'repo', 'sha', 'tag'])
.help(false)
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = async ({token, owner, repo, sha, tag, test = false} = {}) => {
// patch release notes detail for upcoming release
if (release.branchName === 'master') {
const pull = await getPullBySha({owner, repo, token, sha})
if (!pull) return `Release notes will not be extended, because no PR found for commit ${sha} in ${owner}/${repo}. \nThis happens when someone pushes to master without opening a PR.`
patchedReleaseNotes = addPatchToUpcomingReleaseNote({
repo,
releaseNote: originReleaseNote,
Expand Down
4 changes: 4 additions & 0 deletions lib/git/get-pull-by-sha.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ module.exports = async ({owner, repo, token, sha}) => {
'User-Agent': 'release-notes-patch'
}
})

// when someone pushes to master without opening a PR
if(res.data.length === 0) return

return {
title: res.data[0].title,
number: res.data[0].number,
Expand Down

0 comments on commit 8c05488

Please sign in to comment.