Skip to content

Commit

Permalink
chore: remove unnecessary checks
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Feb 8, 2022
1 parent 506a062 commit 55caeb7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
12 changes: 5 additions & 7 deletions packages/jest-changed-files/src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ const findChangedFilesUsingCommand = async (

const adapter: SCMAdapter = {
findChangedFiles: async (cwd, options) => {
const changedSince: string | undefined =
options && (options.withAncestor ? 'HEAD^' : options.changedSince);
const changedSince = options.withAncestor ? 'HEAD^' : options.changedSince;

const includePaths: Array<Config.Path> = (
(options && options.includePaths) ||
[]
).map(absoluteRoot => path.normalize(path.relative(cwd, absoluteRoot)));
const includePaths = (options.includePaths ?? []).map(absoluteRoot =>
path.normalize(path.relative(cwd, absoluteRoot)),
);

if (options && options.lastCommit) {
if (options.lastCommit) {
return findChangedFilesUsingCommand(
['show', '--name-only', '--pretty=format:', 'HEAD', '--'].concat(
includePaths,
Expand Down
10 changes: 4 additions & 6 deletions packages/jest-changed-files/src/hg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,20 @@

import * as path from 'path';
import execa = require('execa');
import type {Config} from '@jest/types';
import type {SCMAdapter} from './types';

const env = {...process.env, HGPLAIN: '1'};

const adapter: SCMAdapter = {
findChangedFiles: async (cwd, options) => {
const includePaths: Array<Config.Path> =
(options && options.includePaths) || [];
const includePaths = options.includePaths ?? [];

const args = ['status', '-amnu'];
if (options && options.withAncestor) {
if (options.withAncestor) {
args.push('--rev', 'min((!public() & ::.)+.)^');
} else if (options && options.changedSince) {
} else if (options.changedSince) {
args.push('--rev', `ancestor(., ${options.changedSince})`);
} else if (options && options.lastCommit === true) {
} else if (options.lastCommit === true) {
args.push('--change', '.');
}
args.push(...includePaths);
Expand Down

0 comments on commit 55caeb7

Please sign in to comment.