@nerdwallet/shepherd
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -63,6 +63,21 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const searchResults = yield octokit_1.paginateSearch(this.octokit, this.octokit.search.code, onRetry)({ | ||
q: this.migrationContext.migration.spec.adapter.search_query, | ||
}); | ||
const repoNames = searchResults.map((r) => r.repository.full_name).sort(); | ||
const { org, search_query } = this.migrationContext.migration.spec.adapter; | ||
let repoNames = []; | ||
// list all of an orgs repos | ||
if (org) { | ||
if (search_query) { | ||
throw new Error('Cannot use both "org" and "search_query" in GitHub adapter. Pick one.'); | ||
} | ||
const repos = yield octokit_1.paginate(this.octokit, this.octokit.repos.listForOrg, undefined, onRetry)({ | ||
org, | ||
}); | ||
repoNames = repos.map((r) => r.full_name).sort(); | ||
} | ||
else { | ||
// github code search query. results are less reliable | ||
const searchResults = yield octokit_1.paginateSearch(this.octokit, this.octokit.search.code, onRetry)({ | ||
q: search_query, | ||
}); | ||
repoNames = searchResults.map((r) => r.repository.full_name).sort(); | ||
} | ||
return lodash_1.default.uniq(repoNames).map((r) => this.parseRepo(r)); | ||
@@ -123,3 +138,3 @@ }); | ||
if (safetyStatus === SafetyStatus.PullRequestExisted) { | ||
throw new Error('Remote branch did not exist, but a pull request does or did; trye with --force?'); | ||
throw new Error('Remote branch did not exist, but a pull request does or did; try with --force?'); | ||
} | ||
@@ -140,3 +155,3 @@ else if (safetyStatus === SafetyStatus.NonShepherdCommits) { | ||
// Let's check if a PR already exists | ||
const { data: pullRequests } = yield this.octokit.pullRequests.getAll({ | ||
const { data: pullRequests } = yield this.octokit.pullRequests.list({ | ||
owner, | ||
@@ -182,3 +197,3 @@ repo: name, | ||
// First, check for a pull request | ||
const pullRequests = yield this.octokit.pullRequests.getAll({ | ||
const pullRequests = yield this.octokit.pullRequests.list({ | ||
owner, | ||
@@ -280,3 +295,3 @@ repo: name, | ||
// a branch yet | ||
const pullRequests = yield this.octokit.pullRequests.getAll({ | ||
const pullRequests = yield this.octokit.pullRequests.list({ | ||
owner, | ||
@@ -283,0 +298,0 @@ repo: name, |
@@ -61,3 +61,3 @@ "use strict"; | ||
pullRequests: { | ||
getAll: jest.fn().mockReturnValue(existingPr), | ||
list: jest.fn().mockReturnValue(existingPr), | ||
create: jest.fn(), | ||
@@ -64,0 +64,0 @@ update: jest.fn(), |
{ | ||
"name": "@nerdwallet/shepherd", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A utility for applying code changes across many repositories", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@octokit/rest": "^15.9.4", | ||
"@octokit/rest": "^15.18.1", | ||
"@types/js-yaml": "^3.11.2", | ||
@@ -75,3 +75,3 @@ "chalk": "^2.4.1", | ||
"@types/ora": "^1.3.4", | ||
"jest": "^23.4.1", | ||
"jest": "^23.6.0", | ||
"jest-plugin-fs": "^2.9.0", | ||
@@ -78,0 +78,0 @@ "ts-jest": "^23.0.1", |
@@ -74,3 +74,3 @@ # Shepherd | ||
* `title` specifies a human-readable title for the migration that will be used as the commit message. | ||
* `adapter` specifies what version control adapter should be used for performing operations on repos, as well as extra options for that adapter. Currently Shepherd only has a GitHub adapter, but you could create a Bitbucket or GitLab adapter if you don't use GitHub. Note that `search_query` is specific to the GitHub adapter: it uses GitHub's [code search qualifiers](https://help.github.com/articles/searching-code/) to identify repositories that are candidates for a migration. If a repository contains a file matching the search, it will be considered a candidate for this migration. | ||
* `adapter` specifies what version control adapter should be used for performing operations on repos, as well as extra options for that adapter. Currently Shepherd only has a GitHub adapter, but you could create a Bitbucket or GitLab adapter if you don't use GitHub. Note that `search_query` is specific to the GitHub adapter: it uses GitHub's [code search qualifiers](https://help.github.com/articles/searching-code/) to identify repositories that are candidates for a migration. If a repository contains a file matching the search, it will be considered a candidate for this migration. As an alternative to `search_query`, GitHub adapter can be configured with `org: YOURGITHUBORGANIZATION`. When using `org`, every repo in the organization that is visible will be considered as a candidate for this migration. | ||
@@ -77,0 +77,0 @@ The options under `hooks` specify the meat of a migration. They tell Shepherd how to determine if a repo should be migrated, how to actually perform the migration, how to generate a pull request message for each repository, and more. Each hook consists of one or more standard executables that Shepherd will execute in sequence. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
163632
1967
Updated@octokit/rest@^15.18.1