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: --no-stash flag implies --no-hide-partially-staged #1294

Closed
wants to merge 5 commits into from

Conversation

giladgd
Copy link
Contributor

@giladgd giladgd commented May 3, 2023

Changes

  • Added support for preventing lint-staged from hiding unstaged changes of partially staged files by using the new flag --no-hide-partially-staged
  • Made the --no-stash flag imply --no-hide-partially-staged

Description

Currently, when using the --no-stash flag, lint-staged discards all the unstaged changes to partially staged files, which results in unknowingly losing unstaged changes permanently.

Disabling that behavior by default will prevent that from happening without explicit consent.

@iiroj
Copy link
Member

iiroj commented May 4, 2023

Thanks for the PR! I'll need to have a closer look, but could this commit message be reworded as a fix?

feat: --no-stash flag implies --no-hide-partially-staged

@giladgd giladgd changed the title feat: add --no-hide-partially-staged flag, and imply it by --no-stash flag fix: --no-stash flag implies --no-hide-partially-staged May 4, 2023
@giladgd giladgd changed the title fix: --no-stash flag implies --no-hide-partially-staged fix: --no-stash flag implies --no-hide-partially-staged May 4, 2023
@codecov
Copy link

codecov bot commented May 4, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (cf691aa) 100.00% compared to head (56063e1) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #1294   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           26        26           
  Lines          740       753   +13     
  Branches       198       208   +10     
=========================================
+ Hits           740       753   +13     
Impacted Files Coverage Δ
lib/index.js 100.00% <100.00%> (ø)
lib/messages.js 100.00% <100.00%> (ø)
lib/runAll.js 100.00% <100.00%> (ø)
lib/state.js 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@iiroj
Copy link
Member

iiroj commented May 28, 2023

The new non-cli code needs some test coverage.

Comment on lines +124 to +125
hidePartiallyStaged:
cliOptions.hidePartiallyStaged == null ? !!cliOptions.stash : !!cliOptions.hidePartiallyStaged, // commander inverts `no-<x>` flags to `!x`
Copy link
Member

Choose a reason for hiding this comment

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

Can the flag be null or is only ever undefined? It would be nice to use strict equality === if possible.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, would this be equivalent to:

Suggested change
hidePartiallyStaged:
cliOptions.hidePartiallyStaged == null ? !!cliOptions.stash : !!cliOptions.hidePartiallyStaged, // commander inverts `no-<x>` flags to `!x`
hidePartiallyStaged:
cliOptions.hidePartiallyStaged ?? !!cliOptions.stash, // commander inverts `no-<x>` flags to `!x`

@iiroj
Copy link
Member

iiroj commented Jun 28, 2023

Can you rebase this after merging #1303?

@Kalay1994
Copy link

Are for you número mega sena python

@iiroj
Copy link
Member

iiroj commented Dec 2, 2023

I don't have permissions to update to this PR so I forked it locally: #1371

@iiroj iiroj closed this Dec 2, 2023
@giladgd
Copy link
Contributor Author

giladgd commented Dec 2, 2023

@iiroj Sorry for leaving this PR idle for so long, I think I missed the notifications of activity on it.
Thanks for merging it anyway :)

@iiroj
Copy link
Member

iiroj commented Dec 2, 2023

No problem, and thanks for the fix @giladgd. Unfortunately the automatic release notes will "thank" me instead of you, because it apparently looks at the PR author instead of the commit author. Oh well, at least the commit is attributed to you. 👍

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

Successfully merging this pull request may close these issues.

None yet

3 participants