Skip to content

Commit

Permalink
feat: enable searching for repositories with Github adapter (#353)
Browse files Browse the repository at this point in the history
* feat: enable using search_type param with github adapter

* fix: update error message

Co-authored-by: Nathan Walters <nwalters512@gmail.com>

* chore: implement suggested PR modifications

* chore: update readme

* chore: minor enhancement to the error message

* chore: update packages

* chore: update package typings

* fix: passthrough of force cli option

* chore: start adding tests

* chore: test additions

* chore: update tests

* chore: update tests

* chore: minor test cleanups

* chore: lint fixes

* chore: revert simple-git upgrade

* chore: minor cleanups

* chore: dont pin simple-git

* chore: update tutorial

Co-authored-by: Nathan Walters <nwalters512@gmail.com>
Co-authored-by: Aori Nevo <aorin@amazon.com>
  • Loading branch information
3 people authored Jan 8, 2021
1 parent 0009775 commit fd47f96
Show file tree
Hide file tree
Showing 6 changed files with 4,064 additions and 2,797 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ id: 2018.07.16-eslintrc-json
title: Rename all .eslintrc files to .eslintrc.json
adapter:
type: github
search_type: code
search_query: org:NerdWallet path:/ filename:.eslintrc
hooks:
should_migrate:
Expand All @@ -72,6 +73,7 @@ Let's go through this line-by-line:
* `id` specifies a unique identifier for this migration. It will be used as a branch name for this migration, and will be used internally by Shepherd to track state about the migration.
* `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. 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.
* `search_type` (optional): specifies search type - either 'code' or 'repositories'. If repositories is specified, it does a [Github repository search](https://docs.github.com/en/free-pro-team@latest/github/searching-for-information-on-github/searching-for-repositories). Defaults to code search if not specified.

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.

Expand Down
9 changes: 9 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ adapter:
org: YOURORGANIZATION
```

**Note:** while for purposes of this tutorial, searching codebases for a file is exactly what we want, other use cases may call for different types of searching, which Github supports. In addition to searching code, shepherd also allows you to do a search of repository metadata. For example, if your repo had an associated 'eslint-repo' topic:

```yml
#shepherd.yml
adapter:
type: github
search_type: repository
search_query: topic:eslint-repo
```

## Filtering repositories

Expand Down
Loading

0 comments on commit fd47f96

Please sign in to comment.