Skip to content

Commit 668827b

Browse files
committed
[Diff][Added] tag_filter
- To select which tags are used for KIBOT_TAG
1 parent ce35400 commit 668827b

7 files changed

Lines changed: 40 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- CLI:
1111
- --keep-temporals: to keep temporal files
12+
- Diff:
13+
- `tag_filter`: to select which tags are used for KIBOT_TAG
1214

1315

1416
## [1.9.0] - 2026-05-12

docs/samples/generic_plot.kibot.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,7 @@ outputs:
11261126
# changes in the history you want to go back. A 0 is the same as `HEAD`,
11271127
# a 1 means the last time the PCB/SCH was changed, etc.
11281128
# Use `KIBOT_TAG-n` to search for the last tag skipping `n` tags.
1129+
# The tags can be filtered using `tag_filter` option.
11291130
# Important: when using the `checkout` GitHub action you just get the
11301131
# last commit. To clone the full repo use `fetch-depth: '0'`
11311132
old: 'HEAD'
@@ -1148,6 +1149,8 @@ outputs:
11481149
# Can be used to fine-tune a variant for a particular output that needs extra filtering done before the
11491150
# variant
11501151
pre_transform: '_null'
1152+
# [string=''] A regular expression used to match the used tags for `KIBOT_TAG`
1153+
tag_filter: ''
11511154
# [number=0] [0,1000000] Error threshold for the `stats` mode, 0 is no error. When specified a
11521155
# difference bigger than the indicated value will make the diff fail.
11531156
# KiBot will return error level 29 and the diff generation will be aborted

docs/source/Changelog.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Added
2323

2424
- –keep-temporals: to keep temporal files
2525

26+
- Diff:
27+
28+
- ``tag_filter``: to select which tags are used for KIBOT_TAG
29+
2630
[1.9.0] - 2026-05-12
2731
--------------------
2832

docs/source/configuration/outputs/DiffOptions.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ DiffOptions parameters
5656
changes in the history you want to go back. A 0 is the same as `HEAD`,
5757
a 1 means the last time the PCB/SCH was changed, etc. |br|
5858
Use `KIBOT_TAG-n` to search for the last tag skipping `n` tags. |br|
59+
The tags can be filtered using `tag_filter` option. |br|
5960

6061
.. note::
6162
when using the `checkout` GitHub action you just get the
@@ -79,6 +80,7 @@ DiffOptions parameters
7980
Can be used to fine-tune a variant for a particular output that needs extra filtering done before the
8081
variant.
8182

83+
- ``tag_filter`` :index:`: <pair: output - diff - options; tag_filter>` [:ref:`string <string>`] (default: ``''``) A regular expression used to match the used tags for `KIBOT_TAG`.
8284
- ``threshold`` :index:`: <pair: output - diff - options; threshold>` [:ref:`number <number>`] (default: ``0``) (range: 0 to 1000000) Error threshold for the `stats` mode, 0 is no error. When specified a
8385
difference bigger than the indicated value will make the diff fail. |br|
8486
KiBot will return error level 29 and the diff generation will be aborted.

kibot/out_diff.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def __init__(self):
5454
changes in the history you want to go back. A 0 is the same as `HEAD`,
5555
a 1 means the last time the PCB/SCH was changed, etc.
5656
Use `KIBOT_TAG-n` to search for the last tag skipping `n` tags.
57+
The tags can be filtered using `tag_filter` option.
5758
Important: when using the `checkout` GitHub action you just get the
5859
last commit. To clone the full repo use `fetch-depth: '0'` """
5960
self.old_type = 'git'
@@ -117,6 +118,8 @@ def __init__(self):
117118
""" Color used for the added stuff in the '2color' mode """
118119
self.color_removed = '#FF0000'
119120
""" Color used for the removed stuff in the '2color' mode """
121+
self.tag_filter = ''
122+
""" A regular expression used to match the used tags for `KIBOT_TAG` """
120123
super().__init__()
121124
self.add_to_doc("zones", "Be careful with the cache when changing this setting")
122125

@@ -133,6 +136,10 @@ def config(self, parent):
133136
if self.old_type == 'multivar' and self.new_type != 'multivar':
134137
raise KiPlotConfigurationError("`old_type` can't be `multivar` when `new_type` isn't (`{}`)".format(self.new_type))
135138
self.validate_colors(['color_added', 'color_removed'])
139+
try:
140+
self._tag_filter = re.compile(self.tag_filter)
141+
except Exception as e:
142+
raise KiPlotConfigurationError('Invalid regular expression '+str(e))
136143

137144
def get_targets(self, out_dir):
138145
return [self._parent.expand_filename(out_dir, self.output)]
@@ -235,8 +242,11 @@ def process_tags(self, num):
235242
skipped = 0
236243
for v in res:
237244
try:
238-
tag = v[v.index('tag: '):].split(',')[0][4:]
239-
logger.debugl(2, '- {}/{} tag: {} -> {}'.format(skipped, num, tag, commit))
245+
tag = v[v.index('tag: '):].split(',')[0][5:]
246+
matches = self._tag_filter.search(tag) is not None if self.tag_filter else True
247+
logger.debugl(2, f'- {skipped}/{num} / matches filter: {matches} - tag: `{tag}` -> {commit}')
248+
if not matches:
249+
continue
240250
if skipped == num:
241251
return commit
242252
skipped += 1

tests/GUI/outputs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,6 +2657,13 @@
26572657
],
26582658
null
26592659
],
2660+
[
2661+
"tag_filter",
2662+
[
2663+
"DataTypeString"
2664+
],
2665+
null
2666+
],
26602667
[
26612668
"zones",
26622669
[

tests/GUI/stats

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
56 outputs types with a total of 2235 different parameters
2-
Single type parameters: 2046 (92 %)
1+
56 outputs types with a total of 2236 different parameters
2+
Single type parameters: 2047 (92 %)
33
Multi type parameters: 189 (8 %)
44
Average parameters: 40
55
Maximum number of parameters: 218
@@ -67,7 +67,7 @@ Outputs sorted by parameters:
6767
- pcb2blender_tools: 34
6868
- vrml: 34
6969
- kicost: 37
70-
- diff: 41
70+
- diff: 42
7171
- excellon: 42
7272
- export_3d: 42
7373
- dxf: 43
@@ -153,7 +153,7 @@ Outputs sorted by depth:
153153
- bom: 5
154154
--------------------------------------------------------------------------------
155155
14 different data types
156-
- String: 972
156+
- String: 973
157157
- Boolean: 562
158158
- ListStringSingular: 303
159159
- Number: 303
@@ -169,7 +169,7 @@ Outputs sorted by depth:
169169
- NumberChoice: 1
170170
--------------------------------------------------------------------------------
171171
Used as single data type:
172-
- String: 805
172+
- String: 806
173173
- Boolean: 494
174174
- ListStringSingular: 300
175175
- Number: 209
@@ -414,8 +414,8 @@ Used as single data type:
414414
- Number,String: 15
415415
================================================================================
416416
================================================================================
417-
97 totals types with a total of 2633 different parameters
418-
Single type parameters: 2418 (92 %)
417+
97 totals types with a total of 2634 different parameters
418+
Single type parameters: 2419 (92 %)
419419
Multi type parameters: 215 (8 %)
420420
Average parameters: 27
421421
Maximum number of parameters: 218
@@ -524,7 +524,7 @@ Totals sorted by parameters:
524524
- vrml: 34
525525
- generic: 35
526526
- kicost: 37
527-
- diff: 41
527+
- diff: 42
528528
- excellon: 42
529529
- export_3d: 42
530530
- dxf: 43
@@ -651,7 +651,7 @@ Totals sorted by depth:
651651
- bom: 5
652652
--------------------------------------------------------------------------------
653653
14 different data types
654-
- String: 1141
654+
- String: 1142
655655
- Boolean: 665
656656
- Number: 356
657657
- ListStringSingular: 333
@@ -667,7 +667,7 @@ Totals sorted by depth:
667667
- NumberChoice: 1
668668
--------------------------------------------------------------------------------
669669
Used as single data type:
670-
- String: 956
670+
- String: 957
671671
- Boolean: 587
672672
- ListStringSingular: 330
673673
- Number: 247

0 commit comments

Comments
 (0)