52 lines
878 B
Bash
Executable File
52 lines
878 B
Bash
Executable File
#!/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)"
|