github-pull 445 B

12345678910111213141516171819202122
  1. #!/bin/sh
  2. die()
  3. {
  4. echo "$*" >&2
  5. exit 1
  6. }
  7. [ $# -eq 2 ] || die "Usage: github-pull PROJECTNAME USER:BRANCH"
  8. project="$1"
  9. user_branch="$2"
  10. user="$(printf '%s' "$user_branch" | cut -f1 -d':')"
  11. branch="$(printf '%s' "$user_branch" | cut -f2 -d':')"
  12. [ -n "$user" ] || die "Invalid user name"
  13. [ -n "$branch" ] || die "Invalid branch name"
  14. url="https://github.com/$user/$project.git"
  15. echo git pull "$url" "$branch"
  16. exec git pull "$url" "$branch"