Skip to content

Instantly share code, notes, and snippets.

@matthewd
Created June 14, 2014 07:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewd/dc4dc0186d8acb1d0f69 to your computer and use it in GitHub Desktop.
Save matthewd/dc4dc0186d8acb1d0f69 to your computer and use it in GitHub Desktop.
Per-branch Gemfile.lock
#!/bin/bash
if [ "$3" = 1 ]; then
old_branch="`git name-rev --name-only --no-undefined "$1" | cut -d'~' -f1`"
new_branch="`git name-rev --name-only --no-undefined "$2" | cut -d'~' -f1`"
if [ "$old_branch" != "$new_branch" ]; then
mv -f "Gemfile.lock" ".Gemfile/lock.$old_branch"
if [ -f ".Gemfile/lock.$new_branch" ]; then
mv -f ".Gemfile/lock.$new_branch" "Gemfile.lock"
else
closest_match="$old_branch"
cp -f ".Gemfile/lock.$closest_match" "Gemfile.lock"
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment