Guest User

Untitled

a guest
Jun 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/bin/bash
  2. set -o errexit
  3. gem="$1"
  4. description="$2"
  5. [ -z "$gem" ] && echo "No gem" >&2 && exit 1
  6. [ -z "$description" ] && echo "No description" >&2 && exit 1
  7. projectdir="${projectdir:-${PWD}}"
  8. projectname="${projectdir##*/}"
  9.  
  10. [ ! -d "$projectdir/.git" ] && echo "No git repository" >&2 && exit 1
  11.  
  12. function finish()
  13. {
  14. cd "$projectdir"
  15. git worktree prune "$tmp"
  16. rm -rf "$tmp"
  17. }
  18.  
  19. git fetch
  20. tmp="$(mktemp -d -t "${projectname}-update-worktree")"
  21. git worktree add "$tmp" origin/master
  22. trap finish EXIT
  23.  
  24. cd "$tmp"
  25.  
  26. rbenv install --skip-existing
  27. gem install bundle
  28. bundle update --conservative $gem
  29. new_version="$(git diff -- Gemfile.lock | perl -n -e"/\+ *${gem} \((.*)\)/ && print \$1")"
  30. old_version="$(git diff -- Gemfile.lock | perl -n -e"/\- *${gem} \((.*)\)/ && print \$1")"
  31. [ -z "$new_version" ] && echo "No new_version" >&2 && exit 1
  32. [ -z "$old_version" ] && echo "No old_version" >&2 && exit 1
  33. branch="update-${gem}-$new_version"
  34. commit_message="${gem}: $old_version -> $new_version"
  35. git checkout -b $branch
  36. git commit -a -m "$commit_message"
  37. git push origin $branch
  38. hub pull-request -m "$commit_message
  39.  
  40. **Context**
  41.  
  42. $description
  43.  
  44. **Changes**
  45.  
  46. \`\`\`
  47. bundle update --conservative $gem
  48. \`\`\`"
Add Comment
Please, Sign In to add comment