diff --git a/.travis.yml b/.travis.yml index 65d52c2..666ebb6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -sudo: false +dist: bionic language: go go: - - 1.12 + - 1.14 env: - GO111MODULE=on @@ -16,18 +16,18 @@ addons: - zsh install: - - bundle install --jobs 4 --retry 3 --path vendor/bundle + - bundle install --jobs 4 --retry 3 --path rbvendor/bundle - go mod download script: - go test ./... - script/build - - bundle exec cucumber -s --tags=~@wip --tags=~@recent-git-only + - bundle exec cucumber -s --tags=~@wip before_cache: - bundle clean cache: directories: - - vendor/bundle + - rbvendor/bundle - $GOPATH/pkg/mod diff --git a/commands/inits/bindata.go b/commands/inits/bindata.go index c7bfd80..eb0997d 100644 --- a/commands/inits/bindata.go +++ b/commands/inits/bindata.go @@ -1,7 +1,7 @@ // Code generated by go-bindata. DO NOT EDIT. // sources: // data/aliases.sh (131B) -// data/git_wrapper.sh (698B) +// data/git_wrapper.sh (706B) // data/status_shortcuts.sh (1.288kB) package inits @@ -22,7 +22,7 @@ import ( func bindataRead(data []byte, name string) ([]byte, error) { gz, err := gzip.NewReader(bytes.NewBuffer(data)) if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } var buf bytes.Buffer @@ -30,7 +30,7 @@ func bindataRead(data []byte, name string) ([]byte, error) { clErr := gz.Close() if err != nil { - return nil, fmt.Errorf("read %q: %v", name, err) + return nil, fmt.Errorf("read %q: %w", name, err) } if clErr != nil { return nil, err @@ -91,7 +91,7 @@ func dataAliasesSh() (*asset, error) { return a, nil } -var _dataGit_wrapperSh = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x8f\x41\x6b\x14\x41\x10\x85\xef\xfd\x2b\x1e\x93\xc1\xec\x8a\x4b\x88\xd7\xc5\x20\x44\x22\x1e\x02\xa2\x06\x2f\xc2\x52\x33\x53\xbd\x53\xd8\xd3\x3d\x74\x57\xcf\x26\x38\xfe\x77\xe9\xc9\xc6\x43\x70\x51\xf0\x5a\xf5\xde\xf7\x55\x9d\xe1\x13\x0f\x61\x62\x90\x7f\x00\xdf\x4b\x52\xf1\x7b\xec\x45\x41\x4e\x28\x21\x44\xd8\xec\x5b\x95\xe0\x4d\xf6\x8f\xb3\xb2\xbd\xc2\x45\xc7\xd3\x85\xcf\xce\xe1\xf5\xd5\x8b\x4b\x93\x7d\x62\xc5\xc6\xfe\x79\x6b\xce\x70\x97\x18\xda\x33\x6c\x19\x8e\xa4\x3d\x34\x2c\x61\x0d\xa0\x29\x48\x07\xf1\x56\xbc\x28\xc3\x85\x30\xe2\x20\xda\x2f\xfb\xdf\x7e\xbe\x1f\x43\x54\x7c\xbe\xbe\xfd\x78\x77\x73\xb3\x7b\xff\xe1\xcb\xee\xfa\xf6\xdd\x9b\xaa\x5e\x7d\x3b\xf4\xd2\x2e\xe9\x75\x55\x5c\x5f\x23\x8d\x4b\x77\x81\x14\xeb\x79\x9f\x9b\xf3\x32\xea\x73\x83\x43\xa4\x71\xe4\xf8\x0a\x62\x21\x3e\x29\x39\xc7\x9d\x11\x0b\x7d\x18\x19\x25\xf1\xfc\x81\x6d\x81\x78\x9c\xba\xa0\xcf\x4d\xb5\x85\x15\x63\x9e\x8e\x2d\xaa\xd5\x1a\x3f\x0c\xd0\x52\x62\xd4\x97\x10\x6f\x00\xa0\x0d\xc3\x20\x3a\x37\x8e\x06\x9e\x5d\xd8\xcf\x91\x1b\x4a\x3c\x0f\x1c\xf7\xbc\x5e\x22\x00\x4f\xe4\x50\xd5\xab\xd4\x0e\x63\xb6\xb6\x88\xc9\x77\xd8\x6c\x50\xd5\xcf\xec\x15\xaa\xfa\x6d\xb5\xae\xb6\xdb\x47\x7c\xcf\xed\xf7\x90\x75\xee\xc4\xda\x39\x0e\x73\xe4\xc4\xfa\x57\x6e\x64\x47\x2a\x13\xff\x8b\x82\xba\xee\x3f\xee\x3c\x36\x8f\x8d\x5d\x52\xd2\x9c\x8e\xe4\x97\x4f\xdc\x13\xed\x25\xc6\x89\x5a\xf3\xd3\xfc\x0a\x00\x00\xff\xff\x93\x56\x0f\x71\xba\x02\x00\x00") +var _dataGit_wrapperSh = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x8f\x41\x6b\x14\x41\x10\x85\xef\xfd\x2b\x1e\x93\xc1\xec\x8a\x4b\x88\xd7\xc5\x20\x44\x22\x1e\x02\xa2\x06\x2f\xc2\x52\x33\x53\xbd\x53\xd8\xd3\x3d\x74\x57\xcf\x26\x38\xfe\x77\xe9\xc9\xc6\x43\x70\x51\xf0\xd2\x87\xaa\xf7\xbe\xaf\xfa\x0c\x9f\x78\x08\x13\x83\xfc\x03\xf8\x5e\x92\x8a\xdf\x63\x2f\x0a\x72\x42\x09\x21\xc2\x66\xdf\xaa\x04\x6f\xb2\x7f\x9c\x95\xed\x15\x2e\x3a\x9e\x2e\x7c\x76\x0e\xaf\xaf\x5e\x5c\x9a\xec\x13\x2b\x36\xf6\xcf\x5b\x73\x86\xbb\xc4\xd0\x9e\x61\xcb\x70\x24\xed\xa1\x61\x09\x6b\x00\x4d\x41\x3a\x88\xb7\xe2\x45\x19\x2e\x84\x11\x07\xd1\x7e\xd9\xff\xf6\xf3\xfd\x18\xa2\xe2\xf3\xf5\xed\xc7\xbb\x9b\x9b\xdd\xfb\x0f\x5f\x76\xd7\xb7\xef\xde\x54\xf5\xea\xdb\xa1\x97\x76\x49\xaf\xab\xe2\xfa\x1a\x69\x5c\xba\x0b\xa4\x58\xcf\xfb\xdc\x9c\x97\x51\x9f\x1b\x1c\x22\x8d\x23\xc7\x57\x10\x0b\xf1\x49\xc9\x39\xee\x8c\x58\xe8\xc3\xc8\x28\x89\xe7\x1f\xd8\x16\x88\xc7\xa9\x0b\xfa\xdc\x54\x5b\x58\x31\xe6\xe9\xd8\xa2\x5a\xad\xf1\xc3\x00\x2d\x25\x46\x7d\x09\xf1\x06\x00\xda\x30\x0c\xa2\x73\xe3\x68\xe0\xd9\x85\xfd\x1c\xb9\xa1\xc4\xf3\xc0\x71\xcf\xeb\x25\x02\xf0\x44\x0e\x55\xbd\x4a\xed\x30\x66\x6b\x8b\x98\x7c\x87\xcd\x06\x55\xfd\xcc\x5e\xa1\xaa\xdf\x56\xeb\x6a\xbb\x7d\xc4\xf7\xdc\x7e\x0f\x59\xe7\x4e\xac\x9d\xe3\x30\x47\x4e\xac\xe5\xd5\x10\xff\xce\x8f\xec\x48\x65\xe2\x7f\x51\x51\xd7\xfd\xc7\xbd\xc7\xe6\xb1\xb1\x4b\x4a\x9a\xd3\x91\xfc\xf2\x89\x7b\xa2\xbd\xc4\x38\x51\x6b\x7e\x9a\x5f\x01\x00\x00\xff\xff\x17\xa5\xb3\x5b\xc2\x02\x00\x00") func dataGit_wrapperShBytes() ([]byte, error) { return bindataRead( @@ -106,8 +106,8 @@ func dataGit_wrapperSh() (*asset, error) { return nil, err } - info := bindataFileInfo{name: "data/git_wrapper.sh", size: 698, mode: os.FileMode(0644), modTime: time.Unix(1558658378, 0)} - a := &asset{bytes: bytes, info: info, digest: [32]uint8{0x0, 0xde, 0x1a, 0x9e, 0x95, 0xa2, 0xad, 0x23, 0x16, 0xc3, 0xbf, 0x44, 0xcc, 0x27, 0x18, 0x53, 0xc5, 0x4a, 0x3d, 0x25, 0x98, 0x2c, 0x45, 0x1d, 0xaa, 0xe4, 0x24, 0xf2, 0x65, 0x19, 0x4b, 0xf0}} + info := bindataFileInfo{name: "data/git_wrapper.sh", size: 706, mode: os.FileMode(0644), modTime: time.Unix(1558658378, 0)} + a := &asset{bytes: bytes, info: info, digest: [32]uint8{0xff, 0x2f, 0x34, 0xba, 0x73, 0xb4, 0x7a, 0x4d, 0xf6, 0xfe, 0x3b, 0xf3, 0xc4, 0x3a, 0xfc, 0xda, 0x60, 0xd0, 0xa3, 0xf, 0xa4, 0x23, 0x59, 0x54, 0x37, 0xff, 0xf0, 0x95, 0xa9, 0x9c, 0xd7, 0x6c}} return a, nil } @@ -222,13 +222,14 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "data/aliases.sh": dataAliasesSh, - - "data/git_wrapper.sh": dataGit_wrapperSh, - + "data/aliases.sh": dataAliasesSh, + "data/git_wrapper.sh": dataGit_wrapperSh, "data/status_shortcuts.sh": dataStatus_shortcutsSh, } +// AssetDebug is true if the assets were built with the debug flag enabled. +const AssetDebug = false + // AssetDir returns the file names below a certain // directory embedded in the file by go-bindata. // For example if you run go-bindata on data/... and data contains the diff --git a/commands/inits/data/git_wrapper.sh b/commands/inits/data/git_wrapper.sh index c795c94..bccbb41 100644 --- a/commands/inits/data/git_wrapper.sh +++ b/commands/inits/data/git_wrapper.sh @@ -12,7 +12,7 @@ function git() { case $1 in commit|blame|log|rebase|merge) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")";; - checkout|diff|rm|reset) + checkout|diff|rm|reset|restore) eval "$(scmpuff expand --relative -- "$SCMPUFF_GIT_CMD" "$@")";; add) eval "$(scmpuff expand -- "$SCMPUFF_GIT_CMD" "$@")" diff --git a/features/command_status.feature b/features/command_status.feature index 99f205e..d8f8775 100644 --- a/features/command_status.feature +++ b/features/command_status.feature @@ -162,44 +162,49 @@ Feature: status command """ - @recent-git-only - Scenario: Handle change detection properly - Change detection is currently fairly rare in `git status`, mostly it only - happens after in index via diff or show. But it can occur, so make sure we - support it when it happens, as it may be baked in better in the future. - Change detection naturally involves two filepaths, like rename. - - In theory this is redundant with the "multiple filenames" scenario above, - but since change detection seems somewhat in flux we want to test for it - seperately in case its behavior changes in future versions of git. - - Thanks to @peff on git mailing list for conditions to reproduce this. - - Given I am in a git repository - And a 1000 byte file named "file" - And I successfully run the following commands: - | git add file | - | git commit -m base | - | mv file other | - Then I append to "file" with "foo" - And I successfully run `git add .` - # verify git behavior has not changed since this is hard to reproduce - When I successfully run `git status --short` - Then the stdout from "git status --short" should contain: - """ - M file - C file -> other - """ - # actual behavior test - When I successfully run `scmpuff status` - Then the stdout from "scmpuff status" should contain: - """ - modified: [1] file - """ - And the stdout from "scmpuff status" should contain: - """ - copied: [2] file -> other - """ + # CURRENT STATUS UNKNOWN! 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`. Disabling this test for now until it + # can be reproduced reliably in modern git. + + # @recent-git-only + # Scenario: Handle change detection properly + # Change detection is currently fairly rare in `git status`, mostly it only + # happens after in index via diff or show. But it can occur, so make sure we + # support it when it happens, as it may be baked in better in the future. + # Change detection naturally involves two filepaths, like rename. + + # In theory this is redundant with the "multiple filenames" scenario above, + # but since change detection seems somewhat in flux we want to test for it + # seperately in case its behavior changes in future versions of git. + + # Thanks to @peff on git mailing list for conditions to reproduce this. + + # Given I am in a git repository + # And a 1000 byte file named "file" + # And I successfully run the following commands: + # | git add file | + # | git commit -m base | + # | mv file other | + # Then I append to "file" with "foo" + # And I successfully run `git add .` + # # verify git behavior has not changed since this is hard to reproduce + # When I successfully run `git status --short` + # Then the stdout from "git status --short" should contain: + # """ + # M file + # C file -> other + # """ + # # actual behavior test + # When I successfully run `scmpuff status` + # Then the stdout from "scmpuff status" should contain: + # """ + # modified: [1] file + # """ + # And the stdout from "scmpuff status" should contain: + # """ + # copied: [2] file -> other + # """ Scenario: Status for a complex merge conflict diff --git a/features/shell_wrappers.feature b/features/shell_wrappers.feature index c275ad5..5c3804e 100644 --- a/features/shell_wrappers.feature +++ b/features/shell_wrappers.feature @@ -72,3 +72,30 @@ Feature: optional wrapping of normal git cmds in the shell | shell | | bash | | zsh | + + + @recent-git-only + 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 `` 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 | diff --git a/go.mod b/go.mod index dadd6c1..ed7a626 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module github.com/mroth/scmpuff -go 1.12 +go 1.14 require github.com/spf13/cobra v0.0.5