1
+ import * as core from '@actions/core'
1
2
import { graphql } from '@octokit/graphql'
2
3
import shell from 'shelljs'
3
4
@@ -48,6 +49,7 @@ export async function generateChangelog(
48
49
)
49
50
) {
50
51
if ( isVersionGreater ( currentVersion , release . version ) ) {
52
+ core . info ( `Previous release is ${ release . version } ` )
51
53
lastReleaseVersion = release . version
52
54
break
53
55
}
@@ -62,13 +64,25 @@ export async function generateChangelog(
62
64
const currentBranch = branchFromVersion ( currentVersion , channel )
63
65
const previousBranch = branchFromVersion ( lastReleaseVersion , channel )
64
66
67
+ core . info ( `Comparing ${ currentBranch } with ${ previousBranch } ` )
68
+
65
69
// Find all the commits that are in `currentBranch` but not `previousBranch`.
66
70
const command = shell . exec (
67
71
`git --no-pager log ^${ previousBranch } ${ currentBranch } --pretty=format:%H` ,
68
72
{ silent : true }
69
73
)
70
74
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
+
72
86
const pullRequestMetadata = await fetchPullRequestBodyFromCommits (
73
87
commits ,
74
88
graphqlWithAuth
@@ -107,20 +121,20 @@ async function fetchPullRequestBodyFromCommits(
107
121
let commitsSubQuery = ''
108
122
for ( const oid of commits ) {
109
123
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
120
133
}
121
134
}
122
135
}
123
- `
136
+ }
137
+ `
124
138
}
125
139
126
140
const response = await graphqlWithAuth ( `
0 commit comments