]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash -e | |
2 | # Helper script for various git mirrors of other VCS types. | |
3 | # I'm lazy and can't be bothered to remember the exact invocation. | |
4 | ||
5 | #if [[ $(git branch | awk '($1 == "*") {print $2}') != master ]] ; then | |
6 | # echo "Switch to master first" | |
7 | # exit 1 | |
8 | #fi | |
9 | ||
10 | g() { | |
11 | set -- git "$@" | |
12 | echo "--- $*" | |
13 | "$@" | |
14 | } | |
15 | ||
16 | if git config svn-remote.svn.url >/dev/null ; then | |
17 | # git-config uses svn.authorsfile relative to repo root | |
18 | # i.e. good to use .git/authors | |
19 | set -- git svn fetch --all "$@" | |
20 | expected="" | |
21 | elif git config remote.hg.url >/dev/null ; then | |
22 | set -- git-hg pull | |
23 | $(git config --get --bool remote.hg.force) && set -- "$@" --force | |
24 | $(git config --get --bool remote.hg.rebase) && set -- "$@" --rebase | |
25 | elif git config cvs.cvsroot >/dev/null ; then | |
26 | # authors file is at .git/cvs-authors | |
27 | set -- git cvsimport -a -d $(git config cvs.cvsroot) $(git config cvs.module) "$@" | |
28 | expected="Already up-to-date." | |
29 | elif [[ -d CVS ]] && git rev-parse origin >/dev/null ; then | |
30 | set -- git cvsimport -a | |
31 | expected="Already up-to-date." | |
32 | else | |
33 | set -- git pull "$@" | |
34 | expected="Already up-to-date." | |
35 | fi | |
36 | ||
37 | output=$( | |
38 | "$@" | tee /proc/$$/fd/1 | |
39 | _pipestatus=${PIPESTATUS[*]} | |
40 | [[ ${_pipestatus// /} -eq 0 ]] || exit 1 | |
41 | ) | |
42 | [[ ${output} == "${expected}" ]] && exit 0 | |
43 | ||
44 | g fsck | |
45 | g count-objects | |
46 | g gc --prune |