feat: Add script utils

* feat: Add script utils - Closes #1

* Closes #issue-1 add script utils

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

* feat: add script utils Closes #issue-1

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>

Signed-off-by: Arthurim <arthurbdauphine@gmail.com>
This commit is contained in:
Eru Ilúvatar 2022-12-14 18:34:52 +00:00 committed by GitHub
parent 0e42ab6ba4
commit b078bc69d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 0 deletions

11
scripts/commit.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# bash script to commit in accordance with the branch name
# usage: ./scripts/commit.sh
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
branch="${branch##*feat/}"
branch="${branch//\_/ }"
issue_number="${branch//Issue\-/}"
title=$( cut -d ' ' -f 2- <<< "$issue_number" )
issue_number=$( cut -d ' ' -f 1 <<< "$issue_number" )
commit_message="feat: $title Closes #$issue_number"
git commit -sam "$commit_message"

View File

@ -0,0 +1,5 @@
#!/bin/sh
# commits and push
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
./scripts/commit.sh
git push --set-upstream origin $branch

View File

@ -0,0 +1,22 @@
#!/bin/sh
# bash script to create a new branch that respects the library standard
#### ./scripts/create_new_branch.sh "[FEAT] - Implement instrument types #14"
#### ./scripts/create_new_branch.sh "[FEAT] Implement instrument types #14"
#### ./scripts/create_new_branch.sh "[FEAT] - Implement instrument types#14"
base_issue=$1
issue_number=${base_issue##*#}
issue="${base_issue%%#*}"
issue="${issue//\[FEAT\] \- /}"
issue="${issue/\[FEAT\] /}"
issue="${issue/\[FEAT\]/}"
issue="${issue// /\_}"
branch_name="feat/issue-$issue_number ${issue,,}"
branch_name="${branch_name// /\_}"
last_char="${branch_name: -1}"
if [ "$last_char" = "_" ]
then
branch_name=${branch_name::-1}
fi
git checkout -b $branch_name