summaryrefslogtreecommitdiff
path: root/.local/bin/ps-pull
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/ps-pull')
-rwxr-xr-x.local/bin/ps-pull51
1 files changed, 51 insertions, 0 deletions
diff --git a/.local/bin/ps-pull b/.local/bin/ps-pull
new file mode 100755
index 0000000..f25ba48
--- /dev/null
+++ b/.local/bin/ps-pull
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+set -e
+
+git_branch() {
+ git rev-parse --symbolic-full-name --abbrev-ref HEAD
+}
+
+[ -d .git ] || {
+ echo "error: not a git repository"
+ exit 1
+}
+
+[ -d .idea ] || {
+ echo "error: not a jetbrains repository"
+ exit 1
+}
+
+PREFETCH_HOOK=.git/hooks/prefetch
+CUR_BRANCH=$(git_branch)
+TARGET_BRANCH="$CUR_BRANCH"
+
+while getopts b: option
+do
+ case "${option}"
+ in
+ b)
+ TARGET_BRANCH=${OPTARG}
+ ;;
+
+ *)
+ :
+ ;;
+ esac
+done
+
+if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
+ echo "new target branch: $TARGET_BRANCH"
+fi
+
+git add .
+git reset --hard
+[ -x "$PREFETCH_HOOK" ] && "./$PREFETCH_HOOK"
+git fetch -a dev
+if [ "$CUR_BRANCH" != "$TARGET_BRANCH" ]; then
+ git checkout "$TARGET_BRANCH" --
+fi
+git reset --hard dev/$TARGET_BRANCH
+#git pull dev $TARGET_BRANCH
+
+echo "current branch: $(git_branch)"