-
-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support for git restore #51
Conversation
Nice!
I'll take a look at the test issue soon. |
Thanks for the feedback! I've backed out the changes to |
Ah gotcha. Looking through the tests, I think it might be possible the reason this is failing on travis-ci may be it has an older version of git installed which doesnt contain the new commands? The announcement you linked seems to suggest they came out almost a full year ago though.. 🤔 |
Definitely a possibility. But the tests don't pass on my machine either – which definitely has a recent git. Are there some intricacies to how the test environment gets its output for |
Oops, I missed that part.
Hmm. Depending on the shell, If you build the binary locally, does it work if you go through the test steps manually in a shell? (versus running the tests) This may also be a case of my old tooling scripts causing some issues in the build... I'll try to take a look at that this weekend. |
It seems to work for me, yep:
|
Okay, I believe I figured it out! The isolated test functions in a new git repo. When I did the exact test steps on a new local repo here (but without using scmpuff), I got an error on the I made a new test that replicates the flow you showed in the output above (e..g modifying an existing committed file), which appears to pass locally: Scenario Outline: Wrapped `git restore` works
Given I am in a git repository
And a 2 byte file named "foo.bar"
And I successfully run `git add foo.bar`
And I successfully run `git commit -m "initial commit"`
And a 4 byte file named "foo.bar"
And I successfully run `git add foo.bar`
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -ws)"`
And I type "scmpuff_status"
And I type "git restore --staged 1"
And I type "exit"
Then the exit status should be 0
When I run `scmpuff status`
Then the stdout from "scmpuff status" should contain:
"""
➤ Changes not staged for commit
#
# modified: [1] foo.bar
"""
Examples:
| shell |
| bash |
| zsh | I also re-ran the go-bindata with the most recent version (installed via homebrew) which appears to have cleaned up some of the extraneous changes in the bindata file. I can't seem to push these fixes to the branch directly, perhaps this setting needs to be enabled? https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork Alternatively, I can help out if you want to make them directly. |
Thanks for the troubleshooting! I've updated the test, which now passes for me locally (though not on Travis, still). I've also allowed maintainers to have access, so you can push the bindata changes to my branch. Let me know if I can help out further, here. :) |
For some reason I still can't push the changes to the branch, perhaps I misunderstand the GitHub settings. Perhaps easiest if you just upgrade your copy of go-bindata (if you're on a Mac, it's in home-brew) and re-run For travis-ci, I believe we can opt into a more recent version of their build environment via |
Weirdly, when I came back to this pull request that flag had switched back to off. Chances are I misclicked last time – sorry for that. I've tried toggling it back on, and it seems to have stuck, so hopefully you can push to the branch. Sorry for the trouble.
I am on a Mac – I installed go-bindata with Homebrew. This didn't immediately work – it turns out I had an older version built in my |
Should contain a more recent version of git.
There was a previous test that only worked on recent versions of git, so replicate that tag, but since we've now upgraded travis we can remove the restrictions on runs there.
go-bindata wants to use the %w formatting directive for Errorf in its generated files, which requires >= go1.13.
Go modules assumes the vendor directory is for go modules if it exists, so lets use something else to install bundler gems as a quick workaround
This behavior appears to have changed again in more recent versions of git, as the test case does not trigger the expected condition during `git status --short` before even testing scmpuff. Disabling this test for now until it can be reproduced reliably in modern git.
@creature Phew, I believe things are working now. Take a look at the changes I pushed (mostly CI related) and let me know what you think (and that they still work for you locally). Thanks! |
Sorry for the slow reply here! Looks great to me, and the tests/updates work locally for me too. Thanks again for the help getting this going, I'm glad to see it all squared away. :) |
Git recently added a couple of new commands, to reduce overloading of
git checkout
:git switch
(for changing branches) andgit restore
(for undoing changes to files). Notably,git status
no longer recommendsgit reset HEAD foo.bar
to unstage files aftergit add
ing them; instead, it recommendsgit restore --staged foo.bar
. It'd be nice if scmpuff supported this.This PR contains two commits:
restore
to the list of commands eligible to be passed toscmpuff expand --relative
ingit_wrapper.sh
, and a test for this.bindata.go
will need to be updated, for sure, as that contains a serialised copy ofgit_wrapper.sh
.This PR is not ready to be merged, though:
bindata.go
that aren't related togit_wrapper.sh
, along with changes togo.mod
andgo.sum
. I'm not sure where these have come from (I'm very new to Go) - maybe these are holdovers from an older version of the repo? Or because I'm using Go 1.14.3?foo.bar
file remains staged.I'd love some feedback or pointers regarding the above so I can improve it!