From 53b62b82410f11ce3621a5eae87ccc61aaab0559 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Mon, 19 Aug 2019 13:04:14 -0700 Subject: [PATCH] feat: implement generic java strategy (#227) --- __snapshots__/github.js | 8 + src/bin/release-please.ts | 5 + src/github.ts | 19 + src/release-pr.ts | 1 + src/releasers/java-auth-yoshi.ts | 10 +- src/releasers/java-yoshi.ts | 135 ++++++ src/updaters/{ => java}/pom-xml.ts | 4 +- .../{java-auth-readme.ts => java/readme.ts} | 7 +- .../versions-manifest.ts} | 7 +- test/fixtures/pom-file-search.json | 386 ++++++++++++++++++ test/github.ts | 14 + test/updaters/java-auth-readme.ts | 4 +- test/updaters/java-auth-versions.ts | 6 +- test/updaters/pom-xml.ts | 2 +- 14 files changed, 587 insertions(+), 21 deletions(-) create mode 100644 src/releasers/java-yoshi.ts rename src/updaters/{ => java}/pom-xml.ts (92%) rename src/updaters/{java-auth-readme.ts => java/readme.ts} (88%) rename src/updaters/{java-auth-versions.ts => java/versions-manifest.ts} (87%) create mode 100644 test/fixtures/pom-file-search.json diff --git a/__snapshots__/github.js b/__snapshots__/github.js index 8a9255a02..a2acf1f17 100644 --- a/__snapshots__/github.js +++ b/__snapshots__/github.js @@ -183,3 +183,11 @@ exports['GitHub commitsSinceSha returns commits immediately before sha 1'] = [ ] } ] + +exports['GitHub findFilesByfilename returns files matching the requested pattern 1'] = [ + "appengine/pom.xml", + "bom/pom.xml", + "credentials/pom.xml", + "oauth2_http/pom.xml", + "pom.xml" +] diff --git a/src/bin/release-please.ts b/src/bin/release-please.ts index 62a42a65b..97e8deda9 100644 --- a/src/bin/release-please.ts +++ b/src/bin/release-please.ts @@ -27,6 +27,7 @@ import { JavaAuthYoshi } from '../releasers/java-auth-yoshi'; import { Node } from '../releasers/node'; import { PHPYoshi } from '../releasers/php-yoshi'; import { RubyYoshi } from '../releasers/ruby-yoshi'; +import { JavaYoshi } from '../releasers/java-yoshi'; const yargs = require('yargs'); @@ -85,8 +86,12 @@ const argv = yargs rp = new PHPYoshi(argv); break; case ReleaseType.JavaAuthYoshi: + // TODO: coerce this to the generic Java release rp = new JavaAuthYoshi(argv); break; + case ReleaseType.JavaYoshi: + rp = new JavaYoshi(argv); + break; case ReleaseType.RubyYoshi: rp = new RubyYoshi(argv); break; diff --git a/src/github.ts b/src/github.ts index 8b64dea6f..d8b48afd7 100644 --- a/src/github.ts +++ b/src/github.ts @@ -84,6 +84,14 @@ interface GitHubPR { labels: string[]; } +interface FileSearchResponse { + items: FileSearchResponseFile[]; +} + +interface FileSearchResponseFile { + path: string; +} + let probotMode = false; export class GitHub { @@ -876,6 +884,17 @@ export class GitHub { ); } } + + async findFilesByFilename(filename: string): Promise { + const response: Octokit.Response< + FileSearchResponse + > = await this.octokit.search.code({ + q: `filename:${filename}+repo:${this.repo}`, + }); + return response.data.items.map(file => { + return file.path; + }); + } } class AuthError extends Error { diff --git a/src/release-pr.ts b/src/release-pr.ts index 7fcb3fe04..4b09d4cb7 100644 --- a/src/release-pr.ts +++ b/src/release-pr.ts @@ -29,6 +29,7 @@ export enum ReleaseType { Node = 'node', PHPYoshi = 'php-yoshi', JavaAuthYoshi = 'java-auth-yoshi', + JavaYoshi = 'java-yoshi', RubyYoshi = 'ruby-yoshi', } diff --git a/src/releasers/java-auth-yoshi.ts b/src/releasers/java-auth-yoshi.ts index dd72ffbc6..6f80c3615 100644 --- a/src/releasers/java-auth-yoshi.ts +++ b/src/releasers/java-auth-yoshi.ts @@ -25,10 +25,10 @@ import { Commit } from '../graphql-to-commits'; // Generic import { Changelog } from '../updaters/changelog'; // Java -import { PomXML } from '../updaters/pom-xml'; +import { PomXML } from '../updaters/java/pom-xml'; // Yoshi Java Auth Library -import { JavaAuthVersions } from '../updaters/java-auth-versions'; -import { JavaAuthReadme } from '../updaters/java-auth-readme'; +import { VersionsManifest } from '../updaters/java/versions-manifest'; +import { Readme } from '../updaters/java/readme'; export class JavaAuthYoshi extends ReleasePR { protected async _run() { @@ -96,7 +96,7 @@ export class JavaAuthYoshi extends ReleasePR { ); updates.push( - new JavaAuthReadme({ + new Readme({ path: 'README.md', changelogEntry, version: candidate.version, @@ -106,7 +106,7 @@ export class JavaAuthYoshi extends ReleasePR { } updates.push( - new JavaAuthVersions({ + new VersionsManifest({ path: 'versions.txt', changelogEntry, version: candidate.version, diff --git a/src/releasers/java-yoshi.ts b/src/releasers/java-yoshi.ts new file mode 100644 index 000000000..ea0aba5eb --- /dev/null +++ b/src/releasers/java-yoshi.ts @@ -0,0 +1,135 @@ +/** + * Copyright 2019 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ReleasePR, ReleaseCandidate } from '../release-pr'; + +import { ConventionalCommits } from '../conventional-commits'; +import { GitHubTag } from '../github'; +import { checkpoint, CheckpointType } from '../util/checkpoint'; +import { Update } from '../updaters/update'; +import { Commit } from '../graphql-to-commits'; + +// Generic +import { Changelog } from '../updaters/changelog'; +// Java +import { PomXML } from '../updaters/java/pom-xml'; +import { VersionsManifest } from '../updaters/java/versions-manifest'; +import { Readme } from '../updaters/java/readme'; + +export class JavaYoshi extends ReleasePR { + protected async _run() { + const latestTag: GitHubTag | undefined = await this.gh.latestTag(); + const commits: Commit[] = this.snapshot + ? [ + { + sha: 'abc123', + message: 'fix: ', + files: [], + }, + ] + : await this.commits(latestTag ? latestTag.sha : undefined, 100, true); + let prSHA = commits[0].sha; + + const cc = new ConventionalCommits({ + commits, + githubRepoUrl: this.repoUrl, + bumpMinorPreMajor: this.bumpMinorPreMajor, + }); + const candidate: ReleaseCandidate = await this.coerceReleaseCandidate( + cc, + latestTag + ); + let changelogEntry: string = await cc.generateChangelogEntry({ + version: candidate.version, + currentTag: `v${candidate.version}`, + previousTag: candidate.previousTag, + }); + + // 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.'; + } + + // don't create a release candidate until user facing changes + // (fix, feat, BREAKING CHANGE) have been made; a CHANGELOG that's + // one line is a good indicator that there were no interesting commits. + if (this.changelogEmpty(changelogEntry) && !this.snapshot) { + checkpoint( + `no user facing commits found since ${ + latestTag ? latestTag.sha : 'beginning of time' + }`, + CheckpointType.Failure + ); + return; + } + + const updates: Update[] = []; + + if (!this.snapshot) { + updates.push( + new Changelog({ + path: 'CHANGELOG.md', + changelogEntry, + version: candidate.version, + packageName: this.packageName, + }) + ); + + updates.push( + new Readme({ + path: 'README.md', + changelogEntry, + version: candidate.version, + packageName: this.packageName, + }) + ); + } + + updates.push( + new VersionsManifest({ + path: 'versions.txt', + changelogEntry, + version: candidate.version, + packageName: this.packageName, + }) + ); + + const pomFiles = await this.gh.findFilesByFilename('pom.xml'); + pomFiles.forEach(path => { + updates.push( + new PomXML({ + path, + changelogEntry, + version: candidate.version, + packageName: this.packageName, + }) + ); + }); + + await this.openPR( + prSHA, + `${changelogEntry}\n---\n`, + updates, + candidate.version + ); + } +} diff --git a/src/updaters/pom-xml.ts b/src/updaters/java/pom-xml.ts similarity index 92% rename from src/updaters/pom-xml.ts rename to src/updaters/java/pom-xml.ts index 882a9aeee..bfdad9fc0 100644 --- a/src/updaters/pom-xml.ts +++ b/src/updaters/java/pom-xml.ts @@ -14,8 +14,8 @@ * limitations under the License. */ -import { Update, UpdateOptions } from './update'; -import { GitHubFileContents } from '../github'; +import { Update, UpdateOptions } from '../update'; +import { GitHubFileContents } from '../../github'; export class PomXML implements Update { path: string; diff --git a/src/updaters/java-auth-readme.ts b/src/updaters/java/readme.ts similarity index 88% rename from src/updaters/java-auth-readme.ts rename to src/updaters/java/readme.ts index 465a8ab92..9a98b056e 100644 --- a/src/updaters/java-auth-readme.ts +++ b/src/updaters/java/readme.ts @@ -14,11 +14,10 @@ * limitations under the License. */ -import { checkpoint, CheckpointType } from '../util/checkpoint'; -import { Update, UpdateOptions } from './update'; -import { GitHubFileContents } from '../github'; +import { Update, UpdateOptions } from '../update'; +import { GitHubFileContents } from '../../github'; -export class JavaAuthReadme implements Update { +export class Readme implements Update { path: string; changelogEntry: string; version: string; diff --git a/src/updaters/java-auth-versions.ts b/src/updaters/java/versions-manifest.ts similarity index 87% rename from src/updaters/java-auth-versions.ts rename to src/updaters/java/versions-manifest.ts index d43c06683..ed3565a80 100644 --- a/src/updaters/java-auth-versions.ts +++ b/src/updaters/java/versions-manifest.ts @@ -14,11 +14,10 @@ * limitations under the License. */ -import { checkpoint, CheckpointType } from '../util/checkpoint'; -import { Update, UpdateOptions } from './update'; -import { GitHubFileContents } from '../github'; +import { Update, UpdateOptions } from '../update'; +import { GitHubFileContents } from '../../github'; -export class JavaAuthVersions implements Update { +export class VersionsManifest implements Update { path: string; changelogEntry: string; version: string; diff --git a/test/fixtures/pom-file-search.json b/test/fixtures/pom-file-search.json new file mode 100644 index 000000000..c6aba74e5 --- /dev/null +++ b/test/fixtures/pom-file-search.json @@ -0,0 +1,386 @@ +{ + "total_count": 5, + "incomplete_results": false, + "items": [ + { + "name": "pom.xml", + "path": "appengine/pom.xml", + "sha": "66a1dbc5dd8997abe6799999456c1753a9eacf1a", + "url": "https://api.github.com/repositories/30676648/contents/appengine/pom.xml?ref=19f38ad583a971364189e802aba38fd01d84fd4a", + "git_url": "https://api.github.com/repositories/30676648/git/blobs/66a1dbc5dd8997abe6799999456c1753a9eacf1a", + "html_url": "https://github.com/googleapis/google-auth-library-java/blob/19f38ad583a971364189e802aba38fd01d84fd4a/appengine/pom.xml", + "repository": { + "id": 30676648, + "node_id": "MDEwOlJlcG9zaXRvcnkzMDY3NjY0OA==", + "name": "google-auth-library-java", + "full_name": "googleapis/google-auth-library-java", + "private": false, + "owner": { + "login": "googleapis", + "id": 16785467, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE2Nzg1NDY3", + "avatar_url": "https://avatars3.githubusercontent.com/u/16785467?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/googleapis", + "html_url": "https://github.com/googleapis", + "followers_url": "https://api.github.com/users/googleapis/followers", + "following_url": "https://api.github.com/users/googleapis/following{/other_user}", + "gists_url": "https://api.github.com/users/googleapis/gists{/gist_id}", + "starred_url": "https://api.github.com/users/googleapis/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/googleapis/subscriptions", + "organizations_url": "https://api.github.com/users/googleapis/orgs", + "repos_url": "https://api.github.com/users/googleapis/repos", + "events_url": "https://api.github.com/users/googleapis/events{/privacy}", + "received_events_url": "https://api.github.com/users/googleapis/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/googleapis/google-auth-library-java", + "description": "Open source Auth client library for Java", + "fork": false, + "url": "https://api.github.com/repos/googleapis/google-auth-library-java", + "forks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/forks", + "keys_url": "https://api.github.com/repos/googleapis/google-auth-library-java/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/googleapis/google-auth-library-java/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/googleapis/google-auth-library-java/teams", + "hooks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/hooks", + "issue_events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/events{/number}", + "events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/events", + "assignees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/assignees{/user}", + "branches_url": "https://api.github.com/repos/googleapis/google-auth-library-java/branches{/branch}", + "tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/tags", + "blobs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/googleapis/google-auth-library-java/statuses/{sha}", + "languages_url": "https://api.github.com/repos/googleapis/google-auth-library-java/languages", + "stargazers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/stargazers", + "contributors_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contributors", + "subscribers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscribers", + "subscription_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscription", + "commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contents/{+path}", + "compare_url": "https://api.github.com/repos/googleapis/google-auth-library-java/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/googleapis/google-auth-library-java/merges", + "archive_url": "https://api.github.com/repos/googleapis/google-auth-library-java/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/googleapis/google-auth-library-java/downloads", + "issues_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues{/number}", + "pulls_url": "https://api.github.com/repos/googleapis/google-auth-library-java/pulls{/number}", + "milestones_url": "https://api.github.com/repos/googleapis/google-auth-library-java/milestones{/number}", + "notifications_url": "https://api.github.com/repos/googleapis/google-auth-library-java/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/googleapis/google-auth-library-java/labels{/name}", + "releases_url": "https://api.github.com/repos/googleapis/google-auth-library-java/releases{/id}", + "deployments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/deployments" + }, + "score": 16.224508 + }, + { + "name": "pom.xml", + "path": "bom/pom.xml", + "sha": "b415893aab92139c0212bd3b763a73ff8e75489b", + "url": "https://api.github.com/repositories/30676648/contents/bom/pom.xml?ref=19f38ad583a971364189e802aba38fd01d84fd4a", + "git_url": "https://api.github.com/repositories/30676648/git/blobs/b415893aab92139c0212bd3b763a73ff8e75489b", + "html_url": "https://github.com/googleapis/google-auth-library-java/blob/19f38ad583a971364189e802aba38fd01d84fd4a/bom/pom.xml", + "repository": { + "id": 30676648, + "node_id": "MDEwOlJlcG9zaXRvcnkzMDY3NjY0OA==", + "name": "google-auth-library-java", + "full_name": "googleapis/google-auth-library-java", + "private": false, + "owner": { + "login": "googleapis", + "id": 16785467, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE2Nzg1NDY3", + "avatar_url": "https://avatars3.githubusercontent.com/u/16785467?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/googleapis", + "html_url": "https://github.com/googleapis", + "followers_url": "https://api.github.com/users/googleapis/followers", + "following_url": "https://api.github.com/users/googleapis/following{/other_user}", + "gists_url": "https://api.github.com/users/googleapis/gists{/gist_id}", + "starred_url": "https://api.github.com/users/googleapis/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/googleapis/subscriptions", + "organizations_url": "https://api.github.com/users/googleapis/orgs", + "repos_url": "https://api.github.com/users/googleapis/repos", + "events_url": "https://api.github.com/users/googleapis/events{/privacy}", + "received_events_url": "https://api.github.com/users/googleapis/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/googleapis/google-auth-library-java", + "description": "Open source Auth client library for Java", + "fork": false, + "url": "https://api.github.com/repos/googleapis/google-auth-library-java", + "forks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/forks", + "keys_url": "https://api.github.com/repos/googleapis/google-auth-library-java/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/googleapis/google-auth-library-java/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/googleapis/google-auth-library-java/teams", + "hooks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/hooks", + "issue_events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/events{/number}", + "events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/events", + "assignees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/assignees{/user}", + "branches_url": "https://api.github.com/repos/googleapis/google-auth-library-java/branches{/branch}", + "tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/tags", + "blobs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/googleapis/google-auth-library-java/statuses/{sha}", + "languages_url": "https://api.github.com/repos/googleapis/google-auth-library-java/languages", + "stargazers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/stargazers", + "contributors_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contributors", + "subscribers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscribers", + "subscription_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscription", + "commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contents/{+path}", + "compare_url": "https://api.github.com/repos/googleapis/google-auth-library-java/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/googleapis/google-auth-library-java/merges", + "archive_url": "https://api.github.com/repos/googleapis/google-auth-library-java/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/googleapis/google-auth-library-java/downloads", + "issues_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues{/number}", + "pulls_url": "https://api.github.com/repos/googleapis/google-auth-library-java/pulls{/number}", + "milestones_url": "https://api.github.com/repos/googleapis/google-auth-library-java/milestones{/number}", + "notifications_url": "https://api.github.com/repos/googleapis/google-auth-library-java/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/googleapis/google-auth-library-java/labels{/name}", + "releases_url": "https://api.github.com/repos/googleapis/google-auth-library-java/releases{/id}", + "deployments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/deployments" + }, + "score": 16.224508 + }, + { + "name": "pom.xml", + "path": "credentials/pom.xml", + "sha": "a07820e85498af9cf9fac8447e7e93f9bd876868", + "url": "https://api.github.com/repositories/30676648/contents/credentials/pom.xml?ref=19f38ad583a971364189e802aba38fd01d84fd4a", + "git_url": "https://api.github.com/repositories/30676648/git/blobs/a07820e85498af9cf9fac8447e7e93f9bd876868", + "html_url": "https://github.com/googleapis/google-auth-library-java/blob/19f38ad583a971364189e802aba38fd01d84fd4a/credentials/pom.xml", + "repository": { + "id": 30676648, + "node_id": "MDEwOlJlcG9zaXRvcnkzMDY3NjY0OA==", + "name": "google-auth-library-java", + "full_name": "googleapis/google-auth-library-java", + "private": false, + "owner": { + "login": "googleapis", + "id": 16785467, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE2Nzg1NDY3", + "avatar_url": "https://avatars3.githubusercontent.com/u/16785467?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/googleapis", + "html_url": "https://github.com/googleapis", + "followers_url": "https://api.github.com/users/googleapis/followers", + "following_url": "https://api.github.com/users/googleapis/following{/other_user}", + "gists_url": "https://api.github.com/users/googleapis/gists{/gist_id}", + "starred_url": "https://api.github.com/users/googleapis/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/googleapis/subscriptions", + "organizations_url": "https://api.github.com/users/googleapis/orgs", + "repos_url": "https://api.github.com/users/googleapis/repos", + "events_url": "https://api.github.com/users/googleapis/events{/privacy}", + "received_events_url": "https://api.github.com/users/googleapis/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/googleapis/google-auth-library-java", + "description": "Open source Auth client library for Java", + "fork": false, + "url": "https://api.github.com/repos/googleapis/google-auth-library-java", + "forks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/forks", + "keys_url": "https://api.github.com/repos/googleapis/google-auth-library-java/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/googleapis/google-auth-library-java/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/googleapis/google-auth-library-java/teams", + "hooks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/hooks", + "issue_events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/events{/number}", + "events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/events", + "assignees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/assignees{/user}", + "branches_url": "https://api.github.com/repos/googleapis/google-auth-library-java/branches{/branch}", + "tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/tags", + "blobs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/googleapis/google-auth-library-java/statuses/{sha}", + "languages_url": "https://api.github.com/repos/googleapis/google-auth-library-java/languages", + "stargazers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/stargazers", + "contributors_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contributors", + "subscribers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscribers", + "subscription_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscription", + "commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contents/{+path}", + "compare_url": "https://api.github.com/repos/googleapis/google-auth-library-java/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/googleapis/google-auth-library-java/merges", + "archive_url": "https://api.github.com/repos/googleapis/google-auth-library-java/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/googleapis/google-auth-library-java/downloads", + "issues_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues{/number}", + "pulls_url": "https://api.github.com/repos/googleapis/google-auth-library-java/pulls{/number}", + "milestones_url": "https://api.github.com/repos/googleapis/google-auth-library-java/milestones{/number}", + "notifications_url": "https://api.github.com/repos/googleapis/google-auth-library-java/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/googleapis/google-auth-library-java/labels{/name}", + "releases_url": "https://api.github.com/repos/googleapis/google-auth-library-java/releases{/id}", + "deployments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/deployments" + }, + "score": 16.224508 + }, + { + "name": "pom.xml", + "path": "oauth2_http/pom.xml", + "sha": "040ba98306c777e78a9b0ce84edba73929a29595", + "url": "https://api.github.com/repositories/30676648/contents/oauth2_http/pom.xml?ref=19f38ad583a971364189e802aba38fd01d84fd4a", + "git_url": "https://api.github.com/repositories/30676648/git/blobs/040ba98306c777e78a9b0ce84edba73929a29595", + "html_url": "https://github.com/googleapis/google-auth-library-java/blob/19f38ad583a971364189e802aba38fd01d84fd4a/oauth2_http/pom.xml", + "repository": { + "id": 30676648, + "node_id": "MDEwOlJlcG9zaXRvcnkzMDY3NjY0OA==", + "name": "google-auth-library-java", + "full_name": "googleapis/google-auth-library-java", + "private": false, + "owner": { + "login": "googleapis", + "id": 16785467, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE2Nzg1NDY3", + "avatar_url": "https://avatars3.githubusercontent.com/u/16785467?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/googleapis", + "html_url": "https://github.com/googleapis", + "followers_url": "https://api.github.com/users/googleapis/followers", + "following_url": "https://api.github.com/users/googleapis/following{/other_user}", + "gists_url": "https://api.github.com/users/googleapis/gists{/gist_id}", + "starred_url": "https://api.github.com/users/googleapis/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/googleapis/subscriptions", + "organizations_url": "https://api.github.com/users/googleapis/orgs", + "repos_url": "https://api.github.com/users/googleapis/repos", + "events_url": "https://api.github.com/users/googleapis/events{/privacy}", + "received_events_url": "https://api.github.com/users/googleapis/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/googleapis/google-auth-library-java", + "description": "Open source Auth client library for Java", + "fork": false, + "url": "https://api.github.com/repos/googleapis/google-auth-library-java", + "forks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/forks", + "keys_url": "https://api.github.com/repos/googleapis/google-auth-library-java/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/googleapis/google-auth-library-java/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/googleapis/google-auth-library-java/teams", + "hooks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/hooks", + "issue_events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/events{/number}", + "events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/events", + "assignees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/assignees{/user}", + "branches_url": "https://api.github.com/repos/googleapis/google-auth-library-java/branches{/branch}", + "tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/tags", + "blobs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/googleapis/google-auth-library-java/statuses/{sha}", + "languages_url": "https://api.github.com/repos/googleapis/google-auth-library-java/languages", + "stargazers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/stargazers", + "contributors_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contributors", + "subscribers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscribers", + "subscription_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscription", + "commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contents/{+path}", + "compare_url": "https://api.github.com/repos/googleapis/google-auth-library-java/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/googleapis/google-auth-library-java/merges", + "archive_url": "https://api.github.com/repos/googleapis/google-auth-library-java/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/googleapis/google-auth-library-java/downloads", + "issues_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues{/number}", + "pulls_url": "https://api.github.com/repos/googleapis/google-auth-library-java/pulls{/number}", + "milestones_url": "https://api.github.com/repos/googleapis/google-auth-library-java/milestones{/number}", + "notifications_url": "https://api.github.com/repos/googleapis/google-auth-library-java/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/googleapis/google-auth-library-java/labels{/name}", + "releases_url": "https://api.github.com/repos/googleapis/google-auth-library-java/releases{/id}", + "deployments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/deployments" + }, + "score": 16.224508 + }, + { + "name": "pom.xml", + "path": "pom.xml", + "sha": "0e3765b4c75648bde30507fc4c102e22a64c3936", + "url": "https://api.github.com/repositories/30676648/contents/pom.xml?ref=19f38ad583a971364189e802aba38fd01d84fd4a", + "git_url": "https://api.github.com/repositories/30676648/git/blobs/0e3765b4c75648bde30507fc4c102e22a64c3936", + "html_url": "https://github.com/googleapis/google-auth-library-java/blob/19f38ad583a971364189e802aba38fd01d84fd4a/pom.xml", + "repository": { + "id": 30676648, + "node_id": "MDEwOlJlcG9zaXRvcnkzMDY3NjY0OA==", + "name": "google-auth-library-java", + "full_name": "googleapis/google-auth-library-java", + "private": false, + "owner": { + "login": "googleapis", + "id": 16785467, + "node_id": "MDEyOk9yZ2FuaXphdGlvbjE2Nzg1NDY3", + "avatar_url": "https://avatars3.githubusercontent.com/u/16785467?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/googleapis", + "html_url": "https://github.com/googleapis", + "followers_url": "https://api.github.com/users/googleapis/followers", + "following_url": "https://api.github.com/users/googleapis/following{/other_user}", + "gists_url": "https://api.github.com/users/googleapis/gists{/gist_id}", + "starred_url": "https://api.github.com/users/googleapis/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/googleapis/subscriptions", + "organizations_url": "https://api.github.com/users/googleapis/orgs", + "repos_url": "https://api.github.com/users/googleapis/repos", + "events_url": "https://api.github.com/users/googleapis/events{/privacy}", + "received_events_url": "https://api.github.com/users/googleapis/received_events", + "type": "Organization", + "site_admin": false + }, + "html_url": "https://github.com/googleapis/google-auth-library-java", + "description": "Open source Auth client library for Java", + "fork": false, + "url": "https://api.github.com/repos/googleapis/google-auth-library-java", + "forks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/forks", + "keys_url": "https://api.github.com/repos/googleapis/google-auth-library-java/keys{/key_id}", + "collaborators_url": "https://api.github.com/repos/googleapis/google-auth-library-java/collaborators{/collaborator}", + "teams_url": "https://api.github.com/repos/googleapis/google-auth-library-java/teams", + "hooks_url": "https://api.github.com/repos/googleapis/google-auth-library-java/hooks", + "issue_events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/events{/number}", + "events_url": "https://api.github.com/repos/googleapis/google-auth-library-java/events", + "assignees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/assignees{/user}", + "branches_url": "https://api.github.com/repos/googleapis/google-auth-library-java/branches{/branch}", + "tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/tags", + "blobs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/blobs{/sha}", + "git_tags_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/tags{/sha}", + "git_refs_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/refs{/sha}", + "trees_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/trees{/sha}", + "statuses_url": "https://api.github.com/repos/googleapis/google-auth-library-java/statuses/{sha}", + "languages_url": "https://api.github.com/repos/googleapis/google-auth-library-java/languages", + "stargazers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/stargazers", + "contributors_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contributors", + "subscribers_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscribers", + "subscription_url": "https://api.github.com/repos/googleapis/google-auth-library-java/subscription", + "commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/commits{/sha}", + "git_commits_url": "https://api.github.com/repos/googleapis/google-auth-library-java/git/commits{/sha}", + "comments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/comments{/number}", + "issue_comment_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues/comments{/number}", + "contents_url": "https://api.github.com/repos/googleapis/google-auth-library-java/contents/{+path}", + "compare_url": "https://api.github.com/repos/googleapis/google-auth-library-java/compare/{base}...{head}", + "merges_url": "https://api.github.com/repos/googleapis/google-auth-library-java/merges", + "archive_url": "https://api.github.com/repos/googleapis/google-auth-library-java/{archive_format}{/ref}", + "downloads_url": "https://api.github.com/repos/googleapis/google-auth-library-java/downloads", + "issues_url": "https://api.github.com/repos/googleapis/google-auth-library-java/issues{/number}", + "pulls_url": "https://api.github.com/repos/googleapis/google-auth-library-java/pulls{/number}", + "milestones_url": "https://api.github.com/repos/googleapis/google-auth-library-java/milestones{/number}", + "notifications_url": "https://api.github.com/repos/googleapis/google-auth-library-java/notifications{?since,all,participating}", + "labels_url": "https://api.github.com/repos/googleapis/google-auth-library-java/labels{/name}", + "releases_url": "https://api.github.com/repos/googleapis/google-auth-library-java/releases{/id}", + "deployments_url": "https://api.github.com/repos/googleapis/google-auth-library-java/deployments" + }, + "score": 16.224508 + } + ] +} \ No newline at end of file diff --git a/test/github.ts b/test/github.ts index 193c166be..4f6958cb4 100644 --- a/test/github.ts +++ b/test/github.ts @@ -47,4 +47,18 @@ describe('GitHub', () => { req.done(); }); }); + + describe('findFilesByfilename', () => { + it('returns files matching the requested pattern', async () => { + const fileSearchResponse = JSON.parse( + readFileSync(resolve(fixturesPath, 'pom-file-search.json'), 'utf8') + ); + const req = nock('https://api.github.com') + .get('/search/code?q=filename%3Apom.xml+repo%3Afake') + .reply(200, fileSearchResponse); + const pomFiles = await github.findFilesByFilename('pom.xml'); + snapshot(pomFiles); + req.done(); + }); + }); }); diff --git a/test/updaters/java-auth-readme.ts b/test/updaters/java-auth-readme.ts index 2339b7513..c8f5d55d0 100644 --- a/test/updaters/java-auth-readme.ts +++ b/test/updaters/java-auth-readme.ts @@ -18,7 +18,7 @@ import { readFileSync } from 'fs'; import { basename, resolve } from 'path'; import * as snapshot from 'snap-shot-it'; -import { JavaAuthReadme } from '../../src/updaters/java-auth-readme'; +import { Readme } from '../../src/updaters/java/readme'; import { UpdateOptions } from '../../src/updaters/update'; const fixturesPath = './test/updaters/fixtures'; @@ -30,7 +30,7 @@ describe('JavaAuthReadme', () => { resolve(fixturesPath, './java-auth-readme.md'), 'utf8' ).replace(/\r\n/g, '\n'); - const javaAuthReadme = new JavaAuthReadme({ + const javaAuthReadme = new Readme({ path: 'README.md', changelogEntry: '', version: '0.20.0', diff --git a/test/updaters/java-auth-versions.ts b/test/updaters/java-auth-versions.ts index 4cf8cffee..648c2081c 100644 --- a/test/updaters/java-auth-versions.ts +++ b/test/updaters/java-auth-versions.ts @@ -18,7 +18,7 @@ import { readFileSync } from 'fs'; import { basename, resolve } from 'path'; import * as snapshot from 'snap-shot-it'; -import { JavaAuthVersions } from '../../src/updaters/java-auth-versions'; +import { VersionsManifest } from '../../src/updaters/java/versions-manifest'; import { UpdateOptions } from '../../src/updaters/update'; const fixturesPath = './test/updaters/fixtures'; @@ -30,7 +30,7 @@ describe('JavaAuthVersions', () => { resolve(fixturesPath, './java-auth-versions.txt'), 'utf8' ).replace(/\r\n/g, '\n'); - const javaAuthVersions = new JavaAuthVersions({ + const javaAuthVersions = new VersionsManifest({ path: 'versions.txt', changelogEntry: '', version: '0.25.0', @@ -45,7 +45,7 @@ describe('JavaAuthVersions', () => { resolve(fixturesPath, './java-auth-versions.txt'), 'utf8' ).replace(/\r\n/g, '\n'); - const javaAuthVersions = new JavaAuthVersions({ + const javaAuthVersions = new VersionsManifest({ path: 'versions.txt', changelogEntry: '', version: '0.16.2-SNAPSHOT', diff --git a/test/updaters/pom-xml.ts b/test/updaters/pom-xml.ts index eb98a49d6..61be62ca8 100644 --- a/test/updaters/pom-xml.ts +++ b/test/updaters/pom-xml.ts @@ -18,7 +18,7 @@ import { readFileSync } from 'fs'; import { basename, resolve } from 'path'; import * as snapshot from 'snap-shot-it'; -import { PomXML } from '../../src/updaters/pom-xml'; +import { PomXML } from '../../src/updaters/java/pom-xml'; import { UpdateOptions } from '../../src/updaters/update'; const fixturesPath = './test/updaters/fixtures';