Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Francesco Witz
Changelog Generator
Commits
981c84b6
Commit
981c84b6
authored
Feb 13, 2022
by
Francesco Witz
Browse files
feat: tool rules editor
parent
48a4cc05
Changes
1
Hide whitespace changes
Inline
Side-by-side
chlog.py
View file @
981c84b6
...
...
@@ -232,13 +232,147 @@ def rules():
print
(
"4. Commit subject case: "
,
subject_case
)
print
(
"5. Commit subject is allowed to contain punctuation: "
,
str
(
has_punctuation
))
print
(
"6. Commit subject length: "
,
str
(
subject_length
))
# Asking user if he wants to edit those or simply leave
print
(
"
\n
"
)
choice
=
""
while
choice
==
""
and
choice
!=
'q'
and
choice
!=
'e'
:
choice
=
input
(
"Press q to quit or e to edit: "
)
# Going through config editing
if
choice
==
'e'
:
print
(
"Edit will come..."
)
# For each rule, show it and ask user if he wants to edit
# If yes, display edit options
continue_edit
=
True
print
(
"
\n
Let's edit the rules ! 🛠"
)
while
continue_edit
:
option
=
""
while
not
option
in
[
"1"
,
"2"
,
"3"
,
"4"
,
"5"
,
"6"
]
and
option
==
""
and
option
!=
"q"
:
option
=
input
(
"Please choose a specific rule to edit (1-6, q to quit): "
)
if
option
==
"1"
:
# Standard commit type edition
action
=
""
while
action
==
""
and
not
action
in
[
"1"
,
"2"
,
"3"
]
and
action
!=
"q"
:
action
=
input
(
"What do you whant to do ? (q to quit)"
)
print
(
"1. Add a new standard commit type"
)
print
(
"2. Remove a standard commit type"
)
if
action
==
"1"
:
print
(
"
\n
"
)
name
=
""
while
name
==
""
:
name
=
input
(
"\Enter standard commit type name: "
)
description
=
""
while
description
==
""
:
description
=
input
(
"Enter standard commit type short description: "
)
validation
=
""
while
validation
==
""
and
not
validation
in
[
"y"
,
"n"
]:
validation
=
input
(
"Do you want to add this new standard commit type ? (y/n)"
)
if
validation
==
"y"
:
config
[
'commit-type'
].
append
([
name
,
description
])
elif
action
==
"2"
:
print
(
"
\n
Standard commit type:"
)
index
=
1
for
e
in
commit_type
:
print
(
" "
+
index
+
". "
+
e
[
0
]
+
": "
+
e
[
1
])
index
+=
1
number
=
""
while
number
==
""
and
not
number
in
[
str
(
i
)
for
i
in
range
(
1
,
len
(
config
[
'commit-type'
])
+
1
)]
and
number
!=
"q"
:
number
=
input
(
"
\n
Which standard commit type do you want to remove ? (q to quit)"
)
validation
=
""
while
validation
==
""
and
not
validation
in
[
"y"
,
"n"
]:
validatiion
=
input
(
"Do you really want to remove this standard commit type ? (y/n)"
)
if
validation
==
"y"
:
config
[
"commit-type"
].
remove
(
config
[
"commit-type"
][
int
(
number
)])
elif
option
==
"2"
:
# Ignored commit type edition
action
=
""
while
action
==
""
and
not
action
in
[
"1"
,
"2"
,
"3"
]
and
action
!=
"q"
:
action
=
input
(
"What do you whant to do ? (q to quit)"
)
print
(
"1. Add a new ignored commit type"
)
print
(
"2. Remove a ignored commit type"
)
if
action
==
"1"
:
print
(
"
\n
"
)
name
=
""
while
name
==
""
:
name
=
input
(
"\Enter ignored commit type name: "
)
description
=
""
while
description
==
""
:
description
=
input
(
"Enter ignored commit type short description: "
)
validation
=
""
while
validation
==
""
and
not
validation
in
[
"y"
,
"n"
]:
validation
=
input
(
"Do you want to add this new ignored commit type ? (y/n)"
)
if
validation
==
"y"
:
config
[
'ignored-commit-type'
].
append
([
name
,
description
])
elif
action
==
"2"
:
print
(
"
\n
Ignored commit type:"
)
index
=
1
for
e
in
ignored_commit_type
:
print
(
" "
+
index
+
". "
+
e
[
0
]
+
": "
+
e
[
1
])
index
+=
1
number
=
""
while
number
==
""
and
not
number
in
[
str
(
i
)
for
i
in
range
(
1
,
len
(
config
[
'ignored-commit-type'
])
+
1
)]
and
number
!=
"q"
:
number
=
input
(
"
\n
Which ignored commit type do you want to remove ? (q to quit)"
)
validation
=
""
while
validation
==
""
and
not
validation
in
[
"y"
,
"n"
]:
validatiion
=
input
(
"Do you really want to remove this ignored commit type ? (y/n)"
)
if
validation
==
"y"
:
config
[
"ignored-commit-type"
].
remove
(
config
[
"ignored-commit-type"
][
int
(
number
)])
elif
option
==
"3"
:
# Commit type case edition
print
(
"
\n
Possible case:"
)
print
(
" 1. lowercase"
)
print
(
" 2. uppercase"
)
print
(
" 3. capitalized"
)
new_type_case
=
""
while
new_type_case
==
""
and
not
new_type_case
in
[
"1"
,
"2"
,
"3"
]
and
new_type_case
!=
"q"
:
new_type_case
=
input
(
"New type case (1-3, q to quit): "
)
if
new_type_case
==
"1"
:
config
[
'commit-type-case'
]
=
"lowercase"
elif
new_type_case
==
"2"
:
config
[
'commit-type-case'
]
=
"uppercase"
elif
new_type_case
==
"3"
:
config
[
'commit-type-case'
]
=
"capitalized"
elif
option
==
"4"
:
# Subject message case edition
print
(
"
\n
Possible case:"
)
print
(
" 1. lowercase"
)
print
(
" 2. uppercase"
)
print
(
" 3. capitalized"
)
new_subject_case
=
""
while
new_subject_case
==
""
and
not
new_subject_case
in
[
"1"
,
"2"
,
"3"
]
and
new_subject_case
!=
"q"
:
new_subject_case
=
input
(
"New type case (1-3, q to quit): "
)
if
new_subject_case
==
"1"
:
config
[
'commit-subject-case'
]
=
"lowercase"
elif
new_subject_case
==
"2"
:
config
[
'commit-subject-case'
]
=
"uppercase"
elif
new_subject_case
==
"3"
:
config
[
'commit-subject-case'
]
=
"capitalized"
elif
option
==
"5"
:
# Punctuation rule edition
new_punct
=
""
while
new_punct
==
""
and
not
new_punct
in
[
"y"
,
"n"
]
and
new_punct
!=
"q"
:
new_punct
=
input
(
"Allowing punctuation in commit subject (y/n, q to quit): "
)
if
new_punct
==
"y"
:
config
[
'commit-subject-ponctuation'
]
=
True
elif
new_punct
==
"n"
:
config
[
'commit-subject-ponctuation'
]
=
False
elif
option
==
"6"
:
# Subject length edition
new_length
=
""
while
new_length
==
""
and
not
new_length
.
isnumeric
()
and
new_length
!=
"q"
:
new_length
=
input
(
"New subject length (q to quit): "
)
if
new_length
!=
"q"
:
config
[
'commit-subject-length'
]
=
int
(
subject_length
)
# Asking user if he wants to edit anything else
edition
=
""
while
edition
==
""
and
not
edition
in
[
"y"
,
"n"
]:
edition
=
input
(
"Do you want to edit another rule ? (y/n)"
)
if
edition
==
"y"
:
continue_edit
=
True
elif
edition
==
"n"
:
continue_edit
=
False
# Write change to the config file
with
open
(
os
.
path
.
join
(
path
,
'config.json'
),
'r'
)
as
file
:
file
.
write
(
json
.
dumps
(
config
))
print
(
"Rules succesfully edited ! ✨"
)
elif
choice
==
'q'
:
print
(
"Good bye ✨"
)
def
config
(
argv
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment