git-clerk 0.1.0__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,38 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write
14
+ contents: write
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - name: Verify tag is on main
22
+ run: |
23
+ git fetch origin main
24
+ if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
25
+ echo "::error::Tag ${{ github.ref_name }} does not point to a commit on main"
26
+ exit 1
27
+ fi
28
+
29
+ - uses: astral-sh/setup-uv@v5
30
+
31
+ - run: uv build
32
+
33
+ - name: Create GitHub release
34
+ run: gh release create "${{ github.ref_name }}" --generate-notes
35
+ env:
36
+ GH_TOKEN: ${{ github.token }}
37
+
38
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,47 @@
1
+ name: Check
2
+
3
+ on:
4
+ push:
5
+ branches: ["**"]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ changes:
11
+ runs-on: ubuntu-latest
12
+ outputs:
13
+ src: ${{ steps.filter.outputs.src }}
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: dorny/paths-filter@v4.0.1
17
+ id: filter
18
+ with:
19
+ filters: |
20
+ src:
21
+ - 'src/**'
22
+ - 'tests/**'
23
+
24
+ test:
25
+ needs: changes
26
+ if: needs.changes.outputs.src == 'true'
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: astral-sh/setup-uv@v5
31
+ with:
32
+ enable-cache: true
33
+ cache-dependency-glob: "pyproject.toml"
34
+ - run: uv sync --all-groups
35
+ - run: uv run ruff check
36
+ - run: uv run ruff format --check
37
+ - run: uv run pyright
38
+ - run: uv run pytest
39
+
40
+ status:
41
+ needs: [changes, test]
42
+ if: always()
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - run: |
46
+ result="${{ needs.test.result }}"
47
+ [[ "$result" == "failure" || "$result" == "cancelled" ]] && exit 1 || exit 0
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ dist/
4
+ *.egg-info/
5
+ .venv/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ .pyright/
9
+ .idea/
10
+ .DS_Store
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nicolas Contreras
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,344 @@
1
+ Metadata-Version: 2.4
2
+ Name: git-clerk
3
+ Version: 0.1.0
4
+ Summary: Structured git workflow CLI: conventional commits, trunk-based branches, GitHub PR lifecycle
5
+ Project-URL: Homepage, https://github.com/nicobc/git-clerk
6
+ Project-URL: Source, https://github.com/nicobc/git-clerk
7
+ Project-URL: Issues, https://github.com/nicobc/git-clerk/issues
8
+ Author-email: Nicolas Contreras <nicolas.b.contreras@gmail.com>
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Environment :: Console
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Version Control :: Git
16
+ Requires-Python: >=3.10
17
+ Requires-Dist: click>=8.0
18
+ Description-Content-Type: text/markdown
19
+
20
+ # git-clerk
21
+
22
+ A structured git workflow CLI for [conventional commits](https://www.conventionalcommits.org/), trunk-based branching, and a clean GitHub PR lifecycle — all from the command line.
23
+
24
+ ## Philosophy
25
+
26
+ git-clerk is built on three practices that reinforce each other: [trunk-based development](https://trunkbaseddevelopment.com/), [conventional commits](https://www.conventionalcommits.org/), and squash-merge-only history. Short-lived branches stay close to `main`. Squash merges keep `main`'s history linear and readable — one commit per feature. Conventional commit types make that history meaningful at a glance. git-clerk connects all three as a unit: you name your branch `feat/user-auth` once, and every commit message, PR title, and release tag follows from that single decision.
27
+
28
+ ## Opinions
29
+
30
+ git-clerk is intentionally opinionated. These constraints are not configurable:
31
+
32
+ - **GitHub only** — PR and release operations rely on `gh`. GitLab and Bitbucket are not supported.
33
+ - **Squash merges** — `ship` always squash-merges to keep `main`'s history linear.
34
+ - **Single trunk** — `main` is the only integration branch. `develop`, `release/*`, and similar long-lived branches are out of scope. The trunk name is not configurable — repositories using a different default branch are not supported.
35
+ - **Conventional commits** — branch names must follow `type/scope` using one of the [11 standard types](https://www.conventionalcommits.org).
36
+
37
+ If your workflow diverges from any of these, git-clerk is not the right tool.
38
+
39
+ ## Prerequisites
40
+
41
+ **Local**
42
+
43
+ - Python 3.10+
44
+ - [uv](https://docs.astral.sh/uv/) for installation
45
+ - [GitHub CLI](https://cli.github.com/) (`gh`) authenticated to your GitHub account
46
+
47
+ **Repository configuration**
48
+
49
+ git-clerk assumes the repository is configured to match its workflow. Without this, the tool still works but its guarantees don't hold — anyone can bypass conventions by using `git` and `gh` directly.
50
+
51
+ Ask your infra or platform team to configure:
52
+
53
+ - **Squash merges only** — disable merge commits and rebase merges so `main` stays linear
54
+ - **Branch protection on `main`** — require pull requests before merging; disallow direct pushes
55
+ - **Required status checks** — require CI to pass before a PR can be merged; this makes `git clerk ship`'s CI gate structural rather than advisory
56
+
57
+ ## Installation
58
+
59
+ ```sh
60
+ uv tool install git-clerk
61
+ ```
62
+
63
+ To use it as `git clerk` (recommended) rather than `git-clerk`, register a git alias:
64
+
65
+ ```sh
66
+ git config --global alias.clerk '!git-clerk'
67
+ ```
68
+
69
+ After this, `git clerk` prints help and `git clerk commit --help` (any subcommand) works as expected. Note that `git clerk --help` will not work — git intercepts `--help` before running the alias and tries to open a man page. Use `git clerk` or `git-clerk --help` for top-level help instead.
70
+
71
+ ## Workflow walkthrough
72
+
73
+ Here is a complete cycle from starting a feature to tagging a release.
74
+
75
+ **1. Create a branch**
76
+
77
+ ```sh
78
+ git clerk branch feat/user-auth
79
+ ```
80
+
81
+ Fetches the latest `origin/main` and creates `feat/user-auth` from it. The branch name is the only thing you decide upfront — type and scope flow into every subsequent command automatically.
82
+
83
+ **2. Do your work, then commit**
84
+
85
+ ```sh
86
+ git clerk commit -A "add login form"
87
+ ```
88
+
89
+ Stages all changes and commits with the message `feat(user-auth): add login form`. The type and scope come from the branch name — you only write the description.
90
+
91
+ For commits that need more context, pass the body as a second argument or open your editor with `-e`:
92
+
93
+ ```sh
94
+ git clerk commit -A "add login form" "Supports email and SSO providers."
95
+ # → commits with inline body (useful in scripts and LLM workflows)
96
+
97
+ git clerk commit -A -e "add login form"
98
+ # → opens $EDITOR for the body, then commits
99
+ ```
100
+
101
+ You can commit as many times as you want. Only the squash commit that lands on `main` is permanent.
102
+
103
+ **3. Open a PR**
104
+
105
+ ```sh
106
+ git clerk pr "Add login form"
107
+ ```
108
+
109
+ Pushes the branch with upstream tracking set, creates the PR against `main`, prints the URL, then watches CI checks until they complete. You can share the URL while CI is still running.
110
+
111
+ By default no body is added. To add one:
112
+
113
+ ```sh
114
+ git clerk pr "Add login form" "Adds email/password and SSO login. Closes #42."
115
+ # inline body
116
+
117
+ git clerk pr -e "Add login form"
118
+ # opens $EDITOR for the body
119
+ ```
120
+
121
+ **4. Ship it**
122
+
123
+ Once CI is green:
124
+
125
+ ```sh
126
+ git clerk ship
127
+ ```
128
+
129
+ Shows you the PR title and number, asks for confirmation, then: squash-merges into `main`, deletes the remote branch, switches to local `main`, pulls, and force-deletes the local branch. You end up on a clean, up-to-date `main` in one step.
130
+
131
+ **5. Tag a release**
132
+
133
+ ```sh
134
+ git clerk release
135
+ ```
136
+
137
+ Detects your versioning scheme from existing tags, computes the next version, shows you the tag, and asks for confirmation before pushing. On a fresh repo with no tags, it prompts you to choose CalVer or SemVer.
138
+
139
+ ## Commands
140
+
141
+ ### `branch TYPE/scope`
142
+
143
+ Fetches the latest `origin/main` and creates a new branch from it.
144
+
145
+ ```sh
146
+ git clerk branch feat/user-auth # → feat/user-auth
147
+ git clerk branch fix/payment-api # → fix/payment-api
148
+ git clerk branch chore/deps # → chore/deps
149
+ ```
150
+
151
+ The branch name is the only decision you make upfront. Every subsequent `commit` and `pr` command reads the type and scope from it — you never repeat yourself.
152
+
153
+ The fetch happens before branch creation, so you always start from the latest `main` regardless of how long ago you last pulled. If the branch already exists locally, git will error — delete it first or choose a different name.
154
+
155
+ ### `commit DESCRIPTION [BODY]`
156
+
157
+ Creates a conventional commit by reading the type and scope from the current branch name. The commit message header is always `type(scope): description` — you only supply the description.
158
+
159
+ ```sh
160
+ git clerk commit "add login form"
161
+ # → feat(user-auth): add login form
162
+ ```
163
+
164
+ **Body**
165
+
166
+ By default there is no body — most commits don't need one. There are three ways to add one:
167
+
168
+ ```sh
169
+ # Inline — pass the body as a second positional argument.
170
+ # Useful in scripts and LLM-driven workflows.
171
+ git clerk commit "add login form" "Supports email and SSO providers."
172
+
173
+ # Interactive — open $EDITOR. Save and exit to use the body; quit without
174
+ # saving to commit with no body.
175
+ git clerk commit -e "add login form"
176
+ ```
177
+
178
+ An empty string passed as BODY is treated the same as no body — only a non-empty string is included in the commit.
179
+
180
+ **Options**
181
+
182
+ | Flag | Description |
183
+ |------|-------------|
184
+ | `-A` | Stage all changes (`git add -A`) before committing |
185
+ | `-e` | Open `$EDITOR` to write the commit body interactively |
186
+ | `-t TYPE` | Override the type inferred from the branch name |
187
+ | `-s SCOPE` | Override the scope inferred from the branch name |
188
+
189
+ The `-t` and `-s` overrides are for cases where the commit type or scope differs from the branch — for example, bumping a lockfile on a `feat` branch:
190
+
191
+ ```sh
192
+ git clerk commit -t chore "update lockfile" # chore(user-auth): update lockfile
193
+ git clerk commit -s auth-core "fix token TTL" # feat(auth-core): fix token TTL
194
+ ```
195
+
196
+ ### `pr TITLE [BODY]`
197
+
198
+ Pushes the current branch to origin (with upstream tracking), creates a GitHub PR against `main` with a conventional title derived from the branch name, prints the PR URL, then watches CI checks until they complete.
199
+
200
+ The PR title is constructed the same way as a commit header: `type(scope): title`. You supply only the human-readable title.
201
+
202
+ **Body**
203
+
204
+ By default no body is added. There are two ways to add one:
205
+
206
+ ```sh
207
+ # Inline — pass the body as a second positional argument.
208
+ # Useful in scripts and LLM-driven workflows.
209
+ git clerk pr "Add login form" "Adds email/password and SSO login. Closes #42."
210
+
211
+ # Interactive — open $EDITOR. Save and exit to use the body;
212
+ # quit without saving to create the PR with no body.
213
+ git clerk pr -e "Add login form"
214
+ ```
215
+
216
+ An empty string passed as BODY is treated the same as no body.
217
+
218
+ **Options**
219
+
220
+ | Flag | Description |
221
+ |------|-------------|
222
+ | `-e` | Open `$EDITOR` to write the PR body interactively |
223
+ | `-t TYPE` | Override the type in the PR title |
224
+ | `-s SCOPE` | Override the scope in the PR title |
225
+
226
+ The PR URL is printed to stdout as soon as the PR is created, before CI checks begin — you can share it while checks are still running. If checks fail, the run ends with a non-zero exit code.
227
+
228
+ ### `ship`
229
+
230
+ Squash-merges the current branch's PR and brings your local environment back to a clean state on `main`. Must be run from the feature branch, not from `main`.
231
+
232
+ ```sh
233
+ git clerk ship
234
+ ```
235
+
236
+ Displays the PR title and number, asks for confirmation, then executes in order:
237
+
238
+ 1. Squash-merges the PR into `main`
239
+ 2. Deletes the remote branch
240
+ 3. Switches to local `main`
241
+ 4. Pulls latest from `origin/main`
242
+ 5. Force-deletes the local branch
243
+
244
+ You end up on a clean, up-to-date `main` in one step. If the local branch doesn't exist — because you're shipping someone else's PR, or because a previous partial run already cleaned it up — step 5 is skipped with a warning rather than erroring.
245
+
246
+ **Options**
247
+
248
+ | Flag | Description |
249
+ |------|-------------|
250
+ | `-y` / `--yes` | Skip the confirmation prompt |
251
+ | `-u BRANCH` | After shipping, switch to BRANCH and merge `origin/main` into it |
252
+
253
+ `-u` is for cases where you paused work on one branch to ship a dependency first:
254
+
255
+ ```sh
256
+ # Shipping fix/tech-debt while feat/user-auth is parked
257
+ git clerk ship -u feat/user-auth
258
+ # → ships fix/tech-debt, then switches to feat/user-auth and merges origin/main
259
+ ```
260
+
261
+ `-y` is useful in automated contexts where you want to ship without interactive confirmation:
262
+
263
+ ```sh
264
+ git clerk ship -y
265
+ ```
266
+
267
+ ### `watch`
268
+
269
+ Re-attaches to CI checks for the current branch's PR. Useful when you want to check in on CI after navigating away from the terminal during a `pr` run.
270
+
271
+ ```sh
272
+ git clerk watch
273
+ ```
274
+
275
+ ### `release`
276
+
277
+ Tags the current tip of `origin/main` and pushes the tag. Supports CalVer and SemVer.
278
+
279
+ git-clerk fetches the latest tags, computes the next version, shows you what it's about to create, and asks for confirmation before pushing anything.
280
+
281
+ ```sh
282
+ git clerk release # auto-detect scheme, bump patch
283
+ git clerk release --semver --bump minor
284
+ git clerk release --semver --bump major
285
+ git clerk release --calver
286
+ ```
287
+
288
+ **Scheme detection**
289
+
290
+ If the repository already has version tags, git-clerk detects the scheme automatically — `--calver` and `--semver` are not needed. If no tags exist yet, git-clerk prompts you to choose interactively. Pass `--calver` or `--semver` to skip the prompt.
291
+
292
+ If both CalVer and SemVer tags are found (e.g. after a scheme migration), git-clerk exits with an error. Pass `--calver` or `--semver` explicitly to proceed.
293
+
294
+ **Options**
295
+
296
+ | Flag | Description |
297
+ |------|-------------|
298
+ | `--calver` | Use calendar versioning |
299
+ | `--semver` | Use semantic versioning |
300
+ | `--bump patch\|minor\|major` | SemVer component to increment (default: `patch`, ignored for CalVer) |
301
+ | `-y` / `--yes` | Skip the confirmation prompt |
302
+
303
+ ## Versioning schemes
304
+
305
+ ### CalVer — `vYYYY.MM.N`
306
+
307
+ Tags are tied to the calendar month, with a sequential counter that resets each month:
308
+
309
+ ```
310
+ v2026.06.1
311
+ v2026.06.2
312
+ v2026.07.1 ← new month, counter resets
313
+ ```
314
+
315
+ Good fit for projects that ship continuously and want version numbers that communicate when something was released.
316
+
317
+ ### SemVer — `vMAJOR.MINOR.PATCH`
318
+
319
+ Standard semantic versioning. The first tag on a repo with no prior tags starts at `v0.1.0`.
320
+
321
+ ```
322
+ v0.1.0 → v0.1.1 (patch)
323
+ v0.1.1 → v0.2.0 (minor)
324
+ v0.2.0 → v1.0.0 (major)
325
+ ```
326
+
327
+ The tag is always placed on `origin/main`, so run `release` after shipping all PRs for the version.
328
+
329
+ ## Branch naming
330
+
331
+ All commands that read from the branch name (`commit`, `pr`) expect the format `type/scope`:
332
+
333
+ ```
334
+ feat/user-auth
335
+ fix/payment-timeout
336
+ chore/upgrade-deps
337
+ docs/api-reference
338
+ ```
339
+
340
+ The type must be one of the standard conventional commit types: `build`, `chore`, `ci`, `docs`, `feat`, `fix`, `perf`, `refactor`, `revert`, `style`, `test`. The scope must start with a letter or digit and may contain letters, digits, hyphens, and underscores — spaces and special characters are not allowed. Both are validated by `branch` before the branch is created, and by `commit` and `pr` when reading the current branch name.
341
+
342
+ ## License
343
+
344
+ MIT