Skip to content

Commit f13ef87

Browse files
committed
CRS-12345 Test 123
1 parent 8bd6389 commit f13ef87

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

git-commit-push-script.sh

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,21 @@ ticket=$(echo $base_branch | grep -o -E '([A-Za-z]+-[0-9]{3,}|[A-Za-z]+-[0-9]{3,
1212

1313
# Prompt for commit message
1414
read -p "Enter commit message: " message
15-
echo "Commit message: $ticket - $message"
15+
echo "Commit message: $ticket $message"
1616

1717
# Prepare and execute commit command
18-
git commit -S -m "$ticket - $message"
18+
git commit -S -m "$ticket $message"
1919

20-
# Push changes
21-
git push
20+
# Check if the branch exists on the remote
21+
remote_branch=$(git ls-remote --heads origin $base_branch)
22+
23+
if [ -z "$remote_branch" ]; then
24+
echo "Branch '$base_branch' does not exist on remote. Creating it."
25+
# Push the local branch to the remote, setting the upstream branch
26+
git push --set-upstream origin $base_branch
27+
else
28+
echo "Branch '$base_branch' exists on remote. Pushing changes."
29+
# Push changes to the remote
30+
git push
31+
fi
2232

0 commit comments

Comments
 (0)