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.

52 lines
647 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. if [ -n "$(git ls -md)" ]; then
  14. if git stash; then
  15. staged=true
  16. fi
  17. fi
  18. git pull --rebase
  19. ! $staged || git stash pop
  20. cd - > /dev/null
  21. }
  22. update_repo() {
  23. cd "$1" || return 1
  24. echo "== $PWD"
  25. repo sync
  26. cd - > /dev/null
  27. }
  28. [ $# -gt 0 ] || set -- .
  29. for d; do
  30. if [ -e "$d/.git" ]; then
  31. mode=git
  32. elif [ -d "$d/.svn" ]; then
  33. mode=svn
  34. elif [ -d "$d/.repo" ]; then
  35. mode=repo
  36. else
  37. continue
  38. fi
  39. update_${mode} "$d"
  40. done