-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitvb-is-pickable
executable file
·35 lines (29 loc) · 1.01 KB
/
gitvb-is-pickable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
set -e
MAIN_BRANCH="${MAIN_BRANCH:-main}"
# Check if the branch name is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <branch-name>"
exit 1
fi
BRANCH_NAME=$1
# Check out the branch
# git checkout "$BRANCH_NAME"
# Get the latest commits for the branch and origin/master
# LOCAL_COMMITS=$(git rev-list --count "$BRANCH_NAME" ^"origin/$MAIN_BRANCH")
# REMOTE_COMMITS=$(git rev-list --count "origin/$MAIN_BRANCH" ^"$BRANCH_NAME")
REMOTE_COMMITS=$(git rev-list --count "origin/$MAIN_BRANCH" ^"$BRANCH_NAME")
# Determine if the branch needs rebasing
if [ "$REMOTE_COMMITS" -gt 0 ]; then
echo ""
echo "*** Branch '$BRANCH_NAME' needs rebasing on 'origin/$MAIN_BRANCH'. ***"
echo " It is $REMOTE_COMMITS commits behind,"
echo " run $ gitvb-sync-unpicked $BRANCH_NAME"
echo " or $ gitvb-pick-outdated $BRANCH_NAME"
echo " or rebase it manually."
echo ""
exit 1
else
echo "Branch '$BRANCH_NAME' is up-to-date with 'origin/$MAIN_BRANCH' or does not need rebasing."
exit 0
fi