diff options
Diffstat (limited to 'bin/git-export')
| -rwxr-xr-x | bin/git-export | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/bin/git-export b/bin/git-export index fc76081..06d832a 100755 --- a/bin/git-export +++ b/bin/git-export | |||
| @@ -18,23 +18,38 @@ set -u | |||
| 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' | 18 | export PATH='/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' |
| 19 | 19 | ||
| 20 | export_prefix='/home/plugins/exported' | 20 | export_prefix='/home/plugins/exported' |
| 21 | export_branch='master' | ||
| 22 | myself=${0##*/} | 21 | myself=${0##*/} |
| 23 | 22 | ||
| 24 | if [ $# -lt 1 ] | 23 | usage() |
| 25 | then | 24 | { |
| 26 | echo >&2 "Usage: $myself <repository> ..." | 25 | echo >&2 "Usage: $myself [-b <branch>] <repository> ..." |
| 27 | exit 2 | 26 | exit 2 |
| 28 | fi | 27 | } |
| 28 | |||
| 29 | while getopts b: option | ||
| 30 | do | ||
| 31 | case $option in | ||
| 32 | b) | ||
| 33 | branch=$OPTARG | ||
| 34 | ;; | ||
| 35 | *) | ||
| 36 | usage | ||
| 37 | ;; | ||
| 38 | esac | ||
| 39 | done | ||
| 40 | |||
| 41 | shift $((OPTIND - 1)) | ||
| 42 | test $# -ge 1 || usage | ||
| 29 | 43 | ||
| 30 | for repository in "$@" | 44 | for repository in "$@" |
| 31 | do | 45 | do |
| 32 | export_dir="$export_prefix/${repository##*/}" | 46 | export_dir="$export_prefix/${repository##*/}" |
| 33 | export_dir=${export_dir%.git} | 47 | export_dir=${export_dir%.git} |
| 48 | export_dir="$export_dir${branch:+-$branch}" | ||
| 34 | 49 | ||
| 35 | cd "$repository" | 50 | cd "$repository" |
| 36 | rm -r -f "$export_dir" | 51 | rm -r -f "$export_dir" |
| 37 | mkdir -p "$export_dir" | 52 | mkdir -p "$export_dir" |
| 38 | git archive "$export_branch" | tar -x -C "$export_dir" -f - | 53 | git archive "${branch:-master}" | tar -x -C "$export_dir" -f - |
| 39 | cd "$OLDPWD" | 54 | cd "$OLDPWD" |
| 40 | done | 55 | done |
