summaryrefslogtreecommitdiff
path: root/update-sources
blob: 8cae061659eb94e25a5e3f74c8d343019bb2406a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash

if [ $# -eq 0 ]; then

  srcDir=$(
    readlink -e "${HOME}/packageSources"
  )

  [ -d "${srcDir}" ] || exit 0

  find "${srcDir}" \
    -type d \
    -exec sh -c 'test -f "{}/HEAD"' \; \
    -printf 'git: %p\n' \
    -prune , \
    -type d \
    -exec sh -c 'test -d "{}/.svn"' \; \
    -printf 'svn: %p\n' \
    -prune \
  | parallel -j 0 -l 1 "$0"

elif [ $# -eq 1 ]; then

  case "${1%%: *}" in
    'git')
      git -C "${1#*: }" fetch --all -p
    ;;
    'svn')
      cd "${1#*: }"
      svn update
    ;;
    *)
      >&2 printf '%s: unknown VCS "%s"\n' "$0" "${1%%: *}"
      exit 1
    ;;
  esac

else

  >&2 printf '%s: too many arguments\n' "$0"
  exit 1

fi