aboutsummaryrefslogtreecommitdiff
path: root/gitstatus
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2019-03-07 12:37:38 +0300
committerromkatv <roman.perepelitsa@gmail.com>2019-03-07 12:37:38 +0300
commit0fc73235e7a5e99947f874b310ceaa0113ff4af5 (patch)
tree44676bb9997c9f01abd6d7e07c1356c04f2f548c /gitstatus
parent5edb47431f7e627e45cbf6bea260f9e36444f7e7 (diff)
add pull-pustream.zsh
Diffstat (limited to 'gitstatus')
-rwxr-xr-xgitstatus/pull-upstream.zsh30
1 files changed, 30 insertions, 0 deletions
diff --git a/gitstatus/pull-upstream.zsh b/gitstatus/pull-upstream.zsh
new file mode 100755
index 00000000..2cb758a5
--- /dev/null
+++ b/gitstatus/pull-upstream.zsh
@@ -0,0 +1,30 @@
+#!/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)
+
+function pull() {
+ local repo && repo=$(mktemp -d ${TMPDIR:-/tmp}/gitstatus-pull-upstream.XXXXXXXXXX)
+ trap "rm -rf ${(q)repo}" EXIT
+ git clone $GITSTATUS_URL $repo
+
+ 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
+ } || {
+ rm $dst
+ }
+ done
+}
+
+pull