Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): use file path inside git repository in git show command #2537

Merged
merged 1 commit into from
Feb 28, 2020

Conversation

jsaguet
Copy link
Contributor

@jsaguet jsaguet commented Feb 23, 2020

Use file's relative path inside git repository when running git show to identify affected .json files to fix an issue when nx workspace is not at the root of git repository

Current Behavior (This is the behavior we have today, before the PR is merged)

When NX workspace is not located at the root of git repository and we run affected commands using git repository (with --base option), we end up with the following kind of error message.

fatal: Path 'src/nx-repository-folder/package.json' exists, but not 'package.json'.
Did you mean 'origin/master:src/nx-repository-folder/package.json' aka 'origin/master:./package.json'?

It seems this problem occurs for .json files only.
When defaultReadFileAtRevision is executed, git show command is used with the file name.
In the case that NX workspace is not located at the root of git repository, the file path does not match the one inside the git repository which shows the above error.

Expected Behavior (This is the new behavior we can expect after the PR is merged)

The git show command is used with the file's relative path inside git repository folder and therefore the git command properly identifies the file even when NX workspace is not located at the root of git repository. (and error message is not shown anymore)

Issue

Closes #2292

@jsaguet jsaguet force-pushed the fix-2292 branch 3 times, most recently from c3be5d6 to 292ec6f Compare February 23, 2020 15:53
@jsaguet jsaguet changed the title fix(core): use file full path in git show fix(core): use file path in git repository in git show command Feb 23, 2020
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 nrwl#2292
@jsaguet jsaguet changed the title fix(core): use file path in git repository in git show command fix(core): use file path inside git repository in git show command Feb 24, 2020
@jsaguet jsaguet requested a review from vsavkin February 25, 2020 22:48
Copy link
Collaborator

@FrozenPandaz FrozenPandaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for your contribution!

LGTM!

@FrozenPandaz FrozenPandaz merged commit dfb0917 into nrwl:master Feb 28, 2020
vsavkin pushed a commit that referenced this pull request Mar 10, 2020
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
@ctaepper
Copy link

I guess this also closes #2404, will verify tomorrow

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

npm run affected:* broken when workspace is not in root folder of repo
3 participants