Skip to content

Commit

Permalink
fix(core): nx affected should not differ if in child directory
Browse files Browse the repository at this point in the history
  • Loading branch information
AgentEnder committed Feb 27, 2023
1 parent 729ff7e commit 5dd189f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/nx/src/utils/command-line-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { output } from './output';
import { NxJsonConfiguration } from '../config/nx-json';
import { execSync } from 'child_process';
import { ProjectGraph } from '../config/project-graph';
import { workspaceRoot } from './workspace-root';

export interface RawNxArgs extends NxArgs {
prod?: boolean;
Expand Down Expand Up @@ -235,12 +236,14 @@ function getFilesUsingBaseAndHead(base: string, head: string): string[] {
try {
mergeBase = execSync(`git merge-base "${base}" "${head}"`, {
maxBuffer: TEN_MEGABYTES,
cwd: workspaceRoot,
})
.toString()
.trim();
} catch {
mergeBase = execSync(`git merge-base --fork-point "${base}" "${head}"`, {
maxBuffer: TEN_MEGABYTES,
cwd: workspaceRoot,
})
.toString()
.trim();
Expand All @@ -251,7 +254,7 @@ function getFilesUsingBaseAndHead(base: string, head: string): string[] {
}

function parseGitOutput(command: string): string[] {
return execSync(command, { maxBuffer: TEN_MEGABYTES })
return execSync(command, { maxBuffer: TEN_MEGABYTES, cwd: workspaceRoot })
.toString('utf-8')
.split('\n')
.map((a) => a.trim())
Expand Down

0 comments on commit 5dd189f

Please sign in to comment.