2019-03-07 11:37:38 +02:00
|
|
|
#!/usr/bin/zsh
|
|
|
|
|
|
|
|
emulate -L zsh
|
|
|
|
setopt err_exit no_unset pipe_fail extended_glob xtrace
|
|
|
|
|
|
|
|
: ${GITSTATUS_DIR:=${${(%):-%x}:A:h}}
|
|
|
|
: ${GITSTATUS_URL:=https://github.com/romkatv/gitstatus.git}
|
|
|
|
|
|
|
|
readonly GITSTATUS_DIR GITSTATUS_URL
|
|
|
|
readonly -a IGNORE=(pull-upstream.zsh README.md)
|
|
|
|
|
2019-10-05 18:14:17 +02:00
|
|
|
() {
|
|
|
|
local repo && repo="$(mktemp -d ${TMPDIR:-/tmp}/gitstatus-pull-upstream.XXXXXXXXXX)"
|
2019-03-07 11:37:38 +02:00
|
|
|
trap "rm -rf ${(q)repo}" EXIT
|
2019-10-07 10:15:34 +02:00
|
|
|
git clone --depth 1 $GITSTATUS_URL $repo
|
2019-03-07 11:37:38 +02:00
|
|
|
|
|
|
|
local dst
|
|
|
|
for dst in $GITSTATUS_DIR/**/*(.,@); do
|
|
|
|
local f=${dst#$GITSTATUS_DIR/}
|
|
|
|
(( ! ${IGNORE[(I)$f]} )) || continue
|
|
|
|
local src=$repo/$f
|
|
|
|
[[ -f $src ]] && {
|
|
|
|
mkdir -p ${dst:h} && cp -f $src $dst || return
|
|
|
|
} || {
|
2019-10-05 18:14:17 +02:00
|
|
|
rm -f $dst
|
2019-03-07 11:37:38 +02:00
|
|
|
}
|
|
|
|
done
|
|
|
|
}
|