Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -o errexit
- gem="$1"
- description="$2"
- [ -z "$gem" ] && echo "No gem" >&2 && exit 1
- [ -z "$description" ] && echo "No description" >&2 && exit 1
- projectdir="${projectdir:-${PWD}}"
- projectname="${projectdir##*/}"
- [ ! -d "$projectdir/.git" ] && echo "No git repository" >&2 && exit 1
- function finish()
- {
- cd "$projectdir"
- git worktree prune "$tmp"
- rm -rf "$tmp"
- }
- git fetch
- tmp="$(mktemp -d -t "${projectname}-update-worktree")"
- git worktree add "$tmp" origin/master
- trap finish EXIT
- cd "$tmp"
- rbenv install --skip-existing
- gem install bundle
- bundle update --conservative $gem
- new_version="$(git diff -- Gemfile.lock | perl -n -e"/\+ *${gem} \((.*)\)/ && print \$1")"
- old_version="$(git diff -- Gemfile.lock | perl -n -e"/\- *${gem} \((.*)\)/ && print \$1")"
- [ -z "$new_version" ] && echo "No new_version" >&2 && exit 1
- [ -z "$old_version" ] && echo "No old_version" >&2 && exit 1
- branch="update-${gem}-$new_version"
- commit_message="${gem}: $old_version -> $new_version"
- git checkout -b $branch
- git commit -a -m "$commit_message"
- git push origin $branch
- hub pull-request -m "$commit_message
- **Context**
- $description
- **Changes**
- \`\`\`
- bundle update --conservative $gem
- \`\`\`"
Add Comment
Please, Sign In to add comment