Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0a2d5be

Browse files
jsaguetvsavkin
authored andcommittedMar 10, 2020
fix(core): use file full path in git show (#2537)
Use file full path in git show to identify affected files to fix an issue when nx workspace is not at the root of git repository Closes #2292
1 parent 17418a8 commit 0a2d5be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎packages/workspace/src/core/file-utils.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,17 @@ function defaultReadFileAtRevision(
8989
revision: void | string
9090
): string {
9191
try {
92+
const fileFullPath = `${appRootPath}${path.sep}${file}`;
93+
const gitRepositoryPath = execSync('git rev-parse --show-toplevel')
94+
.toString()
95+
.trim();
96+
const filePathInGitRepository = path
97+
.relative(gitRepositoryPath, fileFullPath)
98+
.split(path.sep)
99+
.join('/');
92100
return !revision
93101
? readFileSync(file).toString()
94-
: execSync(`git show ${revision}:${file}`, {
102+
: execSync(`git show ${revision}:${filePathInGitRepository}`, {
95103
maxBuffer: TEN_MEGABYTES
96104
})
97105
.toString()

0 commit comments

Comments
 (0)
Please sign in to comment.