Skip to content

Commit 99516e6

Browse files
author
Bhavi Dhingra
committed
feat(gcommit): do not write duplicate scope to the list
1 parent b061ad7 commit 99516e6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

cmd/gcommit

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ function main() {
6565
commitMessage="${commitMessage}${commitDescription}"
6666
printf "\r"
6767

68+
clear
6869
git commit -m "${commitMessage}"
6970
git log -n 1
70-
gstatus
71+
git status
7172

7273
echo
73-
__print_info "To add body, footer or edit the commit message, use "
74-
__println_as magenta " git commit --amend"
74+
__print_info "To add the commit body/footer or edit the commit message, use "
75+
__println_as magenta " $ git commit --amend"
7576
echo
7677
}
7778

@@ -126,7 +127,10 @@ function get_commit_scope() {
126127
--info=hidden\
127128
--bind 'enter:print-query'\
128129
--header "${GCOMMIT_SCOPE_HEADER}")"
129-
[ -n "${commitScope}" ] && echo "${commitScope}" >> "${commitScopeFile}"
130+
# check if the new scope is already present
131+
[ -n "${commitScope}" ] \
132+
&& ! grep -Fxq "${commitScope}" "${commitScopeFile}" \
133+
&& echo "${commitScope}" >> "${commitScopeFile}"
130134
fi
131135
echo "${commitScope}"
132136
}

0 commit comments

Comments
 (0)