Skip to content

Commit 9e6409a

Browse files
committed
rename; reorder; fix CLI.md
1 parent cccbb01 commit 9e6409a

14 files changed

Lines changed: 36 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
* `[jest-cli]` Make Jest exit without an error when no tests are found in the
1313
case of `--lastCommit`, `--findRelatedTests`, or `--onlyChanged` options
1414
having been passed to the CLI
15-
* `[jest-cli]` Allow selectively running tests for code changed since arbitrary
16-
revisions. ([#5188](https://github.com/facebook/jest/pull/5188))
15+
* `[jest-cli]` `--changedSince`: allow selectively running tests for code
16+
changed since arbitrary revisions.
17+
([#5312](https://github.com/facebook/jest/pull/5312))
1718

1819
### Fixes
1920
* `[jest-cli]` Use `import-local` to support global Jest installations.

docs/CLI.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ two times slower._
103103
If you want to inspect the cache, use `--showConfig` and look at the
104104
`cacheDirectory` value. If you need to clear the cache, use `--clearCache`.
105105

106-
### `--changedFilesToContributeTo`
107-
108-
When used together with `--onlyChanged` or `--watch`, it runs tests related the
109-
changes since the provided revision. If the current branch is not a child of the
110-
given commit, then only changes made locally will be tested.
111-
112106
### `--changedFilesWithAncestor`
113107

114108
Runs tests related to the current changes and the changes made in the last
115109
commit. Behaves similarly to `--onlyChanged`.
116110

111+
### `--changedSince`
112+
113+
Runs tests related the changes since the provided branch. If the current branch
114+
has diverged from the given branch, then only changes made locally will be
115+
tested. Behaves similarly to `--onlyChanged`.
116+
117117
### `--ci`
118118

119119
When this option is provided, Jest will assume it is running in a CI

integration-tests/__tests__/jest_changed_files.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test('gets changed files for git', async () => {
196196
run(`${GIT} commit -m "test3"`, DIR);
197197

198198
({changedFiles: files} = await getChangedFilesForRoots(roots, {
199-
toContributeTo: 'HEAD^^',
199+
changedSince: 'HEAD^^',
200200
}));
201201
// Returns files from the last 2 commits
202202
expect(
@@ -214,7 +214,7 @@ test('gets changed files for git', async () => {
214214
run(`${GIT} commit -m "test5"`, DIR);
215215

216216
({changedFiles: files} = await getChangedFilesForRoots(roots, {
217-
toContributeTo: 'master',
217+
changedSince: 'master',
218218
}));
219219
// Returns files from this branch but not ones that only exist on master
220220
expect(
@@ -297,7 +297,7 @@ test('gets changed files for hg', async () => {
297297
run(`${HG} commit -m "test3"`, DIR);
298298

299299
({changedFiles: files} = await getChangedFilesForRoots(roots, {
300-
toContributeTo: '-3',
300+
changedSince: '-3',
301301
}));
302302
// Returns files from the last 2 commits
303303
expect(
@@ -317,7 +317,7 @@ test('gets changed files for hg', async () => {
317317
run(`${HG} commit -m "test4"`, DIR);
318318

319319
({changedFiles: files} = await getChangedFilesForRoots(roots, {
320-
toContributeTo: 'master',
320+
changedSince: 'master',
321321
}));
322322
// Returns files from this branch but not ones that only exist on master
323323
expect(

packages/jest-changed-files/src/git.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ const adapter: SCMAdapter = {
4949
cwd: string,
5050
options?: Options,
5151
): Promise<Array<Path>> => {
52-
const toContributeTo: ?string =
53-
options && (options.withAncestor ? 'HEAD^' : options.toContributeTo);
52+
const changedSince: ?string =
53+
options && (options.withAncestor ? 'HEAD^' : options.changedSince);
5454

5555
if (options && options.lastCommit) {
5656
return await findChangedFilesUsingCommand(
5757
['show', '--name-only', '--pretty=%b', 'HEAD'],
5858
cwd,
5959
);
60-
} else if (toContributeTo) {
60+
} else if (changedSince) {
6161
const committed = await findChangedFilesUsingCommand(
62-
['log', '--name-only', '--pretty=%b', 'HEAD', `^${toContributeTo}`],
62+
['log', '--name-only', '--pretty=%b', 'HEAD', `^${changedSince}`],
6363
cwd,
6464
);
6565
const staged = await findChangedFilesUsingCommand(

packages/jest-changed-files/src/hg.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ const adapter: SCMAdapter = {
2626
let args = ['status', '-amnu'];
2727
if (options && options.withAncestor) {
2828
args.push('--rev', 'ancestor(.^)');
29-
} else if (options && options.toContributeTo) {
30-
args.push('--rev', `ancestor(., ${options.toContributeTo})`);
29+
} else if (options && options.changedSince) {
30+
args.push('--rev', `ancestor(., ${options.changedSince})`);
3131
} else if (options && options.lastCommit === true) {
3232
args = ['tip', '--template', '{files%"{file}\n"}'];
3333
}

packages/jest-cli/src/cli/args.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const check = (argv: Argv) => {
2424
'onlyChanged',
2525
'lastCommit',
2626
'changedFilesWithAncestor',
27-
'changedFilesToContributeTo',
27+
'changedSince',
2828
]) {
2929
if (argv[key]) {
3030
argv.onlyChanged = true;
@@ -112,20 +112,20 @@ export const options = {
112112
' dependency information.',
113113
type: 'string',
114114
},
115-
changedFilesToContributeTo: {
115+
changedFilesWithAncestor: {
116+
description:
117+
'Runs tests related to the current changes and the changes made in the ' +
118+
'last commit. Behaves similarly to `--onlyChanged`.',
119+
type: 'boolean',
120+
},
121+
changedSince: {
116122
description:
117123
'Runs tests related the changes since the provided branch. If the ' +
118124
'current branch has diverged from the given branch, then only changes ' +
119125
'made locally will be tested. Behaves similarly to `--onlyChanged`.',
120126
nargs: 1,
121127
type: 'string',
122128
},
123-
changedFilesWithAncestor: {
124-
description:
125-
'Runs tests related to the current changes and the changes made in the ' +
126-
'last commit. Behaves similarly to `--onlyChanged`.',
127-
type: 'boolean',
128-
},
129129
ci: {
130130
default: isCI,
131131
description:

packages/jest-cli/src/get_changed_files_promise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ export default (
2121
[],
2222
);
2323
return getChangedFilesForRoots(allRootsForAllProjects, {
24+
changedSince: globalConfig.changedSince,
2425
lastCommit: globalConfig.lastCommit,
25-
toContributeTo: globalConfig.changedFilesToContributeTo,
2626
withAncestor: globalConfig.changedFilesWithAncestor,
2727
});
2828
}

packages/jest-config/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ const getConfigs = (
9393
return {
9494
globalConfig: Object.freeze({
9595
bail: options.bail,
96-
changedFilesToContributeTo: options.changedFilesToContributeTo,
9796
changedFilesWithAncestor: options.changedFilesWithAncestor,
97+
changedSince: options.changedSince,
9898
collectCoverage: options.collectCoverage,
9999
collectCoverageFrom: options.collectCoverageFrom,
100100
collectCoverageOnlyFrom: options.collectCoverageOnlyFrom,

packages/jest-config/src/normalize.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ export default function normalize(options: InitialOptions, argv: Argv) {
461461
case 'bail':
462462
case 'browser':
463463
case 'cache':
464-
case 'changedFilesToContributeTo':
464+
case 'changedSince':
465465
case 'changedFilesWithAncestor':
466466
case 'clearMocks':
467467
case 'collectCoverage':

packages/jest-config/src/valid_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export default ({
2020
browser: false,
2121
cache: true,
2222
cacheDirectory: '/tmp/user/jest',
23-
changedFilesToContributeTo: '',
2423
changedFilesWithAncestor: false,
24+
changedSince: '',
2525
clearMocks: false,
2626
collectCoverage: true,
2727
collectCoverageFrom: ['src', '!public'],

0 commit comments

Comments
 (0)