[go: up one dir, main page]

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

Use machine output for listing partially staged files #876

Merged

Conversation

johnnywalker
Copy link
Contributor

When a partially staged file name contains one or more spaces or special characters, git status --porcelain escapes and quotes the file name (see https://github.com/okonet/lint-staged/blob/master/lib/gitWorkflow.js#L161). Consequently, gitWorkflow.hideUnstagedChanges() fails with a pathspec error since execa expects arguments to not be escaped or quoted:

[SUCCESS] Preparing...
[STARTED] Hiding unstaged changes to partially staged files...
[FAILED] error: pathspec '"src/file with spaces.ts"' did not match any file(s) known to git

  ✖ lint-staged failed due to a git error.
  Any lost modifications can be restored from a git stash:

    > git stash list
    stash@{0}: automatic lint-staged backup
    > git stash apply --index stash@{0}

This PR resolves the problem by using the machine output from git-status instead. Note: the order of renamed files in the status output is reversed and separated by a NUL character (instead of ->) when machine output (-z option) is specified.

@codecov
Copy link
codecov bot commented May 29, 2020

Codecov Report

Merging #876 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #876   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          597       597           
  Branches       142       142           
=========================================
  Hits           597       597           
Impacted Files Coverage Δ
lib/gitWorkflow.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 979da5d...390d168. Read the comment docs.

Copy link
Member
@iiroj iiroj left a comment

Choose a reason for hiding this comment

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

Can't say anything else other than great work, and thanks for the PR!

@iiroj iiroj merged commit 21a2b41 into lint-staged:master May 29, 2020
@github-actions
Copy link
Contributor

🎉 This PR is included in version 10.2.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@johnnywalker
Copy link
Contributor Author

@iiroj Appreciate the note and thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants