Skip to content

Commit 506663b

Browse files
committed
chore(scripts): change endfeat to check for upstream branch (#284)
1 parent a48eecd commit 506663b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

โ€Žscripts/git-workflow.zshrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ get-def-branch() {
33
echo master
44
}
55

6+
function get-tracking-branch() {
7+
git config branch.$(git_current_branch).remote
8+
}
9+
610
are-you-sure() {
711
echo "๐Ÿ‘พ Are you sureโ“ (type 'y' to confirm)"
812
read squashed
@@ -15,6 +19,21 @@ are-you-sure() {
1519
fi
1620
}
1721

22+
function check-upstream-branch() {
23+
local upstream_branch=$(get-tracking-branch)
24+
local feature_branch=$(git_current_branch)
25+
26+
if [ -z "$upstream_branch" ]; then
27+
echo "===> ๐Ÿ› No upstream branch detected for : '๐ŸŽ€ $feature_branch'"
28+
are-you-sure
29+
if [ $? -ne 0 ]; then
30+
return 1
31+
fi
32+
fi
33+
34+
return 0
35+
}
36+
1837
startfeat() {
1938
if [[ -n $1 ]]; then
2039
echo "===> ๐Ÿš€ START FEATURE: '๐ŸŽ€ $1'"
@@ -31,6 +50,11 @@ endfeat() {
3150
return 1
3251
fi
3352

53+
check-upstream-branch
54+
if [ $? -ne 0 ]; then
55+
return 1
56+
fi
57+
3458
local feature_branch=$(git_current_branch)
3559
local default_branch=$(get-def-branch)
3660

0 commit comments

Comments
ย (0)