From 6e5d672ea04fb8c89ce9e91cf4c9a53fbb8c2f81 Mon Sep 17 00:00:00 2001 From: Evgeny Sorokin Date: Sat, 6 Jan 2024 03:41:49 +0000 Subject: add something --- .local/bin/ps-pull | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 .local/bin/ps-pull (limited to '.local/bin/ps-pull') 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)" -- cgit v1.2.3