kigit 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kigit-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.3
2
+ Name: kigit
3
+ Version: 0.0.1
4
+ Summary: KiCad-semantics aware git diff and git status CLI tool
5
+ Requires-Dist: typer>=0.25.1
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+
9
+ # kigit
10
+
11
+ **KiCad-aware `git diff` and `git status` for your schematics.**
12
+
13
+ [![PyPI version](https://img.shields.io/pypi/v/kigit.svg)](https://pypi.org/project/kigit/)
14
+ [![Python versions](https://img.shields.io/pypi/pyversions/kigit.svg)](https://pypi.org/project/kigit/)
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
16
+
17
+ `kigit` is a command-line tool that makes Git output for [KiCad](https://www.kicad.org/)
18
+ projects readable. Raw `git diff` on a `.kicad_sch` file is dominated by formatting,
19
+ re-ordering, and tool-generated metadata, so it tells you *that* a file changed but not
20
+ *what* meaningfully changed. `kigit` cuts through that noise and reports the change in
21
+ electrical terms instead: which nets were added, removed, renamed, or rewired.
22
+
23
+ > **Status: early preview (0.0.1).** This is the first public release. It focuses on the
24
+ > schematic netlist and intentionally does a small thing well. Interfaces and output may
25
+ > change in future versions. Bug reports and feedback are very welcome.
26
+
27
+ ---
28
+
29
+ ## What it does
30
+
31
+ `kigit` answers questions a plain text diff struggles with, such as *"Did the wiring
32
+ actually change, or is this just KiCad reshuffling the file?"*
33
+
34
+ For the schematic in your repository it:
35
+
36
+ - locates the schematic via your project (`.kicad_pro`) file,
37
+ - exports the **netlist** for two project states using KiCad's own `kicad-cli`,
38
+ - compares the two netlists semantically, ignoring text-level noise, and
39
+ - prints a structured, color-coded summary of the real changes.
40
+
41
+ It reports nets that were **added**, **removed**, **changed** (nodes/pins added,
42
+ removed, or modified; net-class changes), and **renamed** (a net whose connections are
43
+ unchanged but whose name differs). Each changed net is annotated with semantic tags such
44
+ as `power-net`, `ground-net`, `critical-net`, `high-speed-net`, connectivity level, and
45
+ impact tags like `connectivity-increased`, `node-added`, or `pin-function-changed`.
46
+ Purely cosmetic differences and unconnected (`unconnected-*`) nets are filtered out.
47
+
48
+ ### Not in scope yet
49
+
50
+ To set expectations for 0.0.1, the following are **not** analyzed yet and are planned for
51
+ later releases:
52
+
53
+ - component **value** changes (e.g. a resistor going from 10k to 4.7k),
54
+ - **PCB layout** (`.kicad_pcb`) changes,
55
+ - further changes
56
+
57
+ ---
58
+
59
+ ## Requirements
60
+
61
+ `kigit` orchestrates the tools you already use; it does not reimplement them.
62
+
63
+ - **Python** 3.10 or newer.
64
+ - **Git**, available on your `PATH`.
65
+ - **KiCad 10.x**, with the bundled **`kicad-cli`** available on your `PATH`.
66
+ (`kicad-cli` ships with the standard KiCad installation on Windows, Linux, and macOS.)
67
+
68
+ `kigit` is cross-platform and runs on **Windows and Linux** (and other platforms where
69
+ Python, Git, and KiCad are available). Run `kigit check-health` at any time to confirm
70
+ your environment is ready.
71
+
72
+ ---
73
+
74
+ ## Installation
75
+
76
+ From PyPI with `pip`:
77
+
78
+ ```bash
79
+ pip install kigit
80
+ ```
81
+
82
+ Or as an isolated tool with [uv](https://docs.astral.sh/uv/):
83
+
84
+ ```bash
85
+ uv tool install kigit
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Quick start
91
+
92
+ > **Prerequisite:** your schematic must be committed to Git at least once. `kigit`
93
+ > retrieves historical versions with `git show`, so an untracked schematic cannot be
94
+ > diffed.
95
+
96
+ ```bash
97
+ # Compare your working changes against the last commit (the "status" use case):
98
+ kigit diff
99
+
100
+ # Compare two commits, branches, or tags:
101
+ kigit diff -c1 main -c2 my-feature-branch
102
+
103
+ # See full detail instead of a summary:
104
+ kigit diff --verbose
105
+
106
+ # Confirm Git and KiCad are installed and reachable:
107
+ kigit check-health
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Commands
113
+
114
+ Run `kigit` or `kigit --help` for general help, and `kigit COMMAND --help` for details on
115
+ a specific command.
116
+
117
+ ### `kigit diff`
118
+
119
+ Summarizes the differences between two KiCad project states, filtering out noise from
120
+ formatting, ordering, and tool-generated metadata.
121
+
122
+ | Option | Alias | Default | Description |
123
+ | --- | --- | --- | --- |
124
+ | `--c1-ref` | `-c1` | `HEAD` | Git reference (commit, branch, or tag) used as the **first** state for comparison. |
125
+ | `--c2-ref` | `-c2` | *none* | Git reference used as the **second** state. When omitted, the first ref is compared against the **working-directory** schematic. |
126
+ | `--search-depth` | `-p` | `2` | How many directory levels to descend when locating the schematic file. |
127
+ | `--search-directory` | `-d` | `.` | Root directory for the schematic file lookup. |
128
+ | `--verbose` | `-v` | `false` | Show a detailed, per-net and per-node breakdown instead of a brief count summary. |
129
+
130
+ Behavior of the default invocation: with no `-c2`, `kigit diff` compares the first
131
+ reference (default `HEAD`) against the current schematic on disk — i.e. "what have I
132
+ changed since my last commit?".
133
+
134
+ ### `kigit check-health`
135
+
136
+ Verifies that all required dependencies (Git and `kicad-cli`) are present on the system
137
+ and reports any that are missing.
138
+
139
+ ### `kigit version`
140
+
141
+ Prints the installed `kigit` version.
142
+
143
+ ---
144
+
145
+ ## Example output
146
+
147
+ > The examples below are illustrative; actual output is color-coded in your terminal.
148
+
149
+ Brief summary (default):
150
+
151
+ ```text
152
+ + 3 net(s) added
153
+ - 1 net(s) removed
154
+ ~ 2 net(s) changed
155
+ ~ 1 net(s) renamed
156
+ ```
157
+
158
+ Detailed view (`--verbose`), showing how a changed net is annotated:
159
+
160
+ ```text
161
+ Changed Nets:
162
+ Net '+5V':
163
+ * properties: critical-net, power-net, medium-connectivity
164
+ * impact: connectivity-increased, critical-net-change, node-added
165
+ Added nodes:
166
+ + U3 pin 4 (VCC, power_in)
167
+ ```
168
+
169
+ When nothing meaningful changed:
170
+
171
+ ```text
172
+ No semantically meaningful changes to show.
173
+
174
+ (Hint: only added, removed, changed and renamed items are shown (i.e. code changes are discarded.)
175
+ ```
176
+
177
+ ---
178
+
179
+ ## How it works
180
+
181
+ 1. **Locate** — find the project's `.kicad_pro` and the matching `.kicad_sch` within the
182
+ configured search directory and depth.
183
+ 2. **Retrieve** — for each requested Git reference, extract that version of the schematic
184
+ with `git show <ref>:<path>` into a temporary working area.
185
+ 3. **Export** — run `kicad-cli sch export netlist --format kicadxml` on each version to
186
+ produce a netlist in KiCad XML.
187
+ 4. **Parse** — read the `<nets>` section into an immutable model of nets and their
188
+ nodes (component reference, pin, pin function, pin type).
189
+ 5. **Diff** — compute added / removed / changed / renamed nets, ignoring net codes and
190
+ `unconnected-*` nets, and detect renames by matching nets with identical connections.
191
+ 6. **Classify & report** — tag each net and change with semantic categories and print a
192
+ readable summary.
193
+
194
+ ---
195
+
196
+ ## Logs and temporary files
197
+
198
+ - Diagnostic logs are written to a `kigit-log/` directory in the current working
199
+ directory. If a run fails unexpectedly, this is the first place to look.
200
+ - Temporary working data (`.kigit_temp/`, `.kigit_netlist_temp/`) is created during a run
201
+ and cleaned up automatically afterwards.
202
+
203
+ You may wish to add `kigit-log/`, `.kigit_temp/`, and `.kigit_netlist_temp/` to your
204
+ `.gitignore`.
205
+
206
+ ---
207
+
208
+ ## Development
209
+
210
+ The project uses [uv](https://docs.astral.sh/uv/) for packaging, [pytest](https://docs.pytest.org/)
211
+ and [Hypothesis](https://hypothesis.readthedocs.io/) for testing, and
212
+ [Typer](https://typer.tiangolo.com/) for the command-line interface.
213
+
214
+ ---
215
+
216
+ ## License
217
+
218
+ `kigit` is released under the [MIT License](LICENSE).
219
+
220
+ ---
221
+
222
+ ## Acknowledgements
223
+
224
+ `kigit` is developed as a Software Engineering course project for and with help from
225
+ Auto-Intern GmbH, whose hardware team uses KiCad and Git for industrial monitoring
226
+ systems. The goal is to help engineers make better commit decisions and to keep project
227
+ history readable, with the intention of maintaining it as an open-source tool for the
228
+ wider KiCad community.
kigit-0.0.1/README.md ADDED
@@ -0,0 +1,220 @@
1
+ # kigit
2
+
3
+ **KiCad-aware `git diff` and `git status` for your schematics.**
4
+
5
+ [![PyPI version](https://img.shields.io/pypi/v/kigit.svg)](https://pypi.org/project/kigit/)
6
+ [![Python versions](https://img.shields.io/pypi/pyversions/kigit.svg)](https://pypi.org/project/kigit/)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ `kigit` is a command-line tool that makes Git output for [KiCad](https://www.kicad.org/)
10
+ projects readable. Raw `git diff` on a `.kicad_sch` file is dominated by formatting,
11
+ re-ordering, and tool-generated metadata, so it tells you *that* a file changed but not
12
+ *what* meaningfully changed. `kigit` cuts through that noise and reports the change in
13
+ electrical terms instead: which nets were added, removed, renamed, or rewired.
14
+
15
+ > **Status: early preview (0.0.1).** This is the first public release. It focuses on the
16
+ > schematic netlist and intentionally does a small thing well. Interfaces and output may
17
+ > change in future versions. Bug reports and feedback are very welcome.
18
+
19
+ ---
20
+
21
+ ## What it does
22
+
23
+ `kigit` answers questions a plain text diff struggles with, such as *"Did the wiring
24
+ actually change, or is this just KiCad reshuffling the file?"*
25
+
26
+ For the schematic in your repository it:
27
+
28
+ - locates the schematic via your project (`.kicad_pro`) file,
29
+ - exports the **netlist** for two project states using KiCad's own `kicad-cli`,
30
+ - compares the two netlists semantically, ignoring text-level noise, and
31
+ - prints a structured, color-coded summary of the real changes.
32
+
33
+ It reports nets that were **added**, **removed**, **changed** (nodes/pins added,
34
+ removed, or modified; net-class changes), and **renamed** (a net whose connections are
35
+ unchanged but whose name differs). Each changed net is annotated with semantic tags such
36
+ as `power-net`, `ground-net`, `critical-net`, `high-speed-net`, connectivity level, and
37
+ impact tags like `connectivity-increased`, `node-added`, or `pin-function-changed`.
38
+ Purely cosmetic differences and unconnected (`unconnected-*`) nets are filtered out.
39
+
40
+ ### Not in scope yet
41
+
42
+ To set expectations for 0.0.1, the following are **not** analyzed yet and are planned for
43
+ later releases:
44
+
45
+ - component **value** changes (e.g. a resistor going from 10k to 4.7k),
46
+ - **PCB layout** (`.kicad_pcb`) changes,
47
+ - further changes
48
+
49
+ ---
50
+
51
+ ## Requirements
52
+
53
+ `kigit` orchestrates the tools you already use; it does not reimplement them.
54
+
55
+ - **Python** 3.10 or newer.
56
+ - **Git**, available on your `PATH`.
57
+ - **KiCad 10.x**, with the bundled **`kicad-cli`** available on your `PATH`.
58
+ (`kicad-cli` ships with the standard KiCad installation on Windows, Linux, and macOS.)
59
+
60
+ `kigit` is cross-platform and runs on **Windows and Linux** (and other platforms where
61
+ Python, Git, and KiCad are available). Run `kigit check-health` at any time to confirm
62
+ your environment is ready.
63
+
64
+ ---
65
+
66
+ ## Installation
67
+
68
+ From PyPI with `pip`:
69
+
70
+ ```bash
71
+ pip install kigit
72
+ ```
73
+
74
+ Or as an isolated tool with [uv](https://docs.astral.sh/uv/):
75
+
76
+ ```bash
77
+ uv tool install kigit
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Quick start
83
+
84
+ > **Prerequisite:** your schematic must be committed to Git at least once. `kigit`
85
+ > retrieves historical versions with `git show`, so an untracked schematic cannot be
86
+ > diffed.
87
+
88
+ ```bash
89
+ # Compare your working changes against the last commit (the "status" use case):
90
+ kigit diff
91
+
92
+ # Compare two commits, branches, or tags:
93
+ kigit diff -c1 main -c2 my-feature-branch
94
+
95
+ # See full detail instead of a summary:
96
+ kigit diff --verbose
97
+
98
+ # Confirm Git and KiCad are installed and reachable:
99
+ kigit check-health
100
+ ```
101
+
102
+ ---
103
+
104
+ ## Commands
105
+
106
+ Run `kigit` or `kigit --help` for general help, and `kigit COMMAND --help` for details on
107
+ a specific command.
108
+
109
+ ### `kigit diff`
110
+
111
+ Summarizes the differences between two KiCad project states, filtering out noise from
112
+ formatting, ordering, and tool-generated metadata.
113
+
114
+ | Option | Alias | Default | Description |
115
+ | --- | --- | --- | --- |
116
+ | `--c1-ref` | `-c1` | `HEAD` | Git reference (commit, branch, or tag) used as the **first** state for comparison. |
117
+ | `--c2-ref` | `-c2` | *none* | Git reference used as the **second** state. When omitted, the first ref is compared against the **working-directory** schematic. |
118
+ | `--search-depth` | `-p` | `2` | How many directory levels to descend when locating the schematic file. |
119
+ | `--search-directory` | `-d` | `.` | Root directory for the schematic file lookup. |
120
+ | `--verbose` | `-v` | `false` | Show a detailed, per-net and per-node breakdown instead of a brief count summary. |
121
+
122
+ Behavior of the default invocation: with no `-c2`, `kigit diff` compares the first
123
+ reference (default `HEAD`) against the current schematic on disk — i.e. "what have I
124
+ changed since my last commit?".
125
+
126
+ ### `kigit check-health`
127
+
128
+ Verifies that all required dependencies (Git and `kicad-cli`) are present on the system
129
+ and reports any that are missing.
130
+
131
+ ### `kigit version`
132
+
133
+ Prints the installed `kigit` version.
134
+
135
+ ---
136
+
137
+ ## Example output
138
+
139
+ > The examples below are illustrative; actual output is color-coded in your terminal.
140
+
141
+ Brief summary (default):
142
+
143
+ ```text
144
+ + 3 net(s) added
145
+ - 1 net(s) removed
146
+ ~ 2 net(s) changed
147
+ ~ 1 net(s) renamed
148
+ ```
149
+
150
+ Detailed view (`--verbose`), showing how a changed net is annotated:
151
+
152
+ ```text
153
+ Changed Nets:
154
+ Net '+5V':
155
+ * properties: critical-net, power-net, medium-connectivity
156
+ * impact: connectivity-increased, critical-net-change, node-added
157
+ Added nodes:
158
+ + U3 pin 4 (VCC, power_in)
159
+ ```
160
+
161
+ When nothing meaningful changed:
162
+
163
+ ```text
164
+ No semantically meaningful changes to show.
165
+
166
+ (Hint: only added, removed, changed and renamed items are shown (i.e. code changes are discarded.)
167
+ ```
168
+
169
+ ---
170
+
171
+ ## How it works
172
+
173
+ 1. **Locate** — find the project's `.kicad_pro` and the matching `.kicad_sch` within the
174
+ configured search directory and depth.
175
+ 2. **Retrieve** — for each requested Git reference, extract that version of the schematic
176
+ with `git show <ref>:<path>` into a temporary working area.
177
+ 3. **Export** — run `kicad-cli sch export netlist --format kicadxml` on each version to
178
+ produce a netlist in KiCad XML.
179
+ 4. **Parse** — read the `<nets>` section into an immutable model of nets and their
180
+ nodes (component reference, pin, pin function, pin type).
181
+ 5. **Diff** — compute added / removed / changed / renamed nets, ignoring net codes and
182
+ `unconnected-*` nets, and detect renames by matching nets with identical connections.
183
+ 6. **Classify & report** — tag each net and change with semantic categories and print a
184
+ readable summary.
185
+
186
+ ---
187
+
188
+ ## Logs and temporary files
189
+
190
+ - Diagnostic logs are written to a `kigit-log/` directory in the current working
191
+ directory. If a run fails unexpectedly, this is the first place to look.
192
+ - Temporary working data (`.kigit_temp/`, `.kigit_netlist_temp/`) is created during a run
193
+ and cleaned up automatically afterwards.
194
+
195
+ You may wish to add `kigit-log/`, `.kigit_temp/`, and `.kigit_netlist_temp/` to your
196
+ `.gitignore`.
197
+
198
+ ---
199
+
200
+ ## Development
201
+
202
+ The project uses [uv](https://docs.astral.sh/uv/) for packaging, [pytest](https://docs.pytest.org/)
203
+ and [Hypothesis](https://hypothesis.readthedocs.io/) for testing, and
204
+ [Typer](https://typer.tiangolo.com/) for the command-line interface.
205
+
206
+ ---
207
+
208
+ ## License
209
+
210
+ `kigit` is released under the [MIT License](LICENSE).
211
+
212
+ ---
213
+
214
+ ## Acknowledgements
215
+
216
+ `kigit` is developed as a Software Engineering course project for and with help from
217
+ Auto-Intern GmbH, whose hardware team uses KiCad and Git for industrial monitoring
218
+ systems. The goal is to help engineers make better commit decisions and to keep project
219
+ history readable, with the intention of maintaining it as an open-source tool for the
220
+ wider KiCad community.
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "kigit"
3
+ version = "0.0.1"
4
+ description = "KiCad-semantics aware git diff and git status CLI tool"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ dependencies = [
8
+ "typer>=0.25.1",
9
+ ]
10
+ authors = []
11
+
12
+ [project.scripts]
13
+ kigit = "kigit.cli:app"
14
+
15
+ [build-system]
16
+ requires = ["uv_build>=0.11.9,<0.12.0"]
17
+ build-backend = "uv_build"
18
+
19
+ [dependency-groups]
20
+ dev = [
21
+ "hypothesis>=6.153.2",
22
+ "pytest>=9.0.3",
23
+ ]
24
+
25
+ [tool.pytest.ini_options]
26
+ pythonpath = ["tests"]
27
+ testpaths = ["tests"]
@@ -0,0 +1,6 @@
1
+ # Copyright (c) 2026 RUB-SELAB-2026
2
+ #
3
+ # Licensed under the MIT License.
4
+ # See the LICENSE file in the project root for full license information.
5
+
6
+ __version__ = "0.0.1"
@@ -0,0 +1,157 @@
1
+ # Copyright (c) 2026 RUB-SELAB-2026
2
+ #
3
+ # Licensed under the MIT License.
4
+ # See the LICENSE file in the project root for full license information.
5
+
6
+ import typer
7
+ from typing import Annotated
8
+ from pathlib import Path
9
+ from typer import rich_utils
10
+
11
+ from kigit.extractor import export_netlist
12
+ from kigit.parser import parse_netlist_from_xml
13
+ from kigit.file_ops import find_sch_file, cleanup_temp_data
14
+ from kigit.git_operations import get_reference_file
15
+ from kigit.diff import diff_netlists
16
+ from kigit.output_generator import generate_output
17
+ from kigit.health_checker import verify_dependencies
18
+ from kigit.logger import configure_logger, get_logger
19
+ from kigit.constants import STATUS_MESSAGES, LOG_DIR, SCHEMATICS_FILE_EXTENSION
20
+ from kigit.message_printer import print_message
21
+ import importlib.metadata
22
+ import sys
23
+
24
+ logger = get_logger()
25
+
26
+ # Override color of help subtext to white.
27
+ rich_utils.STYLE_HELPTEXT = ""
28
+
29
+ app = typer.Typer(
30
+ no_args_is_help=True,
31
+ rich_markup_mode="rich",
32
+ help="""
33
+ Welcome to kigit :sparkles:
34
+
35
+ Use [bold bright_green]kigit[/bold bright_green] or [bold bright_green]kigit --help[/bold bright_green] for general help and [bold bright_green]kigit COMMAND --help[/bold bright_green] for help on a specific command.
36
+
37
+ :warning: [yellow]Important:[/yellow] In order for this tool to work, committing an initial schematics file to the git repository is expected. An untracked schematics file won't work.
38
+ """,
39
+ )
40
+
41
+
42
+ # Runs before each command
43
+ @app.callback()
44
+ def init():
45
+ configure_logger()
46
+
47
+
48
+ @app.command()
49
+ def version():
50
+ """
51
+ Gives app version.
52
+ """
53
+ version = importlib.metadata.version("kigit")
54
+ print_message(f"kigit version {version}", type="Override")
55
+
56
+
57
+ @app.command()
58
+ def check_health():
59
+ """
60
+ Checks if all required dependencies to run kigit are present on the system.
61
+ """
62
+
63
+ verify_dependencies(silent=False)
64
+
65
+
66
+ @app.command()
67
+ def diff(
68
+ c1_ref: Annotated[
69
+ str,
70
+ typer.Option(
71
+ "--c1-ref", "-c1", help="Hash of reference commit for comparison."
72
+ ),
73
+ ] = "HEAD",
74
+ c2_ref: Annotated[
75
+ str | None,
76
+ typer.Option(
77
+ "--c2-ref",
78
+ "-c2",
79
+ help="Hash of reference commit for comparison with the first reference commit.",
80
+ ),
81
+ ] = None,
82
+ search_depth: Annotated[
83
+ int,
84
+ typer.Option(
85
+ "--search-depth",
86
+ "-p",
87
+ help="Search depth when looking up the schematics file.",
88
+ ),
89
+ ] = 2,
90
+ search_directory: Annotated[
91
+ Path,
92
+ typer.Option(
93
+ "--search-directory", "-d", help="Root path for schematics file lookup."
94
+ ),
95
+ ] = Path("."),
96
+ verbose: Annotated[
97
+ bool,
98
+ typer.Option("--verbose", "-v", help="Shows a more detailed diffing output."),
99
+ ] = False,
100
+ ):
101
+ """
102
+ Summarizes differences between two KiCad project states in a structured and understandable way, filtering out noise from formatting, ordering, and tool-generated metadata.
103
+
104
+ [deep_sky_blue1]Remarks:[/deep_sky_blue1]
105
+ When omitting the second reference commit, the comparison will be done between the first reference commit (default: HEAD) and the file in the working directory.
106
+ """
107
+
108
+ try:
109
+ result = verify_dependencies()
110
+
111
+ if not result:
112
+ raise typer.Exit(code=1)
113
+
114
+ schematics_file_path = find_sch_file(
115
+ search_directory, SCHEMATICS_FILE_EXTENSION, search_depth
116
+ )
117
+
118
+ if schematics_file_path is None:
119
+ print_message(
120
+ formatted_message=STATUS_MESSAGES[
121
+ "NO_SCHEMATICS_FILE_FOUND_MESSAGE"
122
+ ].format(search_directory=search_directory),
123
+ type="Error",
124
+ )
125
+ raise typer.Exit(code=1)
126
+
127
+ c1_sch_path = get_reference_file(c1_ref, schematics_file_path)
128
+ c1_netlist_xml = export_netlist(c1_sch_path)
129
+ c1_netlist = parse_netlist_from_xml(c1_netlist_xml)
130
+
131
+ if c2_ref is None:
132
+ c2_sch_path = schematics_file_path
133
+ else:
134
+ c2_sch_path = get_reference_file(c2_ref, schematics_file_path)
135
+
136
+ c2_netlist_xml = export_netlist(c2_sch_path)
137
+ c2_netlist = parse_netlist_from_xml(c2_netlist_xml)
138
+
139
+ netlist_diff = diff_netlists(c1_netlist, c2_netlist)
140
+
141
+ print_message(generate_output(netlist_diff, verbose), type="Override")
142
+ except typer.Exit as e:
143
+ sys.exit(e.exit_code)
144
+ except Exception as x:
145
+ logger.exception(x)
146
+ print_message(
147
+ formatted_message=STATUS_MESSAGES["GENERAL_EXCEPTION_MESSAGE"].format(
148
+ log_dir=LOG_DIR
149
+ ),
150
+ type="Error",
151
+ )
152
+ finally:
153
+ cleanup_temp_data()
154
+
155
+
156
+ if __name__ == "__main__":
157
+ app()
@@ -0,0 +1,22 @@
1
+ # Copyright (c) 2026 RUB-SELAB-2026
2
+ #
3
+ # Licensed under the MIT License.
4
+ # See the LICENSE file in the project root for full license information.
5
+
6
+ SCHEMATICS_FILE_EXTENSION = ".kicad_sch"
7
+ PROJECT_FILE_EXTENSION = ".kicad_pro"
8
+ IGNORED_LOOKUP_PATHS = [".git", ".history", "kigit-log"]
9
+ NETLIST_TEMP_DIR = ".kigit_netlist_temp"
10
+ SUBDIR_FOR_DIFFS = ".kigit_temp"
11
+ REF_SCH_FILENAME = "schematic.kicad_sch"
12
+ LOGGER_KEY = "c_logger"
13
+ LOG_DIR = "kigit-log"
14
+ LOG_FILE_NAME = "kigit.log"
15
+
16
+ STATUS_MESSAGES = {
17
+ "NO_SCHEMATICS_FILE_FOUND_MESSAGE": "No schematics file (.kicad_sch) has been found with the current parameters. Try adjusting the search depth if the file is nested.\nRoot path used: '{search_directory}'",
18
+ "GENERAL_EXCEPTION_MESSAGE": "App has exited with an exception. See the '{log_dir}' folder for app logs.",
19
+ "GIT_NOT_FOUND_MESSAGE": "Couldn't find Git on your system. Git is required for this tool to work.",
20
+ "KICAD_NOT_FOUND_MESSAGE": "Couldn't find KiCad on your system. KiCad is required for this tool to work.",
21
+ "NO_CHANGES_TO_SHOW_MESSAGE": "No semantically meaningful changes to show.\n\n (Hint: only added, removed, changed and renamed items are shown (i.e. code changes are discarded.)",
22
+ }