gerrit-checkout 0.5.3__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,259 @@
1
+ Metadata-Version: 2.4
2
+ Name: gerrit-checkout
3
+ Version: 0.5.3
4
+ Summary: Fetch and checkout Gerrit changes by topic
5
+ Home-page: https://github.com/example/gerrit-checkout
6
+ Author: Tharindu Piyasekara
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Classifier: Programming Language :: Python :: 3.14
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Environment :: Console
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: rich>=10.0.0
21
+ Dynamic: author
22
+ Dynamic: classifier
23
+ Dynamic: description
24
+ Dynamic: description-content-type
25
+ Dynamic: home-page
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+ Dynamic: summary
30
+
31
+ # gerrit-checkout
32
+
33
+ Fetch and checkout Gerrit topic changes across a single git repository or a repo-tool workspace.
34
+
35
+ The tool understands Gerrit parent relationships and can:
36
+
37
+ - keep only top changes per repository when parent changes are already included by ancestry
38
+ - discover related parent topics that are still needed for a complete local checkout
39
+ - show a dry-run execution plan with lineage to `master`
40
+ - build a complete dependency graph across recursively linked topics
41
+ - safely preflight, store, and push a full affected rebase chain
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ pip install git+https://github.com/example/gerrit-checkout.git
47
+ ```
48
+
49
+ For local development:
50
+
51
+ ```bash
52
+ pip install -e . --force-reinstall --no-deps
53
+ ```
54
+
55
+ Python dependency (`rich`) is installed by pip. `git` and `ssh` must be available on your system.
56
+
57
+ ## Usage
58
+
59
+ ```bash
60
+ gerrit-checkout --init-config [--gerrit-server SERVER]
61
+ gerrit-checkout <topic|change-number|url> [--gerrit-server SERVER] [--repo PATH] [-v] [--plan | --html-report [PATH] | --rebase [--push] | --push]
62
+ ```
63
+
64
+ The first positional argument accepts:
65
+
66
+ - a **topic name** — fetches all open changes in that topic
67
+ - a **change number** — fetches that specific change; if it belongs to a topic the full topic is loaded, otherwise the change is used directly as the dependency seed
68
+ - a **full Gerrit URL** — e.g. `https://gerrit.example.com/c/example/platform/test/+/12345`
69
+
70
+ **Note:** Change numbers are globally unique within a Gerrit server, so `12345` always refers to the same change regardless of which project it belongs to.
71
+
72
+ ### Options
73
+
74
+ - `--gerrit-server`: Gerrit server hostname (overrides config for this run only)
75
+ - `--repo`: Git repository or repo-tool workspace path (default: current directory)
76
+ - `--init-config`: Create `~/.gerrit-checkout.cfg` with default values
77
+ - `-v, --verbose`: Enable verbose traceback output on failures
78
+ - `--plan`: Preview the checkout and rebase plans. It queries Gerrit and may fetch metadata, but does not checkout, rebase, or push.
79
+ - `--html-report [PATH]`: Write the preview as HTML, optionally at `PATH`. It does not checkout, rebase, or push.
80
+ - `--rebase`: Preflight the complete affected chain bottom-to-top in temporary worktrees and store validated local Git refs only if every rebase succeeds.
81
+ - `--push`: Validate and push previously stored refs to Gerrit. With `--rebase`, push only after the complete preflight succeeds.
82
+
83
+ `--plan` and `--html-report` are preview-only modes and cannot be combined with `--rebase` or `--push`. `--rebase` and `--push` are compatible and may be used together.
84
+
85
+ Compatibility note: `--dry-run` remains an alias for `--plan`. The older `--rebase-check`, `--check-rebase`, `--auto-rebase`, and detailed report flags remain available for compatibility.
86
+
87
+ ### Command effects
88
+
89
+ ```text
90
+ gerrit-checkout TOPIC
91
+ Local working-tree changes. Fetches and checks out planned changes.
92
+
93
+ gerrit-checkout TOPIC --plan
94
+ Preview only. Queries Gerrit and may fetch metadata, but does not checkout,
95
+ rebase or push.
96
+
97
+ gerrit-checkout TOPIC --html-report [PATH]
98
+ Preview only. Writes an HTML report locally but does not checkout, rebase
99
+ or push.
100
+
101
+ gerrit-checkout TOPIC --rebase
102
+ Local Git metadata changes. Uses temporary worktrees and creates validated
103
+ local Git refs. Does not change the main working tree or push to Gerrit.
104
+
105
+ gerrit-checkout TOPIC --push
106
+ Remote Gerrit changes. Validates and pushes previously stored rebases.
107
+
108
+ gerrit-checkout TOPIC --rebase --push
109
+ Remote Gerrit changes. Preflights the complete affected chain bottom-to-top
110
+ and pushes only when every rebase succeeds. A conflict or validation failure
111
+ pushes nothing.
112
+ ```
113
+
114
+ Server value precedence:
115
+
116
+ 1. `--gerrit-server` (CLI override, current run only)
117
+ 2. `~/.gerrit-checkout.cfg` -> `[gerrit].server`
118
+
119
+ If no server is set in either place, the command exits with an error.
120
+
121
+ Note: `gerrit.example.com` in the config template below is a sample only. Update it to your actual Gerrit hostname.
122
+
123
+ ### Config file
124
+
125
+ `--init-config` creates this file:
126
+
127
+ ```ini
128
+ [gerrit]
129
+ server = gerrit.example.com
130
+ repo_path = .
131
+ ```
132
+
133
+ For one-step setup, run `gerrit-checkout --init-config --gerrit-server YOUR_HOST`.
134
+
135
+ If the config file already exists, `--init-config` updates it.
136
+
137
+ ## What It Does
138
+
139
+ For a source topic, the tool will:
140
+
141
+ 1. query every open Gerrit change in the source topic
142
+ 2. recursively discover open parent topics and build one complete dependency graph
143
+ 3. group changes by normalized project and target branch, split them into connected components, and identify every component head
144
+ 4. independently build a rebase plan containing every affected open change
145
+ 5. either report the plans, checkout the repository leaves, or safely preflight the rebase chain
146
+
147
+ By default, mutations are limited to `git fetch`, checkout, temporary preflight worktrees, and tool-managed refs. Push happens only when `--push` is used.
148
+
149
+ A connected chain in one repository is represented by checking out its head. If a repository has multiple independent heads, preview modes show all of them, while normal checkout stops with a clear error because one worktree cannot represent multiple independent histories. Use separate worktrees manually for those heads.
150
+
151
+ ## Output
152
+
153
+ ### Preview plan
154
+
155
+ `--plan` prints a unified table that includes:
156
+
157
+ - source-topic top changes
158
+ - related-topic changes that are already covered by the source topic
159
+ - related-topic changes that still need local checkout
160
+ - a relation tree showing how each change reaches `master`
161
+ - stale parent issues and rebase status
162
+ - which changes would be rebased and which are blocked
163
+
164
+ Use `--html-report [PATH]` to write the preview to an HTML file for easier reading.
165
+
166
+ ### Rebase status
167
+
168
+ The rebase status view marks each change as one of:
169
+
170
+ - `rebased on latest open parent`
171
+ - `parent already merged to master`
172
+ - `warning: needs rebase`
173
+ - `warning: parent unresolved`
174
+
175
+ When stale parents are found, the tool prints a warning summary after the table.
176
+
177
+ ### Rebase
178
+
179
+ `--rebase` builds explicit dependency components from current revision parents. It finds every stale parent edge and adds only the open descendants in that component. Each component is ordered bottom-to-top; independent components are never stacked onto one another.
180
+
181
+ - every patch set and parent ref is fetched and checked against the revision returned during planning
182
+ - each change is replayed in a disposable Git worktree; the user's current branch, index, and files are not changed
183
+ - each child is replayed onto the newly generated commit for its parent
184
+ - Gerrit `Change-Id` footers are verified before and after every replay
185
+ - unresolved parents, merge commits, conflicts, and rebase failures block the operation and return a non-zero exit code
186
+ - a conflict names the failing change and every blocked descendant; no changes are pushed
187
+ - local tool-managed refs are stored only after the complete graph passes preflight
188
+
189
+ ### Push
190
+
191
+ `--push` publishes previously rebased local changes in bottom-to-top order.
192
+
193
+ - before the first push, every stored result is checked against its original Gerrit revision, its validated parent, its current Gerrit patch set, and its `Change-Id`
194
+ - a missing, stale, or modified local ref prevents all pushes and returns a non-zero exit code
195
+ - pushes stop immediately if Gerrit rejects any change; later descendants remain unpushed
196
+ - successfully pushed local refs and their validation metadata are cleaned up automatically
197
+
198
+ ### Safety and exit status
199
+
200
+ Preflight may fetch Gerrit objects and create temporary worktrees, but it never checks out or rebases in the user's working tree. Temporary worktrees are removed whether a replay succeeds or conflicts. No Gerrit push starts until every affected change has passed preflight and every stored ref has passed freshness validation.
201
+
202
+ The command exits non-zero for unresolved dependencies, conflicts, rebase failures, stale stored refs, push failures, and descendants blocked by any of those failures. A preview also exits non-zero when it reports unresolved rebase dependencies, which makes it suitable for CI validation.
203
+
204
+ ### Examples
205
+
206
+ ```bash
207
+ # By topic name
208
+ gerrit-checkout FEATURE-1234
209
+
210
+ # By change number
211
+ gerrit-checkout 12345
212
+
213
+ # By full Gerrit URL
214
+ gerrit-checkout "https://gerrit.example.com/c/example/platform/test/+/12345"
215
+
216
+ # Preview the full checkout plan (no actual fetch/checkout)
217
+ gerrit-checkout FEATURE-1234 --plan
218
+
219
+ # Write preview output to the default HTML report location
220
+ gerrit-checkout FEATURE-1234 --html-report
221
+
222
+ # Write preview output to an explicit path
223
+ gerrit-checkout FEATURE-1234 --html-report gerrit-checkout-report.html
224
+
225
+ # Rebase stale changes locally in dependency order
226
+ gerrit-checkout FEATURE-1234 --rebase
227
+
228
+ # Push previously rebased changes
229
+ gerrit-checkout FEATURE-1234 --push
230
+
231
+ # Rebase now and push immediately after
232
+ gerrit-checkout FEATURE-1234 --rebase --push
233
+
234
+ # Use an explicit Gerrit host for one run
235
+ gerrit-checkout FEATURE-1234 --gerrit-server gerrit.example.com
236
+
237
+ # Create default config once
238
+ gerrit-checkout --init-config --gerrit-server gerrit.example.com
239
+ ```
240
+
241
+ ## Requirements
242
+
243
+ - Python 3.7+
244
+ - Git
245
+ - SSH access to Gerrit
246
+
247
+ ## Uninstall
248
+
249
+ ```bash
250
+ python3 -m pip uninstall -y gerrit-checkout && rm -f ~/.gerrit-checkout.cfg
251
+ ```
252
+
253
+ ## 0.5.2
254
+
255
+ The 0.5.2 release validates that every rebase candidate maps to exactly one Git commit before replay. It rejects multi-commit ranges and unsupported merge or root commits, then verifies the new parent, changed paths, commit message, and Gerrit Change-Id before storing refs or allowing a push. Rebase output now distinguishes topic changes, supporting parents, dependency chains, replayed commits, stored ref sets, and pushed changes.
256
+
257
+ ## License
258
+
259
+ MIT
@@ -0,0 +1,229 @@
1
+ # gerrit-checkout
2
+
3
+ Fetch and checkout Gerrit topic changes across a single git repository or a repo-tool workspace.
4
+
5
+ The tool understands Gerrit parent relationships and can:
6
+
7
+ - keep only top changes per repository when parent changes are already included by ancestry
8
+ - discover related parent topics that are still needed for a complete local checkout
9
+ - show a dry-run execution plan with lineage to `master`
10
+ - build a complete dependency graph across recursively linked topics
11
+ - safely preflight, store, and push a full affected rebase chain
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install git+https://github.com/example/gerrit-checkout.git
17
+ ```
18
+
19
+ For local development:
20
+
21
+ ```bash
22
+ pip install -e . --force-reinstall --no-deps
23
+ ```
24
+
25
+ Python dependency (`rich`) is installed by pip. `git` and `ssh` must be available on your system.
26
+
27
+ ## Usage
28
+
29
+ ```bash
30
+ gerrit-checkout --init-config [--gerrit-server SERVER]
31
+ gerrit-checkout <topic|change-number|url> [--gerrit-server SERVER] [--repo PATH] [-v] [--plan | --html-report [PATH] | --rebase [--push] | --push]
32
+ ```
33
+
34
+ The first positional argument accepts:
35
+
36
+ - a **topic name** — fetches all open changes in that topic
37
+ - a **change number** — fetches that specific change; if it belongs to a topic the full topic is loaded, otherwise the change is used directly as the dependency seed
38
+ - a **full Gerrit URL** — e.g. `https://gerrit.example.com/c/example/platform/test/+/12345`
39
+
40
+ **Note:** Change numbers are globally unique within a Gerrit server, so `12345` always refers to the same change regardless of which project it belongs to.
41
+
42
+ ### Options
43
+
44
+ - `--gerrit-server`: Gerrit server hostname (overrides config for this run only)
45
+ - `--repo`: Git repository or repo-tool workspace path (default: current directory)
46
+ - `--init-config`: Create `~/.gerrit-checkout.cfg` with default values
47
+ - `-v, --verbose`: Enable verbose traceback output on failures
48
+ - `--plan`: Preview the checkout and rebase plans. It queries Gerrit and may fetch metadata, but does not checkout, rebase, or push.
49
+ - `--html-report [PATH]`: Write the preview as HTML, optionally at `PATH`. It does not checkout, rebase, or push.
50
+ - `--rebase`: Preflight the complete affected chain bottom-to-top in temporary worktrees and store validated local Git refs only if every rebase succeeds.
51
+ - `--push`: Validate and push previously stored refs to Gerrit. With `--rebase`, push only after the complete preflight succeeds.
52
+
53
+ `--plan` and `--html-report` are preview-only modes and cannot be combined with `--rebase` or `--push`. `--rebase` and `--push` are compatible and may be used together.
54
+
55
+ Compatibility note: `--dry-run` remains an alias for `--plan`. The older `--rebase-check`, `--check-rebase`, `--auto-rebase`, and detailed report flags remain available for compatibility.
56
+
57
+ ### Command effects
58
+
59
+ ```text
60
+ gerrit-checkout TOPIC
61
+ Local working-tree changes. Fetches and checks out planned changes.
62
+
63
+ gerrit-checkout TOPIC --plan
64
+ Preview only. Queries Gerrit and may fetch metadata, but does not checkout,
65
+ rebase or push.
66
+
67
+ gerrit-checkout TOPIC --html-report [PATH]
68
+ Preview only. Writes an HTML report locally but does not checkout, rebase
69
+ or push.
70
+
71
+ gerrit-checkout TOPIC --rebase
72
+ Local Git metadata changes. Uses temporary worktrees and creates validated
73
+ local Git refs. Does not change the main working tree or push to Gerrit.
74
+
75
+ gerrit-checkout TOPIC --push
76
+ Remote Gerrit changes. Validates and pushes previously stored rebases.
77
+
78
+ gerrit-checkout TOPIC --rebase --push
79
+ Remote Gerrit changes. Preflights the complete affected chain bottom-to-top
80
+ and pushes only when every rebase succeeds. A conflict or validation failure
81
+ pushes nothing.
82
+ ```
83
+
84
+ Server value precedence:
85
+
86
+ 1. `--gerrit-server` (CLI override, current run only)
87
+ 2. `~/.gerrit-checkout.cfg` -> `[gerrit].server`
88
+
89
+ If no server is set in either place, the command exits with an error.
90
+
91
+ Note: `gerrit.example.com` in the config template below is a sample only. Update it to your actual Gerrit hostname.
92
+
93
+ ### Config file
94
+
95
+ `--init-config` creates this file:
96
+
97
+ ```ini
98
+ [gerrit]
99
+ server = gerrit.example.com
100
+ repo_path = .
101
+ ```
102
+
103
+ For one-step setup, run `gerrit-checkout --init-config --gerrit-server YOUR_HOST`.
104
+
105
+ If the config file already exists, `--init-config` updates it.
106
+
107
+ ## What It Does
108
+
109
+ For a source topic, the tool will:
110
+
111
+ 1. query every open Gerrit change in the source topic
112
+ 2. recursively discover open parent topics and build one complete dependency graph
113
+ 3. group changes by normalized project and target branch, split them into connected components, and identify every component head
114
+ 4. independently build a rebase plan containing every affected open change
115
+ 5. either report the plans, checkout the repository leaves, or safely preflight the rebase chain
116
+
117
+ By default, mutations are limited to `git fetch`, checkout, temporary preflight worktrees, and tool-managed refs. Push happens only when `--push` is used.
118
+
119
+ A connected chain in one repository is represented by checking out its head. If a repository has multiple independent heads, preview modes show all of them, while normal checkout stops with a clear error because one worktree cannot represent multiple independent histories. Use separate worktrees manually for those heads.
120
+
121
+ ## Output
122
+
123
+ ### Preview plan
124
+
125
+ `--plan` prints a unified table that includes:
126
+
127
+ - source-topic top changes
128
+ - related-topic changes that are already covered by the source topic
129
+ - related-topic changes that still need local checkout
130
+ - a relation tree showing how each change reaches `master`
131
+ - stale parent issues and rebase status
132
+ - which changes would be rebased and which are blocked
133
+
134
+ Use `--html-report [PATH]` to write the preview to an HTML file for easier reading.
135
+
136
+ ### Rebase status
137
+
138
+ The rebase status view marks each change as one of:
139
+
140
+ - `rebased on latest open parent`
141
+ - `parent already merged to master`
142
+ - `warning: needs rebase`
143
+ - `warning: parent unresolved`
144
+
145
+ When stale parents are found, the tool prints a warning summary after the table.
146
+
147
+ ### Rebase
148
+
149
+ `--rebase` builds explicit dependency components from current revision parents. It finds every stale parent edge and adds only the open descendants in that component. Each component is ordered bottom-to-top; independent components are never stacked onto one another.
150
+
151
+ - every patch set and parent ref is fetched and checked against the revision returned during planning
152
+ - each change is replayed in a disposable Git worktree; the user's current branch, index, and files are not changed
153
+ - each child is replayed onto the newly generated commit for its parent
154
+ - Gerrit `Change-Id` footers are verified before and after every replay
155
+ - unresolved parents, merge commits, conflicts, and rebase failures block the operation and return a non-zero exit code
156
+ - a conflict names the failing change and every blocked descendant; no changes are pushed
157
+ - local tool-managed refs are stored only after the complete graph passes preflight
158
+
159
+ ### Push
160
+
161
+ `--push` publishes previously rebased local changes in bottom-to-top order.
162
+
163
+ - before the first push, every stored result is checked against its original Gerrit revision, its validated parent, its current Gerrit patch set, and its `Change-Id`
164
+ - a missing, stale, or modified local ref prevents all pushes and returns a non-zero exit code
165
+ - pushes stop immediately if Gerrit rejects any change; later descendants remain unpushed
166
+ - successfully pushed local refs and their validation metadata are cleaned up automatically
167
+
168
+ ### Safety and exit status
169
+
170
+ Preflight may fetch Gerrit objects and create temporary worktrees, but it never checks out or rebases in the user's working tree. Temporary worktrees are removed whether a replay succeeds or conflicts. No Gerrit push starts until every affected change has passed preflight and every stored ref has passed freshness validation.
171
+
172
+ The command exits non-zero for unresolved dependencies, conflicts, rebase failures, stale stored refs, push failures, and descendants blocked by any of those failures. A preview also exits non-zero when it reports unresolved rebase dependencies, which makes it suitable for CI validation.
173
+
174
+ ### Examples
175
+
176
+ ```bash
177
+ # By topic name
178
+ gerrit-checkout FEATURE-1234
179
+
180
+ # By change number
181
+ gerrit-checkout 12345
182
+
183
+ # By full Gerrit URL
184
+ gerrit-checkout "https://gerrit.example.com/c/example/platform/test/+/12345"
185
+
186
+ # Preview the full checkout plan (no actual fetch/checkout)
187
+ gerrit-checkout FEATURE-1234 --plan
188
+
189
+ # Write preview output to the default HTML report location
190
+ gerrit-checkout FEATURE-1234 --html-report
191
+
192
+ # Write preview output to an explicit path
193
+ gerrit-checkout FEATURE-1234 --html-report gerrit-checkout-report.html
194
+
195
+ # Rebase stale changes locally in dependency order
196
+ gerrit-checkout FEATURE-1234 --rebase
197
+
198
+ # Push previously rebased changes
199
+ gerrit-checkout FEATURE-1234 --push
200
+
201
+ # Rebase now and push immediately after
202
+ gerrit-checkout FEATURE-1234 --rebase --push
203
+
204
+ # Use an explicit Gerrit host for one run
205
+ gerrit-checkout FEATURE-1234 --gerrit-server gerrit.example.com
206
+
207
+ # Create default config once
208
+ gerrit-checkout --init-config --gerrit-server gerrit.example.com
209
+ ```
210
+
211
+ ## Requirements
212
+
213
+ - Python 3.7+
214
+ - Git
215
+ - SSH access to Gerrit
216
+
217
+ ## Uninstall
218
+
219
+ ```bash
220
+ python3 -m pip uninstall -y gerrit-checkout && rm -f ~/.gerrit-checkout.cfg
221
+ ```
222
+
223
+ ## 0.5.2
224
+
225
+ The 0.5.2 release validates that every rebase candidate maps to exactly one Git commit before replay. It rejects multi-commit ranges and unsupported merge or root commits, then verifies the new parent, changed paths, commit message, and Gerrit Change-Id before storing refs or allowing a push. Rebase output now distinguishes topic changes, supporting parents, dependency chains, replayed commits, stored ref sets, and pushed changes.
226
+
227
+ ## License
228
+
229
+ MIT
@@ -0,0 +1,5 @@
1
+ """Gerrit Checkout - Fetch and checkout Gerrit changes by topic."""
2
+
3
+ __version__ = "0.5.3"
4
+ __author__ = "Tharindu Piyasekara"
5
+ __email__ = ""