@nerdwallet/shepherd
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -265,3 +265,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { owner, name, defaultBranch } = repo; | ||
const { owner, name } = repo; | ||
// Get all branches and look for the remote branch | ||
@@ -292,6 +292,4 @@ // @ts-ignore (typings are broken) | ||
// master. | ||
const commits = yield this.git(repo).log({ | ||
from: defaultBranch, | ||
to: `remotes/origin/${this.branchName}`, | ||
}); | ||
const upstreamBranch = `remotes/origin/${this.branchName}`; | ||
const commits = yield this.git(repo).log([`HEAD..${upstreamBranch}`]); | ||
const allShepherd = commits.all.every(({ message }) => this.isShepherdCommitMessage(message)); | ||
@@ -298,0 +296,0 @@ if (!allShepherd) { |
{ | ||
"name": "@nerdwallet/shepherd", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A utility for applying code changes across many repositories", | ||
@@ -79,3 +79,6 @@ "keywords": [ | ||
"typescript": "^3.0.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
# Shepherd | ||
![Travis status](https://img.shields.io/travis/NerdWalletOSS/shepherd/master.svg?style=flat-square) | ||
![npm version](https://img.shields.io/npm/v/@nerdwallet/shepherd.svg?style=flat-square) | ||
![GitHub issues](https://img.shields.io/github/issues/NerdWalletOSS/shepherd.svg?style=flat-square) | ||
Shepherd is a utility for applying code changes across many repositories. | ||
@@ -9,3 +13,3 @@ | ||
**Note**: This software should be considered a beta product: it's subject to change without notice as we explore new ideas and best practices. | ||
For more high level context, this [blog post](https://www.nerdwallet.com/blog/engineering/shepherd-automating-code-changes/) covers the basics. | ||
@@ -75,3 +79,3 @@ ## Getting started | ||
* `post_checkout` is a sequence of commands to be executed once a repo has been checked out and passed any `should_migrate` checks. This is a convenient place to do anything that will only need to be done once per repo, such as installing any dependencies. | ||
* `apply` is a sequence of commands that will actually execute the migration. This example is very simple: we're just using `mv` to rename a file. However, this hook could contain arbitrarily many, potentially complex commands, depending on the requirements of your particualr migration. | ||
* `apply` is a sequence of commands that will actually execute the migration. This example is very simple: we're just using `mv` to rename a file. However, this hook could contain arbitrarily many, potentially complex commands, depending on the requirements of your particular migration. | ||
* `pr_message` is a sequence of commands that will be used to generate a pull request message for a repository. In the simplest case, this can just be a static message, but you could also programmatically generate a message that calls out particular things that might need human attention. Anything written to `stdout` will be used for the message. If multiple commands are specified, the output from each one will be concatenated together. | ||
@@ -81,3 +85,3 @@ | ||
Each of these commands will be executed with the workign directory set to the target repository. Shepherd exposes some context to each command via specific environment variables: | ||
Each of these commands will be executed with the working directory set to the target repository. Shepherd exposes some context to each command via specific environment variables: | ||
@@ -88,5 +92,5 @@ * `SHEPHERD_REPO_DIR` is the absolute path to the repository being operated on. This will be the working directory when commands are executed. | ||
```yml | ||
pr_message: $SHEPHERD_MIGRATION_DIR/pr.sh | ||
``` | ||
```yml | ||
pr_message: $SHEPHERD_MIGRATION_DIR/pr.sh | ||
``` | ||
@@ -114,9 +118,9 @@ Commands follow standard Unix conventions: an exit code of 0 indicates a command succeeded, a non-zero exit code indicates failure. | ||
Currently, the only supported option is `--repos`, which allows you to specifiy a comma-separated list of repos that should be operated on. An example usage of this option: | ||
By default, `checkout` will use the adapter to figure out which repositories to check out, and the remaining commands will operate on all checked-out repos. To only checkout a specific repo or to operate on only a subset of the checked-out repos, you can use the `--repos` flag, which specifies a comma-separated list of repos: | ||
```sh | ||
shepherd checkout ~/path/to/migration --repos facebook/react,google/protobuf | ||
shepherd checkout path/to/migration --repos facebook/react,google/protobuf | ||
``` | ||
Run `shepherd --help` to see available commands and descriptions for each one. | ||
Run `shepherd --help` to see all available commands and descriptions for each one. | ||
@@ -127,2 +131,6 @@ ### Developing | ||
Shepherd is written in TypeScript, which requires compilation to JavaScript. When developing Shepherd, it's recommended to run `npm run build:watch` in a separate terminal. This will constantly recompile the source code as you edit it. | ||
Shepherd is written in TypeScript, which requires compilation to JavaScript. When developing Shepherd, it's recommended to run `npm run build:watch` in a separate terminal. This will incrementally compile the source code as you edit it. | ||
Shepherd currently has minimal test coverage, but we're aiming to improve that with each new PR. Tests are written with Jest and should be named in a `*.test.ts` alongside the file under test. To run the test suite, run `npm run test`. | ||
We use [TSLint](https://github.com/palantir/tslint) to ensure a consistent coding style and to help prevent certain classes of problems. Run `npm run lint` to run the linter, and `npm run fix-lint` to automatically fix applicable problems. |
Sorry, the diff of this file is not supported yet
160170
85
131
1929