summaryrefslogtreecommitdiff
path: root/.local/bin/ps-pull
diff options
context:
space:
mode:
authorEvgeny Sorokin <me@ch1p.io>2024-01-06 03:41:49 +0000
committerEvgeny Sorokin <me@ch1p.io>2024-01-06 03:41:49 +0000
commit6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 (patch)
treed9f9200cf572385cf25f41442231675d5eeabcb8 /.local/bin/ps-pull
add somethingHEADmaster
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)"