|
7 | 7 | source "${__CUSTOM_GIT_UTIL}"/__assertgitrepo
|
8 | 8 | source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gcommit/__type_header
|
9 | 9 | source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gcommit/__scope_header
|
| 10 | +source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gcommit/__new_scope_header |
10 | 11 | source "${__CUSTOM_GIT_UTIL}"/fzf_headers/gcommit/__description_header
|
11 | 12 | source "${__CUSTOM_CONSOLE_UTIL}"/__print_info
|
12 | 13 | source "${__CUSTOM_CONSOLE_UTIL}"/__print_as
|
@@ -52,9 +53,28 @@ function main() {
|
52 | 53 | return
|
53 | 54 | }
|
54 | 55 | commitMessage="${commitType}"
|
55 |
| - print_commit_msg "${commitMessage}" |
56 | 56 |
|
57 |
| - local commitScope="$(get_commit_scope)" |
| 57 | + local commitScope="" |
| 58 | + while true; do |
| 59 | + print_commit_msg "${commitMessage}" |
| 60 | + commitScope="$(get_commit_scope)" |
| 61 | + [ "${commitScope}" != "ADD NEW SCOPE" ] && break |
| 62 | + |
| 63 | + local GCOMMIT_SCOPE_HEADER="$(__new_scope_header)" |
| 64 | + print_commit_msg "${commitMessage}" |
| 65 | + commitScope="$(echo "" | grep "x" |\ |
| 66 | + fzf --height 10%\ |
| 67 | + --info=hidden\ |
| 68 | + --bind 'enter:print-query'\ |
| 69 | + --header "${GCOMMIT_SCOPE_HEADER}")" |
| 70 | + |
| 71 | + local repoPath="$(git rev-parse --show-toplevel)" |
| 72 | + local commitScopeFile="${repoPath}/git-commit-scope.list" |
| 73 | + # check if the new scope is already present |
| 74 | + [ -n "${commitScope}" ] \ |
| 75 | + && ! grep -Fxq "${commitScope}" "${commitScopeFile}" \ |
| 76 | + && echo "${commitScope}" >> "${commitScopeFile}" |
| 77 | + done |
58 | 78 | [ -n "${commitScope}" ] && commitMessage="${commitMessage}(${commitScope})"
|
59 | 79 |
|
60 | 80 | [ "${isBreakingChange}" == "true" ] && commitMessage="${commitMessage}!"
|
@@ -119,26 +139,11 @@ function get_commit_scope() {
|
119 | 139 | commitScopes=("${commitScopes[@]}" "${commitScope}")
|
120 | 140 | done < "${commitScopeFile}"
|
121 | 141 |
|
122 |
| - local addNewScope=false |
123 |
| - local GCOMMIT_SCOPE_HEADER="$(__scope_header "${addNewScope}")" |
124 |
| - |
| 142 | + local GCOMMIT_SCOPE_HEADER="$(__scope_header)" |
125 | 143 | commitScope="$(printf "%s\n" "${commitScopes[@]}" |\
|
126 | 144 | fzf --height 55%\
|
127 | 145 | --header "${GCOMMIT_SCOPE_HEADER}")"
|
128 | 146 |
|
129 |
| - if [[ "${commitScope}" == "ADD NEW SCOPE" ]]; then |
130 |
| - addNewScope=true |
131 |
| - local GCOMMIT_SCOPE_HEADER="$(__scope_header "${addNewScope}")" |
132 |
| - commitScope="$(echo "" | grep "x" |\ |
133 |
| - fzf --height 10%\ |
134 |
| - --info=hidden\ |
135 |
| - --bind 'enter:print-query'\ |
136 |
| - --header "${GCOMMIT_SCOPE_HEADER}")" |
137 |
| - # check if the new scope is already present |
138 |
| - [ -n "${commitScope}" ] \ |
139 |
| - && ! grep -Fxq "${commitScope}" "${commitScopeFile}" \ |
140 |
| - && echo "${commitScope}" >> "${commitScopeFile}" |
141 |
| - fi |
142 | 147 | echo "${commitScope}"
|
143 | 148 | }
|
144 | 149 |
|
|
0 commit comments