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

thoughts on installing as a git bash alias? #24

Closed
SKalt opened this issue Nov 17, 2018 · 4 comments
Closed

thoughts on installing as a git bash alias? #24

SKalt opened this issue Nov 17, 2018 · 4 comments

Comments

@SKalt
Copy link
Contributor

SKalt commented Nov 17, 2018

I got the following to work:

mkdir my-project && cd my-project
git init
cd .git
wget https://raw.githubusercontent.com/stylemistake/runner/master/src/runner.sh
chmod +x runner.sh
cat <<eof> config
[alias]
   runner = "!f(){ .git/runner.sh $@; }; f"
eof

cd ..
git runner # runs runner.sh!

Some issues remain: I haven't figured out how to pass a runnerfile in, and git consumes all --help flags. If those issues were resolved, installing as a git alias would be both cli-enabled, local to a project, and independent of the node ecosystem.

@stylemistake
Copy link
Owner

stylemistake commented Nov 17, 2018

That's a clever idea.

My advice would be to experiment with making a git extension (this way you'll have control of all the flags (allegedly)).

How to do it: Create an executable script git-runner, add it to PATH, and Git will pick it up when you use git runner.

Maybe there is some trick to make this process local to repo (maybe modifying PATH in some hooks), but i don't know of any.

https://github.com/afeld/git-plugins

@SKalt
Copy link
Contributor Author

SKalt commented Nov 18, 2018

Good idea. I'll get to look into this around Wednesday.

@SKalt
Copy link
Contributor Author

SKalt commented Nov 21, 2018

After a bit of research, I'm confident there's no way to localize a git extension to a repository without going the rvm route and overriding cd (see the accepted answer to "Execute bash scripts on entering a directory" for how). I'm unwilling to make that dangerous of a change or deal with possible collision with other tools (e.g. rvm).

So long as you're willing to sacrifice the --help flag, I've found

# .git/config
[alias]
  runner = "!f(){ path/to/runner/bin/runner $@; }; f"

will detect root-level runnerfiles and accept arguments. Note git does not consume -h, so usage can still be accessed that way.

With your go-ahead, I'd like to document this in the ./README.md#installation section to close this issue.

@SKalt SKalt changed the title thoughts on installing as a bash alias? thoughts on installing as a git bash alias? Nov 22, 2018
@stylemistake
Copy link
Owner

Yes, please do.

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

No branches or pull requests

2 participants