-
-
Notifications
You must be signed in to change notification settings - Fork 297
Commit 440a7fa
author
committedamitlevy21
feat(ConventionalCommitsCz): allow to override defaults from config
As addressed on #535, when using customize commitizen, if we want to
customize a small attribute, we need to redefine all commitizens options
to make our custom class work.
For example:
```diff
diff --git a/cz.yaml b/cz.yaml
index f2e19a9..302e961 100644
--- a/cz.yaml
+++ b/cz.yaml
@@ -1,6 +1,18 @@
commitizen:
annotated_tag: true
bump_message: 'bump: $current_version -> $new_version [skip ci]'
- name: cz_conventional_commits
+ name: cz_customize
update_changelog_on_bump: true
version: 0.11.0
+
+ customize:
+ bump_pattern: '^(fix|feat|docs|style|refactor|test|build|ci)'
+ bump_map:
+ fix: PATCH
+ feat: PATCH
+ docs: PATCH
+ style: PATCH
+ refactor: PATCH
+ test: PATCH
+ build: PATCH
+ ci: PATCH
diff --git a/t b/t
new file mode 100644
index 0000000..e69de29
diff --git a/t2 b/t2
new file mode 100644
index 0000000..e69de29
```
making the following change on a repo would cause an unexpected
behavior:
```python
+ bash -c cz commit
Traceback (most recent call last):
File "/home/amit/.local/bin/cz", line 8, in <module>
sys.exit(main())
File "/home/amit/.local/lib/python3.10/site-packages/commitizen/cli.py", line 382, in main
args.func(conf, vars(args))()
File "/home/amit/.local/lib/python3.10/site-packages/commitizen/commands/commit.py", line 74, in __call__
m = self.prompt_commit_questions()
File "/home/amit/.local/lib/python3.10/site-packages/commitizen/commands/commit.py", line 49, in prompt_commit_questions
for question in filter(lambda q: q["type"] == "list", questions):
File "/home/amit/.local/lib/python3.10/site-packages/commitizen/commands/commit.py", line 49, in <lambda>
for question in filter(lambda q: q["type"] == "list", questions):
KeyError: 'type'
```
From my best understanding, this error happens because I didn't defined
question section in config, though I'm ok with using
ConventionalCommitsCz default ones.
This commit extends ConventionalCommitsCz to read from config and
fallbacks to defaults if some are not provided.
By adding this change, potentially customize commitizen can be
deprecated.
Closes #535.1 parent 2ff9f15 commit 440a7fa
File tree
6 files changed
+117
-75
lines changed- commitizen
- cz
- conventional_commits
- jira
- tests
6 files changed
+117
-75
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | - | ||
2 | + | ||
3 | 3 |
| |
4 | - | ||
4 | + | ||
5 | 5 |
| |
6 | - | ||
6 | + | ||
7 | 7 |
| |
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 | - | ||
13 | - | ||
14 | - | ||
15 | - | ||
16 | - | ||
17 | - | ||
18 | - | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | - | ||
23 | - | ||
24 | - | ||
25 | - | ||
26 | - | ||
27 | - | ||
28 | - | ||
29 | - | ||
30 | - | ||
31 | - | ||
32 | - | ||
33 | - | ||
34 | - | ||
35 | 12 |
| |
36 | 13 |
| |
37 | 14 |
| |
| |||
42 | 19 |
| |
43 | 20 |
| |
44 | 21 |
| |
45 | - | ||
46 | - | ||
22 | + | ||
23 | + | ||
24 | + | ||
25 | + | ||
26 | + | ||
27 | + | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | + | ||
32 | + | ||
33 | + | ||
34 | + | ||
35 | + | ||
36 | + | ||
37 | + | ||
38 | + | ||
39 | + | ||
40 | + | ||
41 | + | ||
42 | + | ||
43 | + | ||
47 | 44 |
| |
48 | 45 |
| |
49 | 46 |
| |
| |||
53 | 50 |
| |
54 | 51 |
| |
55 | 52 |
| |
56 | - | ||
57 | - | ||
58 | - | ||
59 | - | ||
60 | - | ||
61 | - | ||
62 | - | ||
63 | - | ||
64 | - | ||
65 | 53 |
| |
66 | 54 |
| |
67 | 55 |
| |
|
Lines changed: 31 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 | - | ||
4 | + | ||
5 | + | ||
6 | + | ||
7 | + | ||
8 | + | ||
5 | 9 |
| |
6 | 10 |
| |
7 | 11 |
| |
| |||
28 | 32 |
| |
29 | 33 |
| |
30 | 34 |
| |
31 | - | ||
32 | - | ||
33 | - | ||
34 | - | ||
35 | - | ||
36 | - | ||
37 | - | ||
38 | - | ||
39 | - | ||
40 | - | ||
41 | - | ||
42 | - | ||
43 | 35 |
| |
44 | 36 |
| |
45 | 37 |
| |
| |||
148 | 140 |
| |
149 | 141 |
| |
150 | 142 |
| |
151 | - | ||
143 | + | ||
144 | + | ||
152 | 145 |
| |
153 | 146 |
| |
147 | + | ||
148 | + | ||
149 | + | ||
150 | + | ||
151 | + | ||
152 | + | ||
153 | + | ||
154 | + | ||
155 | + | ||
156 | + | ||
154 | 157 |
| |
155 | 158 |
| |
156 | 159 |
| |
| |||
172 | 175 |
| |
173 | 176 |
| |
174 | 177 |
| |
175 | - | ||
176 | - | ||
177 | - | ||
178 | - | ||
179 | - | ||
180 | - | ||
178 | + | ||
179 | + | ||
180 | + | ||
181 | + | ||
182 | + | ||
183 | + | ||
184 | + | ||
185 | + | ||
186 | + | ||
181 | 187 |
| |
182 | 188 |
| |
183 | 189 |
| |
184 | - | ||
190 | + | ||
191 | + | ||
185 | 192 |
| |
186 | 193 |
| |
187 | 194 |
| |
188 | 195 |
| |
189 | - | ||
196 | + | ||
190 | 197 |
| |
191 | 198 |
| |
192 | 199 |
| |
193 | 200 |
| |
194 | - | ||
201 | + | ||
195 | 202 |
| |
196 | 203 |
| |
197 | 204 |
| |
198 | 205 |
| |
199 | 206 |
| |
200 | - | ||
207 | + | ||
201 | 208 |
| |
202 | 209 |
| |
203 | 210 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | + | ||
3 | 4 |
| |
4 | 5 |
| |
5 | 6 |
| |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
11 | + | ||
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | ||
16 | + | ||
17 | + | ||
10 | 18 |
| |
11 | 19 |
| |
12 | 20 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
34 | + | ||
35 | + | ||
34 | 36 |
| |
35 | 37 |
| |
36 | 38 |
| |
37 | 39 |
| |
40 | + | ||
38 | 41 |
| |
39 | 42 |
| |
40 | - | ||
43 | + | ||
41 | 44 |
| |
45 | + | ||
46 | + | ||
47 | + | ||
48 | + | ||
49 | + | ||
50 | + | ||
42 | 51 |
| |
43 | 52 |
| |
44 | 53 |
| |
| |||
80 | 89 |
| |
81 | 90 |
| |
82 | 91 |
| |
83 | - | ||
92 | + | ||
84 | 93 |
| |
85 | 94 |
| |
86 | 95 |
| |
87 | 96 |
| |
88 | 97 |
| |
89 | 98 |
| |
99 | + | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | + | ||
104 | + | ||
105 | + | ||
106 | + | ||
107 | + | ||
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | ||
112 | + | ||
113 | + | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + | ||
120 | + |
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 | + | ||
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
| |||
72 | 73 |
| |
73 | 74 |
| |
74 | 75 |
| |
76 | + | ||
75 | 77 |
| |
76 | 78 |
| |
77 | 79 |
| |
78 | - | ||
79 | - | ||
80 | + | ||
81 | + | ||
80 | 82 |
| |
81 | 83 |
| |
82 | 84 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 | 3 |
| |
4 | + | ||
4 | 5 |
| |
5 | 6 |
| |
6 | 7 |
| |
| |||
844 | 845 |
| |
845 | 846 |
| |
846 | 847 |
| |
847 | - | ||
848 | - | ||
848 | + | ||
849 | + | ||
850 | + | ||
849 | 851 |
| |
850 | 852 |
| |
851 | 853 |
| |
| |||
854 | 856 |
| |
855 | 857 |
| |
856 | 858 |
| |
859 | + | ||
857 | 860 |
| |
858 | - | ||
859 | - | ||
861 | + | ||
862 | + | ||
860 | 863 |
| |
861 | 864 |
| |
862 | 865 |
| |
| |||
869 | 872 |
| |
870 | 873 |
| |
871 | 874 |
| |
875 | + | ||
872 | 876 |
| |
873 | - | ||
874 | - | ||
877 | + | ||
878 | + | ||
875 | 879 |
| |
876 | 880 |
| |
877 | 881 |
| |
| |||
882 | 886 |
| |
883 | 887 |
| |
884 | 888 |
| |
889 | + | ||
885 | 890 |
| |
886 | 891 |
| |
887 | - | ||
888 | - | ||
892 | + | ||
893 | + | ||
889 | 894 |
| |
890 | 895 |
| |
891 | 896 |
| |
| |||
900 | 905 |
| |
901 | 906 |
| |
902 | 907 |
| |
903 | - | ||
904 | - | ||
908 | + | ||
909 | + | ||
910 | + | ||
905 | 911 |
| |
906 | 912 |
| |
907 | 913 |
| |
|
0 commit comments