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: disambiguate stash reference #906

Merged
merged 6 commits into from Aug 25, 2020

Conversation

philipbjorge
Copy link
Contributor

@philipbjorge philipbjorge commented Aug 18, 2020

Problem

#905

When you have a branch named stash, you receive the following error from lint-staged.

warning: refname 'stash' is ambiguous.
error: refname 'stash' is ambiguous
warning: refname 'stash' is ambiguous.
'--quiet stash@{0}' is not a stash reference 

Options

  1. Stashes are stored at refs/stash and we could update this line with refs/ to disambiguate
    https://github.com/okonet/lint-staged/blob/b078324d5e911ec5e667736b2c552af32f475751/lib/gitWorkflow.js#L102

  2. Convert the call from git stash list to git log -g --pretty="%gD %H %gs" refs/stash which returns the disambiguated stash refs (We'd need to introduce additional error handling as this command fails when there is no stash)

The Solution

I went with the simpler option of updating the string to refs/stash
I've added an integration test to verify this behavior.

@philipbjorge
Copy link
Contributor Author

philipbjorge commented Aug 19, 2020

Sweet -- There are integration tests!
I can't promise I'll have the time to update them and push this over the finish, but I'm glad to see they're there as this seemed useless to unit test.

@philipbjorge
Copy link
Contributor Author

@okonet -- Are you able to assist here? I've been unable to get a passing build on your CI even without any changes in my branch.

Locally, things look good and it also appears to be passing on Appveyor.

Screenshot 2020-08-23 14:21:32

https://ci.appveyor.com/project/okonet/lint-staged/builds/34808885

@okonet
Copy link
Collaborator

okonet commented Aug 24, 2020

It looks like the snapshot is failing and I'm wondering why:

    - Merge branch 'branch-b'
    + Merge branch 'branch-b' into master

Looks like a different version of git maybe?

@iiroj
Copy link
Member

iiroj commented Aug 24, 2020

That's probably it. Maybe the snapshot can be losened to assert it only contains the necessary bits.

@philipbjorge
Copy link
Contributor Author

@iiroj @okonet --
Is this something you'd like me to take a stab at fixing or is this something y'all would like to handle? It looks like this is affecting some other PRs as well.

@iiroj
Copy link
Member

iiroj commented Aug 24, 2020

@philipbjorge @okonet I updated dependencies and fixed the offending snapshot in #901

@codecov
Copy link

codecov bot commented Aug 25, 2020

Codecov Report

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

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #906   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           17        17           
  Lines          602       602           
  Branches       142       142           
=========================================
  Hits           602       602           
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 10b3218...762902f. Read the comment docs.

@iiroj iiroj changed the title Disambiguate stash reference fix: disambiguate stash reference Aug 25, 2020
@iiroj iiroj merged commit 51c5ac8 into lint-staged:master Aug 25, 2020
@iiroj
Copy link
Member

iiroj commented Aug 25, 2020

Thanks a lot @philipbjorge!

@github-actions
Copy link
Contributor

🎉 This PR is included in version 10.2.13 🎉

The release is available on:

Your semantic-release bot 📦🚀

@iiroj
Copy link
Member

iiroj commented Aug 25, 2020

@okonet seems master's Appveyor run failed randomly for this merge? At least the log looked like it didn't even start properly.

@philipbjorge
Copy link
Contributor Author

Thank you!
This tool is an absolute pleasure to use and it's been great to introduce to dev teams I've been a part of 🙏.

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.

None yet

3 participants