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.

61 lines
855 B

  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. cd "$1" || return 1
  12. echo "== $PWD"
  13. git fetch --all --prune
  14. git remote | xargs -r git fetch --multiple --prune --tags
  15. if [ -n "$(git ls -md)" ]; then
  16. if git stash; then
  17. staged=true
  18. fi
  19. fi
  20. git pull --rebase
  21. ! $staged || git stash pop
  22. cd - > /dev/null
  23. }
  24. update_repo() {
  25. cd "$1" || return 1
  26. echo "== $PWD"
  27. repo sync
  28. cd - > /dev/null
  29. }
  30. if [ $# -eq 0 ]; then
  31. if git rev-parse --is-inside-work-tree > /dev/null; then
  32. set -- "$(git rev-parse --show-toplevel)"
  33. else
  34. set -- .
  35. fi
  36. fi
  37. for d; do
  38. if [ -e "$d/.git" ]; then
  39. mode=git
  40. elif [ -d "$d/.svn" ]; then
  41. mode=svn
  42. elif [ -d "$d/.repo" ]; then
  43. mode=repo
  44. else
  45. continue
  46. fi
  47. update_${mode} "$d"
  48. done