Skip to content

Commit 701bbb7

Browse files
authored
Merge pull request #11 from warpdotdev/aloke/generate_changelog
Add more logging when generating changelog
2 parents 911d300 + 0f17fb8 commit 701bbb7

File tree

3 files changed

+69
-25
lines changed

3 files changed

+69
-25
lines changed

dist/index.js

Lines changed: 42 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/generate-changelog.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as core from '@actions/core'
12
import {graphql} from '@octokit/graphql'
23
import shell from 'shelljs'
34

@@ -48,6 +49,7 @@ export async function generateChangelog(
4849
)
4950
) {
5051
if (isVersionGreater(currentVersion, release.version)) {
52+
core.info(`Previous release is ${release.version}`)
5153
lastReleaseVersion = release.version
5254
break
5355
}
@@ -62,13 +64,25 @@ export async function generateChangelog(
6264
const currentBranch = branchFromVersion(currentVersion, channel)
6365
const previousBranch = branchFromVersion(lastReleaseVersion, channel)
6466

67+
core.info(`Comparing ${currentBranch} with ${previousBranch}`)
68+
6569
// Find all the commits that are in `currentBranch` but not `previousBranch`.
6670
const command = shell.exec(
6771
`git --no-pager log ^${previousBranch} ${currentBranch} --pretty=format:%H`,
6872
{silent: true}
6973
)
7074

71-
const commits = command.stdout.trim().split('\n')
75+
const commits = command.stdout
76+
.trim()
77+
.split('\n')
78+
.filter(s => s)
79+
core.info(`Found commits ${commits}`)
80+
81+
// There were no differences in commits between the current version and the previous version.
82+
if (commits.length === 0) {
83+
return {added: undefined, fixed: undefined}
84+
}
85+
7286
const pullRequestMetadata = await fetchPullRequestBodyFromCommits(
7387
commits,
7488
graphqlWithAuth
@@ -107,20 +121,20 @@ async function fetchPullRequestBodyFromCommits(
107121
let commitsSubQuery = ''
108122
for (const oid of commits) {
109123
commitsSubQuery += `
110-
commit_${oid}: object(oid: "${oid}") {
111-
... on Commit {
112-
oid
113-
author {
114-
name
115-
}
116-
associatedPullRequests(first: 1) {
117-
nodes {
118-
body
119-
}
124+
commit_${oid}: object(oid: "${oid}") {
125+
... on Commit {
126+
oid
127+
author {
128+
name
129+
}
130+
associatedPullRequests(first: 1) {
131+
nodes {
132+
body
120133
}
121134
}
122135
}
123-
`
136+
}
137+
`
124138
}
125139

126140
const response = await graphqlWithAuth(`

0 commit comments

Comments
 (0)