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

don't force hub usage in git-wrapper if installed #62

Merged
merged 5 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Development

While the build process itself does not require it, development uses Ruby for
integration testing because of the excellent Cucumber/Aruba package for testing
CLI tools.

Thus, to bootstrap, you will need to have Ruby and bundler installed on your
system. Do `bundle install` to get the dev environment going.

Since we already have Ruby then for tests, we use a Rakefile instead of Makefile
since it offers some niceties. Do `rake -T` to see available tasks.
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ shell integration is under 100 lines of shell script.
system. It's written with cross-platform support in mind, so hopefully we'll
have it functioning on Windows soon as well.

**scmpuff** is fully compatible with the most-excellent [Hub][hub].

[scmbreeze]: https://github.com/ndbroadbent/scm_breeze
[hub]: https://github.com/github/hub

## Installation

Expand Down Expand Up @@ -87,8 +84,8 @@ e.g. `ga`, `gd`, `gco`. Check your aliases to see what they are.

### How does it compare with SCM Breeze?

The short version: it does less, but is faster and should be significantly more
stable and reliable, especially across different platforms.
The short version: it does less, but is faster and should be more stable and
reliable, especially across different platforms.

The long, detailed version:
https://github.com/mroth/scmpuff/wiki/scmpuff-vs-SCM-Breeze
Expand All @@ -99,15 +96,12 @@ in your shell initialization. Then, if you wish to remap them, simple modify
your default aliases wherever you normally do, but add aliases mapped to the
scmpuff shell functions, e.g. `alias gs='scmpuff_status'`.

### I want to use scmpuff in conjunction with [hub][hub] or something else that I've aliased git to, how would I do so?

## Development
By default, scmpuff will attempt to utilize the absolute path of whatever `git`
it finds in your system PATH, ignoring existing shell aliases. If you want to
use a different binary, set `$SCMPUFF_GIT_CMD` in your shell to the path, for
example, `export SCMPUFF_GIT_CMD=/usr/local/bin/hub`.

While the build process itself does not require it, development uses Ruby for
integration testing because of the excellent Cucumber/Aruba package for testing
CLI tools.

Thus, to bootstrap, you will need to have Ruby and bundler installed on your
system. Do `bundle install` to get the dev environment going.
[hub]: https://github.com/github/hub

Since we already have Ruby then for tests, we use a Rakefile instead of Makefile
since it offers some niceties. Do `rake -T` to see available tasks.
6 changes: 2 additions & 4 deletions commands/inits/data/git_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ unalias git > /dev/null 2>&1
unset -f git > /dev/null 2>&1

# Use the full path to git to avoid infinite loop with git function
export SCMPUFF_GIT_CMD="$(\which git)"

# Wrap git with the 'hub' github wrapper, if installed
if type hub > /dev/null 2>&1; then export SCMPUFF_GIT_CMD="hub"; fi
SCMPUFF_GIT_CMD=${SCMPUFF_GIT_CMD:-"$(\which git)"}
export SCMPUFF_GIT_CMD

function git() {
case $1 in
Expand Down
40 changes: 40 additions & 0 deletions features/shell_functions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,43 @@ Feature: scmpuff_status function
| shell |
| bash |
| zsh |

Scenario Outline: default SCMPUFF_GIT_CMD is set to absolute path of a git command
When I run `<shell>` interactively
And I type `eval "$(scmpuff init -s)"`
And I type "echo $SCMPUFF_GIT_CMD"
And I type "exit"
And I stop the command "<shell>"
Then the output should match %r<^/.+/git$>
# ^^ is absolute path to git: begins with a /, and ends with /git
Examples:
| shell |
| bash |
| zsh |

Scenario Outline: SCMPUFF_GIT_CMD is set to absolute path of a git command, eliminating aliases
When I run `<shell>` interactively
And I type "alias git=/foo/bar"
And I type `eval "$(scmpuff init -s)"`
And I type "echo $SCMPUFF_GIT_CMD"
And I type "exit"
And I stop the command "<shell>"
Then the output should match %r<^/.+/git$>
# ^^ is absolute path to git: begins with a /, and ends with /git
Examples:
| shell |
| bash |
| zsh |

Scenario Outline: SCMPUFF_GIT_CMD respects existing environment variables
When I run `<shell>` interactively
And I type "export SCMPUFF_GIT_CMD=/foo/hub"
And I type `eval "$(scmpuff init -s)"`
And I type "echo $SCMPUFF_GIT_CMD"
And I type "exit"
And I stop the command "<shell>"
Then the output should contain exactly "/foo/hub"
Examples:
| shell |
| bash |
| zsh |