Skip to content

Commit

Permalink
fixup! WIP: --changedFilesSinceCommit=origin/master + hg support
Browse files Browse the repository at this point in the history
Turns out hacking things out drunkenly at midnight on a Friday
isn't the greatest way to get high-quality code.
  • Loading branch information
alsuren committed Jan 14, 2018
1 parent 8f15c74 commit 933e33a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions integration-tests/__tests__/jest_changed_files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ test('gets changed files for git', async () => {
writeFiles(DIR, {
'file5.txt': 'file5',
});
run(`${GIT} commit -am "test5"`, DIR);
run(`${GIT} add file5.txt`, DIR);
run(`${GIT} commit -m "test5"`, DIR);

({changedFiles: files} = await getChangedFilesForRoots(roots, {
sinceCommit: 'master',
Expand Down Expand Up @@ -292,10 +293,11 @@ test('gets changed files for hg', async () => {
.sort(),
).toEqual(['file1.txt', 'file4.txt']);

run(`${HG} add file4.txt`, DIR);
run(`${HG} commit -m "test3"`, DIR);

({changedFiles: files} = await getChangedFilesForRoots(roots, {
sinceCommit: '-2',
sinceCommit: '-3',
}));
// Returns files from the last 2 commits
expect(
Expand All @@ -311,7 +313,8 @@ test('gets changed files for hg', async () => {
writeFiles(DIR, {
'file5.txt': 'file5',
});
run(`${HG} commit -am "test5"`, DIR);
run(`${HG} add file5.txt`, DIR);
run(`${HG} commit -m "test4"`, DIR);

({changedFiles: files} = await getChangedFilesForRoots(roots, {
sinceCommit: 'master',
Expand Down
1 change: 1 addition & 0 deletions packages/jest-changed-files/src/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const findChangedFilesUsingCommand = async (
resolve(
stdout
.split('\n')
.filter(s => s !== '')
.map(changedPath => path.resolve(cwd, changedPath)),
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-changed-files/src/hg.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const adapter: SCMAdapter = {
if (options && options.withAncestor) {
args.push('--rev', 'ancestor(.^)');
} else if (options && options.sinceCommit) {
args.push(`--rev', 'ancestor(., ${options.sinceCommit})`);
args.push('--rev', `ancestor(., ${options.sinceCommit})`);
} else if (options && options.lastCommit === true) {
args = ['tip', '--template', '{files%"{file}\n"}'];
}
Expand Down

0 comments on commit 933e33a

Please sign in to comment.