Skip to content

Commit 5559d58

Browse files
feat: improve branch processing if a target branch doesn't exist
1 parent a4d95d9 commit 5559d58

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

bin/git-tickets

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,23 @@ process_branch() {
3333
local temp_branch="temp_${branch_name}_$$"
3434
if $UPDATE_BRANCHES; then
3535
git checkout "$branch_name" &> /dev/null
36+
if [ $? -ne 0 ]; then
37+
echo "Failed to checkout branch $branch_name" >&2
38+
exit 1
39+
fi
3640
git pull origin "$branch_name" &> /dev/null
3741
echo "$branch_name"
3842
else
3943
git fetch origin "$branch_name":"$temp_branch" &> /dev/null
44+
if ! git rev-parse --verify "$temp_branch" &> /dev/null; then
45+
echo "Failed to fetch and create temp branch for $branch_name" >&2
46+
exit 1
47+
fi
4048
echo "$temp_branch"
4149
fi
4250
}
4351

52+
4453
# Process the first branch
4554
BRANCH1=$(process_branch "$BRANCH1")
4655

0 commit comments

Comments
 (0)