Skip to content

Commit 4362e20

Browse files
authored
Merge pull request #2 from wesleyscholl/CRS-98765-Jira-Ticket-Title-Test
Crs 98765 script updated to check for remote branch
2 parents 174e7bd + 88b2d76 commit 4362e20

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,18 @@ To https://github.com/wesleyscholl/git-commit-push-script.git
9494
c76b73c..be6fe58 CRS-12345-Git-Script-Test -> CRS-12345-Git-Script-Test
9595
```
9696

97-
9. Enjoy the script!
97+
## Troubleshooting
98+
99+
You may encounter an error from the following command because of the `-S` flag:
100+
```shell
101+
git commit -S -m "<commit message>"
102+
```
103+
To resolve this error, remove the `-S` from the command in the `git-commit-push-script.sh` file:
104+
```shell
105+
git commit -m "<commit message>"
106+
```
107+
If you want to use the -S flag, configure your Git configuration to use the GPG key for signing commits.
108+
Use the guide here: https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key
98109

99110
## License
100111
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

git-commit-push-script.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,20 @@ 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)
2222

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

0 commit comments

Comments
 (0)