Skip to content

Commit

Permalink
feat: avoid updating release PR if no additional changes (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe authored Jun 10, 2019
1 parent 6a708c8 commit 0c96de1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions __snapshots__/release-pr.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ exports['GitHub Yoshi PHP Mono-Repo generates CHANGELOG and aborts if duplicate
* Add Web Security Center Client ([#1961](https://www.github.com/googleapis/release-please/issues/1961)) ([fa5761e](https://www.github.com/googleapis/release-please/commit/fa5761e))
----
This PR was generated with [Release Please](https://github.com/googleapis/release-please).
`
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,18 @@ export class GitHub {
}
);

// short-circuit of there have been no changes to the
// pull-request body.
if (openReleasePR && openReleasePR.body === options.body) {
checkpoint(
`PR https://github.com/${this.owner}/${this.repo}/pull/${
openReleasePR.number
} remained the same`,
CheckpointType.Failure
);
return -1;
}

await this.request(
`PATCH /repos/:owner/:repo/git/refs/:ref${
this.proxyKey ? `?key=${this.proxyKey}` : ''
Expand Down
11 changes: 7 additions & 4 deletions src/release-pr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export class ReleasePR {

await this.openPR(
commits[0].sha,
changelogEntry,
`${changelogEntry}\n---\n`,
updates,
candidate.version
);
Expand Down Expand Up @@ -341,7 +341,7 @@ export class ReleasePR {
version: string
) {
const title = `chore: release ${version}`;
const body = `:robot: I have created a release \\*beep\\* \\*boop\\* \n---\n${changelogEntry}`;
const body = `:robot: I have created a release \\*beep\\* \\*boop\\* \n---\n${changelogEntry}\nThis PR was generated with [Release Please](https://github.com/googleapis/release-please).`;
const pr: number = await this.gh.openPR({
branch: `release-v${version}`,
version,
Expand All @@ -351,8 +351,11 @@ export class ReleasePR {
body,
labels: this.labels,
});
await this.gh.addLabels(pr, this.labels);
await this.closeStaleReleasePRs(pr);
// a return of -1 indicates that PR was not updated.
if (pr > 0) {
await this.gh.addLabels(pr, this.labels);
await this.closeStaleReleasePRs(pr);
}
}
}

Expand Down

0 comments on commit 0c96de1

Please sign in to comment.