From d5e0fddab2acf7f7397a030afc2dd7f22574126c Mon Sep 17 00:00:00 2001 From: Michael Erb Date: Mon, 11 Mar 2013 09:08:15 -0700 Subject: [PATCH 1/2] add 'bundle install --local' and 'rbenv rehash' as options to git config settings --- README.md | 8 ++++++++ RVM.md | 6 +++--- lib/git-up.rb | 14 ++++++++++++-- lib/git-up/version.rb | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 564c6fc..e8cba86 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,14 @@ It slows the process down slightly, and therefore defaults to `false`. If you're even lazier, you can tell `git-up` to run `bundle install` for you if it finds missing gems. Make sure `git-up.bundler.check` is also set to `true` or it won't do anything. +### `git-up.bundler.local [true|false]` + +If you've `bundle package`-ed your project gems, you can tell `git-up` to run `bundle install --local` for you if it finds missing gems. Much faster than just a plain old `bundle install`. Make sure `git-up.bundler.autoinstall` is also set to `true` or it won't do anything. + +### `git-up.bundler.rbenv [true|false]` + +If you have rbenv installed, you can tell `git-up` to run `rbenv rehash` for you after it installs your gems so any binaries will be available right away. Make sure `git-up.bundler.autoinstall` is also set to `true` or it won't do anything. + ### `git-up.fetch.prune [true|false]` By default, `git-up` will append the `--prune` flag to the `git fetch` command if your git version supports it (1.6.6 or greater), telling it to [remove any remote tracking branches which no longer exist on the remote](http://linux.die.net/man/1/git-fetch). Set this option to `false` to disable it. diff --git a/RVM.md b/RVM.md index 676f7a0..09282fc 100644 --- a/RVM.md +++ b/RVM.md @@ -14,19 +14,19 @@ ruby interpreter in the environment, and the way git interprets and executes `git up`. When you run `git [some command]` git will first look internally to see -if it can fulfil the command, then it will attempt to "shell out" and run +if it can fulfill the command, then it will attempt to "shell out" and run whatever `git-[some command]` executable it can find in your $PATH. When git "shells out" all of the environmental variables will be exposed, and it will be able to find our `git-up` executable in the $PATH. However because of the way RVM magically sets your ruby interpreter, -when `git-up` is ran `ruby` still points to the non-RVM system default. +when `git-up` is run `ruby` still points to the non-RVM system default. workaround ---------- To fix this we need to make sure that RVM gets to do it's business -before `git-up` is ran. +before `git-up` is run. RVM provides a handy way of doing this called "wrappers", so let's generate a wrapper for git-up like so: diff --git a/lib/git-up.rb b/lib/git-up.rb index 6efe0da..c0cce3d 100644 --- a/lib/git-up.rb +++ b/lib/git-up.rb @@ -172,8 +172,18 @@ def check_bundler print 'Gems are missing. '.yellow if config("bundler.autoinstall") == 'true' - puts "Running `bundle install`.".yellow - system "bundle", "install" + if config("bundler.local") == 'true' + puts "Running `bundle install --local`.".yellow + system "bundle", "install", "--local" + else + puts "Running `bundle install`.".yellow + system "bundle", "install" + end + + if config("bundler.rbenv") == 'true' + puts "Running `rbenv rehash`.".yellow + system "rbenv", "rehash" + end else puts "You should `bundle install`.".yellow end diff --git a/lib/git-up/version.rb b/lib/git-up/version.rb index 73b481b..bb5666a 100644 --- a/lib/git-up/version.rb +++ b/lib/git-up/version.rb @@ -1,3 +1,3 @@ class GitUp - VERSION = "0.5.8" + VERSION = "0.5.9" end From 64fa9eda63ec28182e39ebe6b4119773fe8bbbad Mon Sep 17 00:00:00 2001 From: Michael Erb Date: Mon, 11 Mar 2013 09:25:42 -0700 Subject: [PATCH 2/2] put in fallback for local bundle in case missing gems --- README.md | 2 +- lib/git-up.rb | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e8cba86..bc2128e 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ If you're even lazier, you can tell `git-up` to run `bundle install` for you if ### `git-up.bundler.local [true|false]` -If you've `bundle package`-ed your project gems, you can tell `git-up` to run `bundle install --local` for you if it finds missing gems. Much faster than just a plain old `bundle install`. Make sure `git-up.bundler.autoinstall` is also set to `true` or it won't do anything. +If you've `bundle package`-ed your project gems, you can tell `git-up` to run `bundle install --local` for you if it finds missing gems. Much faster than just a plain old `bundle install`. Don't worry if you're missing gems, it will backtrack to `bundle install` if anything goes wrong. Make sure `git-up.bundler.autoinstall` is also set to `true` or it won't do anything. ### `git-up.bundler.rbenv [true|false]` diff --git a/lib/git-up.rb b/lib/git-up.rb index c0cce3d..752ea62 100644 --- a/lib/git-up.rb +++ b/lib/git-up.rb @@ -174,7 +174,10 @@ def check_bundler if config("bundler.autoinstall") == 'true' if config("bundler.local") == 'true' puts "Running `bundle install --local`.".yellow - system "bundle", "install", "--local" + unless system "bundle", "install", "--local" + puts "Problem running `bundle install --local`. Running `bundle install` instead.".yellow + system "bundle", "install" + end else puts "Running `bundle install`.".yellow system "bundle", "install"