You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.1 KiB

  1. #!/bin/sh
  2. update_svn() {
  3. DIR=$(cd "$1" && pwd -P)
  4. [ -d "$DIR" ] || return 0
  5. echo "== $DIR"
  6. # svn upgrade "$DIR"
  7. svn up "$DIR"
  8. }
  9. update_git() {
  10. local staged=false
  11. local branch= remote= merge=
  12. cd "$1" || return 1
  13. echo "== $PWD"
  14. git fetch -q --all --prune
  15. git remote | xargs -r git fetch -q --multiple --prune --tags
  16. if [ -n "$(git ls-files -md)" ]; then
  17. if git stash -q; then
  18. staged=true
  19. fi
  20. fi
  21. branch=`git branch | sed -ne 's!* \(.\)!\1!p'`
  22. remote=`git config "branch.${branch}.remote"`
  23. merge=`git config "branch.${branch}.merge"`
  24. git rebase -q "$remote/${merge##refs/heads/}"
  25. if $staged; then
  26. git stash pop -q
  27. git status -s
  28. fi
  29. cd - > /dev/null
  30. }
  31. update_repo() {
  32. cd "$1" || return 1
  33. echo "== $PWD"
  34. repo sync
  35. cd - > /dev/null
  36. }
  37. if [ $# -eq 0 ]; then
  38. if git rev-parse --is-inside-work-tree > /dev/null; then
  39. set -- "$(git rev-parse --show-toplevel)"
  40. else
  41. set -- .
  42. fi
  43. fi
  44. for d; do
  45. if [ -e "$d/.git" ]; then
  46. mode=git
  47. elif [ -d "$d/.svn" ]; then
  48. mode=svn
  49. elif [ -d "$d/.repo" ]; then
  50. mode=repo
  51. else
  52. continue
  53. fi
  54. update_${mode} "$d"
  55. done