Skip to content

Commit

Permalink
fix: snapshots will now be taken from the latest commit (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Apr 8, 2020
1 parent 0e2c74e commit 274f852
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/releasers/java-yoshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ export class JavaYoshi extends ReleasePR {
]
: await this.commits(latestTag ? latestTag.sha : undefined, 100, true);
let prSHA = commits[0].sha;
// Snapshots populate a fake "fix:"" commit, so that they will always
// result in a patch update. We still need to know the HEAD sba, so that
// we can use this as a starting point for the snapshot PR:
if (this.snapshot) {
const latestCommit = (
await this.commits(latestTag ? latestTag.sha : undefined, 1, true)
)[0];
prSHA = latestCommit.sha;
}

const cc = new ConventionalCommits({
commits,
Expand All @@ -182,21 +191,18 @@ export class JavaYoshi extends ReleasePR {
cc,
latestTag
);
console.info('current package versions:', currentVersions);
const candidateVersions = await this.coerceVersions(cc, currentVersions);
let changelogEntry: string = await cc.generateChangelogEntry({
version: candidate.version,
currentTag: `v${candidate.version}`,
previousTag: candidate.previousTag,
});
console.info('candidate package versions:', candidateVersions);

// snapshot entries are special:
// 1. they don't update the README or CHANGELOG.
// 2. they always update a patch with the -SNAPSHOT suffix.
// 3. they're haunted.
if (this.snapshot) {
prSHA = latestTag!.sha;
candidate.version = `${candidate.version}-SNAPSHOT`;
changelogEntry =
'### Updating meta-information for bleeding-edge SNAPSHOT release.';
Expand Down
8 changes: 8 additions & 0 deletions test/releasers/java-yoshi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ describe('JavaYoshi', () => {
'utf8'
);
const pomContents = readFileSync(resolve(fixturesPath, 'pom.xml'), 'utf8');
const graphql = JSON.parse(
readFileSync(resolve(fixturesPath, 'commits-yoshi-java.json'), 'utf8')
);
const req = nock('https://api.github.com')
.get('/repos/googleapis/java-trace/pulls?state=closed&per_page=100')
.reply(200, undefined)
Expand All @@ -224,6 +227,11 @@ describe('JavaYoshi', () => {
content: Buffer.from(versionsContent, 'utf8').toString('base64'),
sha: 'abc123',
})
// getting the most recent commit:
.post('/graphql')
.reply(200, {
data: graphql,
})
// fetch semver tags, this will be used to determine
// the delta since the last release.
.get('/repos/googleapis/java-trace/tags?per_page=100')
Expand Down

0 comments on commit 274f852

Please sign in to comment.