git-gx 0.9.2__tar.gz → 0.10.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.
- {git_gx-0.9.2 → git_gx-0.10.1}/PKG-INFO +40 -9
- {git_gx-0.9.2 → git_gx-0.10.1}/README.md +37 -6
- git_gx-0.10.1/pyproject.toml +186 -0
- git_gx-0.9.2/pyproject.toml → git_gx-0.10.1/pyproject.toml.orig +12 -15
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/__init__.py +1 -1
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/cli.py +3 -1
- git_gx-0.10.1/src/gx/commands/integrate.py +139 -0
- git_gx-0.10.1/src/gx/commands/log.py +90 -0
- git_gx-0.10.1/src/gx/commands/pull.py +121 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/push.py +107 -3
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/constants.py +3 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/branch.py +31 -8
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/config.py +36 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/git.py +30 -11
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/github.py +4 -5
- git_gx-0.10.1/src/gx/lib/log_graph.py +288 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/log_panel.py +2 -2
- git_gx-0.10.1/src/gx/lib/options.py +36 -0
- git_gx-0.10.1/src/gx/lib/sync.py +384 -0
- git_gx-0.9.2/src/gx/commands/log.py +0 -158
- git_gx-0.9.2/src/gx/commands/pull.py +0 -58
- git_gx-0.9.2/src/gx/lib/options.py +0 -18
- git_gx-0.9.2/src/gx/lib/sync.py +0 -90
- {git_gx-0.9.2 → git_gx-0.10.1}/LICENSE +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/__init__.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/clean.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/done.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/feat.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/info.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/commands/status.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/__init__.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/display.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/info_panels.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/nclutils_logging.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/stale_analyzer.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/status_panel.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/workspace.py +0 -0
- {git_gx-0.9.2 → git_gx-0.10.1}/src/gx/lib/worktree.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: git-gx
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.1
|
|
4
4
|
Summary: A CLI that wraps common git commands with sensible defaults, safety guards, and helpful summaries.
|
|
5
5
|
Author: Nate Landau
|
|
6
6
|
Author-email: Nate Landau <github@natenate.org>
|
|
@@ -27,9 +27,9 @@ License: MIT License
|
|
|
27
27
|
SOFTWARE.
|
|
28
28
|
Classifier: Programming Language :: Python :: 3.13
|
|
29
29
|
Classifier: Programming Language :: Python :: 3.14
|
|
30
|
-
Requires-Dist: nclutils>=3.4.
|
|
30
|
+
Requires-Dist: nclutils>=3.4.4,<4.0.0
|
|
31
31
|
Requires-Dist: rich>=15.0.0,<16.0.0
|
|
32
|
-
Requires-Dist: typer>=0.
|
|
32
|
+
Requires-Dist: typer>=0.27.2,<1.0.0
|
|
33
33
|
Requires-Python: >=3.13, <3.15
|
|
34
34
|
Description-Content-Type: text/markdown
|
|
35
35
|
|
|
@@ -41,7 +41,7 @@ A CLI wrapper around git that adds sensible defaults, safety guards, and summari
|
|
|
41
41
|
|
|
42
42
|
- Auto-numbered feature branches with optional worktree isolation
|
|
43
43
|
- Push with dirty-tree warnings and a confirmation prompt before touching the default branch
|
|
44
|
-
- Pull with automatic stash/unstash and rebase
|
|
44
|
+
- Pull with automatic stash/unstash and rebase, with guided rebase-or-merge reconciliation on divergence
|
|
45
45
|
- Batch cleanup of merged, gone, and empty branches
|
|
46
46
|
- Color-coded commit log across all branches with inline branch and tag badges
|
|
47
47
|
- Repository dashboard with metadata, branches, GitHub info, and recent commits
|
|
@@ -71,7 +71,7 @@ gx done # checkout main, pull, delete feat/1
|
|
|
71
71
|
|
|
72
72
|
## Commands
|
|
73
73
|
|
|
74
|
-
Every command supports `-h` for help. The mutating commands (`feat`, `push`, `pull`, `clean`, `done`) and `log` also support `-v`/`-vv` for verbosity and `-n` for dry-run.
|
|
74
|
+
Every command supports `-h` for help. The mutating commands (`feat`, `push`, `pull`, `integrate`, `clean`, `done`) and `log` also support `-v`/`-vv` for verbosity and `-n` for dry-run.
|
|
75
75
|
|
|
76
76
|
### `gx info`
|
|
77
77
|
|
|
@@ -105,9 +105,12 @@ Color-coded commit log inside a panel. Includes commits from all branches, with
|
|
|
105
105
|
gx log # last 15 commits
|
|
106
106
|
gx log -c 30 # last 30 commits
|
|
107
107
|
gx log --full # include commit bodies
|
|
108
|
-
gx log --graph # branch
|
|
108
|
+
gx log --graph # branch graph of all branches, long runs folded
|
|
109
|
+
gx log --graph --full # branch graph with every commit
|
|
109
110
|
```
|
|
110
111
|
|
|
112
|
+
The graph reaches back past the point where each local branch leaves the default branch, so you can see which commit every branch and worktree starts from. Long runs of commits with no branch or tag fold into one `… N more commits` line. `-c` sets the least number of commits to show.
|
|
113
|
+
|
|
111
114
|
### `gx feat`
|
|
112
115
|
|
|
113
116
|
Create a feature branch from the latest default branch. Without a name, branches are auto-numbered (`feat/1`, `feat/2`, ...), filling gaps in the sequence. The `feat/` prefix is configurable.
|
|
@@ -144,10 +147,13 @@ Safety guards:
|
|
|
144
147
|
|
|
145
148
|
### `gx pull`
|
|
146
149
|
|
|
147
|
-
Fetch and rebase the current branch onto its upstream. Handles uncommitted changes automatically.
|
|
150
|
+
Fetch and rebase the current branch onto its upstream. Handles uncommitted changes automatically. If the branch has diverged from its upstream, gx guides you through reconciling it instead of failing the rebase.
|
|
148
151
|
|
|
149
152
|
```sh
|
|
150
153
|
gx pull # pull and rebase
|
|
154
|
+
gx pull --rebase # reconcile a diverged branch by rebasing
|
|
155
|
+
gx pull --merge # reconcile a diverged branch with a merge commit
|
|
156
|
+
gx pull --ff-only # only fast-forward; fail if the branch has diverged
|
|
151
157
|
gx pull -v # pull with debug output
|
|
152
158
|
```
|
|
153
159
|
|
|
@@ -155,12 +161,33 @@ The full sequence:
|
|
|
155
161
|
|
|
156
162
|
1. Stash uncommitted changes (including untracked files)
|
|
157
163
|
2. Fetch from the remote
|
|
158
|
-
3. Rebase onto the upstream branch
|
|
164
|
+
3. Rebase onto the upstream branch, or reconcile a divergence
|
|
159
165
|
4. Update submodules if `.gitmodules` is present
|
|
160
166
|
5. Restore the stash
|
|
161
167
|
6. Print a summary of new commits
|
|
162
168
|
|
|
163
|
-
If a rebase conflict occurs, gx
|
|
169
|
+
If the branch has only diverged (both ahead of and behind its upstream), gx shows the commits unique to each side and asks whether to reconcile by rebase or merge, unless `--rebase`, `--merge`, `--ff-only`, or the `integrate.strategy` config setting already decides it. If a rebase or merge conflict occurs, gx leaves the operation in progress and prints resolution steps; any changes it stashed are left in the stash for you to restore with `git stash pop` after you resolve the conflict.
|
|
170
|
+
|
|
171
|
+
### `gx integrate` (alias: `gx int`)
|
|
172
|
+
|
|
173
|
+
Reconcile the current branch with another ref, choosing between rebase and merge when they've diverged. Unlike `gx pull`, it doesn't touch your upstream or stash: it refuses to run on a dirty working tree instead.
|
|
174
|
+
|
|
175
|
+
```sh
|
|
176
|
+
gx integrate # reconcile with the upstream
|
|
177
|
+
gx integrate main # bring main into the current branch
|
|
178
|
+
gx integrate main --merge # merge main in without prompting
|
|
179
|
+
gx int main -n # preview integrating main
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The current branch always receives the changes. With no argument, gx integrates against the upstream tracking branch; given a ref (a local branch like `main` or a remote-qualified ref like `origin/main`), gx fetches it if it names a known remote and brings its commits into the current branch.
|
|
183
|
+
|
|
184
|
+
Depending on how the branch relates to the target:
|
|
185
|
+
|
|
186
|
+
- **Already up to date**: nothing to do.
|
|
187
|
+
- **Fast-forward** (only behind): gx fast-forwards automatically.
|
|
188
|
+
- **Diverged** (both ahead and behind): gx previews the commits unique to each side, then reconciles by rebase or merge. Pass `--rebase`, `--merge`, or `--ff-only` to skip the prompt, or set `integrate.strategy` in your config. `--ff-only` fails cleanly if the branch has actually diverged.
|
|
189
|
+
|
|
190
|
+
`gx integrate` refuses to run against a dirty working tree. Commit or stash your changes first.
|
|
164
191
|
|
|
165
192
|
### `gx clean`
|
|
166
193
|
|
|
@@ -220,6 +247,9 @@ name = "origin" # default remote name
|
|
|
220
247
|
|
|
221
248
|
[display]
|
|
222
249
|
nerd_font = true # use Nerd Font icons in the log (see Icons below)
|
|
250
|
+
|
|
251
|
+
[integrate]
|
|
252
|
+
strategy = "ask" # ask, rebase, merge, or ff-only: default strategy for reconciling a diverged branch
|
|
223
253
|
```
|
|
224
254
|
|
|
225
255
|
Every key is optional. Only specify the ones you want to change.
|
|
@@ -248,6 +278,7 @@ Override any setting per-invocation with environment variables. These take prior
|
|
|
248
278
|
| `GX_PROTECTED_BRANCHES` | `GX_PROTECTED_BRANCHES=main,production gx clean` |
|
|
249
279
|
| `GX_REMOTE_NAME` | `GX_REMOTE_NAME=upstream gx push` |
|
|
250
280
|
| `GX_NERD_FONT` | `GX_NERD_FONT=false gx log` |
|
|
281
|
+
| `GX_INTEGRATE_STRATEGY` | `GX_INTEGRATE_STRATEGY=rebase gx pull` |
|
|
251
282
|
|
|
252
283
|
## License
|
|
253
284
|
|
|
@@ -6,7 +6,7 @@ A CLI wrapper around git that adds sensible defaults, safety guards, and summari
|
|
|
6
6
|
|
|
7
7
|
- Auto-numbered feature branches with optional worktree isolation
|
|
8
8
|
- Push with dirty-tree warnings and a confirmation prompt before touching the default branch
|
|
9
|
-
- Pull with automatic stash/unstash and rebase
|
|
9
|
+
- Pull with automatic stash/unstash and rebase, with guided rebase-or-merge reconciliation on divergence
|
|
10
10
|
- Batch cleanup of merged, gone, and empty branches
|
|
11
11
|
- Color-coded commit log across all branches with inline branch and tag badges
|
|
12
12
|
- Repository dashboard with metadata, branches, GitHub info, and recent commits
|
|
@@ -36,7 +36,7 @@ gx done # checkout main, pull, delete feat/1
|
|
|
36
36
|
|
|
37
37
|
## Commands
|
|
38
38
|
|
|
39
|
-
Every command supports `-h` for help. The mutating commands (`feat`, `push`, `pull`, `clean`, `done`) and `log` also support `-v`/`-vv` for verbosity and `-n` for dry-run.
|
|
39
|
+
Every command supports `-h` for help. The mutating commands (`feat`, `push`, `pull`, `integrate`, `clean`, `done`) and `log` also support `-v`/`-vv` for verbosity and `-n` for dry-run.
|
|
40
40
|
|
|
41
41
|
### `gx info`
|
|
42
42
|
|
|
@@ -70,9 +70,12 @@ Color-coded commit log inside a panel. Includes commits from all branches, with
|
|
|
70
70
|
gx log # last 15 commits
|
|
71
71
|
gx log -c 30 # last 30 commits
|
|
72
72
|
gx log --full # include commit bodies
|
|
73
|
-
gx log --graph # branch
|
|
73
|
+
gx log --graph # branch graph of all branches, long runs folded
|
|
74
|
+
gx log --graph --full # branch graph with every commit
|
|
74
75
|
```
|
|
75
76
|
|
|
77
|
+
The graph reaches back past the point where each local branch leaves the default branch, so you can see which commit every branch and worktree starts from. Long runs of commits with no branch or tag fold into one `… N more commits` line. `-c` sets the least number of commits to show.
|
|
78
|
+
|
|
76
79
|
### `gx feat`
|
|
77
80
|
|
|
78
81
|
Create a feature branch from the latest default branch. Without a name, branches are auto-numbered (`feat/1`, `feat/2`, ...), filling gaps in the sequence. The `feat/` prefix is configurable.
|
|
@@ -109,10 +112,13 @@ Safety guards:
|
|
|
109
112
|
|
|
110
113
|
### `gx pull`
|
|
111
114
|
|
|
112
|
-
Fetch and rebase the current branch onto its upstream. Handles uncommitted changes automatically.
|
|
115
|
+
Fetch and rebase the current branch onto its upstream. Handles uncommitted changes automatically. If the branch has diverged from its upstream, gx guides you through reconciling it instead of failing the rebase.
|
|
113
116
|
|
|
114
117
|
```sh
|
|
115
118
|
gx pull # pull and rebase
|
|
119
|
+
gx pull --rebase # reconcile a diverged branch by rebasing
|
|
120
|
+
gx pull --merge # reconcile a diverged branch with a merge commit
|
|
121
|
+
gx pull --ff-only # only fast-forward; fail if the branch has diverged
|
|
116
122
|
gx pull -v # pull with debug output
|
|
117
123
|
```
|
|
118
124
|
|
|
@@ -120,12 +126,33 @@ The full sequence:
|
|
|
120
126
|
|
|
121
127
|
1. Stash uncommitted changes (including untracked files)
|
|
122
128
|
2. Fetch from the remote
|
|
123
|
-
3. Rebase onto the upstream branch
|
|
129
|
+
3. Rebase onto the upstream branch, or reconcile a divergence
|
|
124
130
|
4. Update submodules if `.gitmodules` is present
|
|
125
131
|
5. Restore the stash
|
|
126
132
|
6. Print a summary of new commits
|
|
127
133
|
|
|
128
|
-
If a rebase conflict occurs, gx
|
|
134
|
+
If the branch has only diverged (both ahead of and behind its upstream), gx shows the commits unique to each side and asks whether to reconcile by rebase or merge, unless `--rebase`, `--merge`, `--ff-only`, or the `integrate.strategy` config setting already decides it. If a rebase or merge conflict occurs, gx leaves the operation in progress and prints resolution steps; any changes it stashed are left in the stash for you to restore with `git stash pop` after you resolve the conflict.
|
|
135
|
+
|
|
136
|
+
### `gx integrate` (alias: `gx int`)
|
|
137
|
+
|
|
138
|
+
Reconcile the current branch with another ref, choosing between rebase and merge when they've diverged. Unlike `gx pull`, it doesn't touch your upstream or stash: it refuses to run on a dirty working tree instead.
|
|
139
|
+
|
|
140
|
+
```sh
|
|
141
|
+
gx integrate # reconcile with the upstream
|
|
142
|
+
gx integrate main # bring main into the current branch
|
|
143
|
+
gx integrate main --merge # merge main in without prompting
|
|
144
|
+
gx int main -n # preview integrating main
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
The current branch always receives the changes. With no argument, gx integrates against the upstream tracking branch; given a ref (a local branch like `main` or a remote-qualified ref like `origin/main`), gx fetches it if it names a known remote and brings its commits into the current branch.
|
|
148
|
+
|
|
149
|
+
Depending on how the branch relates to the target:
|
|
150
|
+
|
|
151
|
+
- **Already up to date**: nothing to do.
|
|
152
|
+
- **Fast-forward** (only behind): gx fast-forwards automatically.
|
|
153
|
+
- **Diverged** (both ahead and behind): gx previews the commits unique to each side, then reconciles by rebase or merge. Pass `--rebase`, `--merge`, or `--ff-only` to skip the prompt, or set `integrate.strategy` in your config. `--ff-only` fails cleanly if the branch has actually diverged.
|
|
154
|
+
|
|
155
|
+
`gx integrate` refuses to run against a dirty working tree. Commit or stash your changes first.
|
|
129
156
|
|
|
130
157
|
### `gx clean`
|
|
131
158
|
|
|
@@ -185,6 +212,9 @@ name = "origin" # default remote name
|
|
|
185
212
|
|
|
186
213
|
[display]
|
|
187
214
|
nerd_font = true # use Nerd Font icons in the log (see Icons below)
|
|
215
|
+
|
|
216
|
+
[integrate]
|
|
217
|
+
strategy = "ask" # ask, rebase, merge, or ff-only: default strategy for reconciling a diverged branch
|
|
188
218
|
```
|
|
189
219
|
|
|
190
220
|
Every key is optional. Only specify the ones you want to change.
|
|
@@ -213,6 +243,7 @@ Override any setting per-invocation with environment variables. These take prior
|
|
|
213
243
|
| `GX_PROTECTED_BRANCHES` | `GX_PROTECTED_BRANCHES=main,production gx clean` |
|
|
214
244
|
| `GX_REMOTE_NAME` | `GX_REMOTE_NAME=upstream gx push` |
|
|
215
245
|
| `GX_NERD_FONT` | `GX_NERD_FONT=false gx log` |
|
|
246
|
+
| `GX_INTEGRATE_STRATEGY` | `GX_INTEGRATE_STRATEGY=rebase gx pull` |
|
|
216
247
|
|
|
217
248
|
## License
|
|
218
249
|
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
classifiers = [
|
|
3
|
+
"Programming Language :: Python :: 3.13",
|
|
4
|
+
"Programming Language :: Python :: 3.14",
|
|
5
|
+
]
|
|
6
|
+
dependencies = [
|
|
7
|
+
"nclutils>=3.4.4,<4.0.0",
|
|
8
|
+
"rich>=15.0.0, <16.0.0",
|
|
9
|
+
"typer>=0.27.2,<1.0.0",
|
|
10
|
+
]
|
|
11
|
+
description = "A CLI that wraps common git commands with sensible defaults, safety guards, and helpful summaries."
|
|
12
|
+
name = "git-gx"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.13,<3.15"
|
|
15
|
+
version = "0.10.1"
|
|
16
|
+
|
|
17
|
+
[[project.authors]]
|
|
18
|
+
name = "Nate Landau"
|
|
19
|
+
email = "github@natenate.org"
|
|
20
|
+
|
|
21
|
+
[project.license]
|
|
22
|
+
file = "LICENSE"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
gx = "gx.cli:main"
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
build-backend = "uv_build"
|
|
29
|
+
requires = ["uv_build>=0.11.0,<0.12.0"]
|
|
30
|
+
|
|
31
|
+
[tool.uv.build-backend]
|
|
32
|
+
module-name = "gx"
|
|
33
|
+
|
|
34
|
+
[tool.commitizen]
|
|
35
|
+
bump_message = "bump(release): v$current_version → v$new_version"
|
|
36
|
+
changelog_merge_prerelease = true
|
|
37
|
+
tag_format = "v$version"
|
|
38
|
+
update_changelog_on_bump = true
|
|
39
|
+
version_files = ["src/gx/__init__.py:__version__"]
|
|
40
|
+
version_provider = "uv"
|
|
41
|
+
|
|
42
|
+
[tool.coverage.report]
|
|
43
|
+
exclude_lines = [
|
|
44
|
+
"def __repr__",
|
|
45
|
+
'except [\w\s\._]+ as .*:',
|
|
46
|
+
"if TYPE_CHECKING",
|
|
47
|
+
"pragma: no cover",
|
|
48
|
+
]
|
|
49
|
+
fail_under = 10
|
|
50
|
+
show_missing = true
|
|
51
|
+
skip_covered = true
|
|
52
|
+
skip_empty = true
|
|
53
|
+
|
|
54
|
+
[tool.coverage.run]
|
|
55
|
+
branch = true
|
|
56
|
+
command_line = "--module pytest"
|
|
57
|
+
data_file = ".cache/coverage"
|
|
58
|
+
omit = ["tests/*"]
|
|
59
|
+
source = ["src"]
|
|
60
|
+
|
|
61
|
+
[tool.coverage.xml]
|
|
62
|
+
output = ".cache/coverage.xml"
|
|
63
|
+
|
|
64
|
+
[tool.pytest.ini_options]
|
|
65
|
+
addopts = "--color=yes --doctest-modules --strict-config --strict-markers -n auto --dist loadfile"
|
|
66
|
+
cache_dir = ".cache/pytest"
|
|
67
|
+
columns = 120
|
|
68
|
+
filterwarnings = [
|
|
69
|
+
"error",
|
|
70
|
+
"ignore:.*Pydantic.*:UserWarning",
|
|
71
|
+
"ignore::DeprecationWarning:",
|
|
72
|
+
]
|
|
73
|
+
markers = ["serial"]
|
|
74
|
+
set_columns = true
|
|
75
|
+
testpaths = ["tests"]
|
|
76
|
+
xfail_strict = true
|
|
77
|
+
|
|
78
|
+
[tool.ruff]
|
|
79
|
+
exclude = [
|
|
80
|
+
".cache",
|
|
81
|
+
".git",
|
|
82
|
+
".venv",
|
|
83
|
+
"build",
|
|
84
|
+
"dist",
|
|
85
|
+
"reference",
|
|
86
|
+
]
|
|
87
|
+
fix = true
|
|
88
|
+
line-length = 100
|
|
89
|
+
output-format = "grouped"
|
|
90
|
+
src = [
|
|
91
|
+
"src",
|
|
92
|
+
"tests",
|
|
93
|
+
]
|
|
94
|
+
target-version = "py313"
|
|
95
|
+
|
|
96
|
+
[tool.ruff.lint]
|
|
97
|
+
ignore = [
|
|
98
|
+
"ANN002",
|
|
99
|
+
"ANN003",
|
|
100
|
+
"ANN204",
|
|
101
|
+
"COM812",
|
|
102
|
+
"CPY001",
|
|
103
|
+
"D107",
|
|
104
|
+
"E501",
|
|
105
|
+
"FIX002",
|
|
106
|
+
"PLC0415",
|
|
107
|
+
"S311",
|
|
108
|
+
"TD001",
|
|
109
|
+
"TD002",
|
|
110
|
+
"TD003",
|
|
111
|
+
]
|
|
112
|
+
select = ["ALL"]
|
|
113
|
+
unfixable = [
|
|
114
|
+
"ERA001",
|
|
115
|
+
"F401",
|
|
116
|
+
"F841",
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
[tool.ruff.lint.per-file-ignores]
|
|
120
|
+
"tests/**/*.py" = [
|
|
121
|
+
"A002",
|
|
122
|
+
"A003",
|
|
123
|
+
"ANN001",
|
|
124
|
+
"ANN002",
|
|
125
|
+
"ANN003",
|
|
126
|
+
"ANN201",
|
|
127
|
+
"ARG001",
|
|
128
|
+
"ARG002",
|
|
129
|
+
"ARG005",
|
|
130
|
+
"D102",
|
|
131
|
+
"ERA001",
|
|
132
|
+
"F403",
|
|
133
|
+
"F405",
|
|
134
|
+
"FBT001",
|
|
135
|
+
"PGH003",
|
|
136
|
+
"PLC0415",
|
|
137
|
+
"PLR0913",
|
|
138
|
+
"PLR0917",
|
|
139
|
+
"PLR2004",
|
|
140
|
+
"PLW0108",
|
|
141
|
+
"S101",
|
|
142
|
+
"SLF001",
|
|
143
|
+
"W292",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[tool.ruff.lint.mccabe]
|
|
147
|
+
max-complexity = 10
|
|
148
|
+
|
|
149
|
+
[tool.ruff.lint.pydocstyle]
|
|
150
|
+
convention = "google"
|
|
151
|
+
|
|
152
|
+
[tool.ruff.lint.pylint]
|
|
153
|
+
max-args = 7
|
|
154
|
+
|
|
155
|
+
[tool.ruff.lint.flake8-annotations]
|
|
156
|
+
allow-star-arg-any = true
|
|
157
|
+
|
|
158
|
+
[tool.ruff.format]
|
|
159
|
+
indent-style = "space"
|
|
160
|
+
line-ending = "auto"
|
|
161
|
+
quote-style = "double"
|
|
162
|
+
skip-magic-trailing-comma = false
|
|
163
|
+
|
|
164
|
+
[tool.ty.terminal]
|
|
165
|
+
error-on-warning = true
|
|
166
|
+
|
|
167
|
+
[dependency-groups]
|
|
168
|
+
dev = [
|
|
169
|
+
"commitizen>=4.19.0",
|
|
170
|
+
"coverage>=7.16.2",
|
|
171
|
+
"duty>=1.10.0",
|
|
172
|
+
"prek>=0.5.4",
|
|
173
|
+
"pytest-clarity>=1.0.1",
|
|
174
|
+
"pytest-cov>=7.1.0",
|
|
175
|
+
"pytest-devtools>=1.3.0",
|
|
176
|
+
"pytest-mock>=3.16.0",
|
|
177
|
+
"pytest-repeat>=0.9.4",
|
|
178
|
+
"pytest-sugar>=1.1.1",
|
|
179
|
+
"pytest-xdist>=3.8.0",
|
|
180
|
+
"pytest>=9.1.1",
|
|
181
|
+
"ruff>=0.16.9",
|
|
182
|
+
"shellcheck-py>=0.11.0.1",
|
|
183
|
+
"ty>=0.0.84",
|
|
184
|
+
"typos>=1.50.3",
|
|
185
|
+
"yamllint>=1.38.0",
|
|
186
|
+
]
|
|
@@ -4,17 +4,13 @@
|
|
|
4
4
|
"Programming Language :: Python :: 3.13",
|
|
5
5
|
"Programming Language :: Python :: 3.14",
|
|
6
6
|
]
|
|
7
|
-
dependencies = [
|
|
8
|
-
"nclutils>=3.4.1,<4.0.0",
|
|
9
|
-
"rich>=15.0.0, <16.0.0",
|
|
10
|
-
"typer>=0.26.7,<1.0.0",
|
|
11
|
-
]
|
|
7
|
+
dependencies = ["nclutils>=3.4.4,<4.0.0", "rich>=15.0.0, <16.0.0", "typer>=0.27.2,<1.0.0"]
|
|
12
8
|
description = "A CLI that wraps common git commands with sensible defaults, safety guards, and helpful summaries."
|
|
13
9
|
license = { file = "LICENSE" }
|
|
14
10
|
name = "git-gx"
|
|
15
11
|
readme = "README.md"
|
|
16
12
|
requires-python = ">=3.13,<3.15"
|
|
17
|
-
version = "0.
|
|
13
|
+
version = "0.10.1"
|
|
18
14
|
|
|
19
15
|
[project.scripts]
|
|
20
16
|
gx = "gx.cli:main"
|
|
@@ -28,22 +24,22 @@
|
|
|
28
24
|
|
|
29
25
|
[dependency-groups]
|
|
30
26
|
dev = [
|
|
31
|
-
"commitizen>=4.
|
|
32
|
-
"coverage>=7.
|
|
33
|
-
"duty>=1.
|
|
34
|
-
"prek>=0.4
|
|
27
|
+
"commitizen>=4.19.0",
|
|
28
|
+
"coverage>=7.16.2",
|
|
29
|
+
"duty>=1.10.0",
|
|
30
|
+
"prek>=0.5.4",
|
|
35
31
|
"pytest-clarity>=1.0.1",
|
|
36
32
|
"pytest-cov>=7.1.0",
|
|
37
|
-
"pytest-devtools>=1.
|
|
38
|
-
"pytest-mock>=3.
|
|
33
|
+
"pytest-devtools>=1.3.0",
|
|
34
|
+
"pytest-mock>=3.16.0",
|
|
39
35
|
"pytest-repeat>=0.9.4",
|
|
40
36
|
"pytest-sugar>=1.1.1",
|
|
41
37
|
"pytest-xdist>=3.8.0",
|
|
42
38
|
"pytest>=9.1.1",
|
|
43
|
-
"ruff>=0.
|
|
39
|
+
"ruff>=0.16.9",
|
|
44
40
|
"shellcheck-py>=0.11.0.1",
|
|
45
|
-
"ty>=0.0.
|
|
46
|
-
"typos>=1.
|
|
41
|
+
"ty>=0.0.84",
|
|
42
|
+
"typos>=1.50.3",
|
|
47
43
|
"yamllint>=1.38.0",
|
|
48
44
|
]
|
|
49
45
|
|
|
@@ -130,6 +126,7 @@
|
|
|
130
126
|
"PGH003", # Use specific rule codes when ignoring type issues
|
|
131
127
|
"PLC0415", # Imports should be at top of file
|
|
132
128
|
"PLR0913",
|
|
129
|
+
"PLR0917", # Too many positional arguments
|
|
133
130
|
"PLR2004",
|
|
134
131
|
"PLW0108", # Lambda may be unnecessary; consider inlining inner function
|
|
135
132
|
"S101",
|
|
@@ -8,7 +8,7 @@ from nclutils.git import is_git_repo
|
|
|
8
8
|
from typer import rich_utils
|
|
9
9
|
|
|
10
10
|
from gx import __version__
|
|
11
|
-
from gx.commands import clean, done, feat, info, log, pull, push, status
|
|
11
|
+
from gx.commands import clean, done, feat, info, integrate, log, pull, push, status
|
|
12
12
|
from gx.lib.git import check_git_installed
|
|
13
13
|
from gx.lib.nclutils_logging import configure_nclutils_logging
|
|
14
14
|
from gx.lib.options import VERBOSE_OPTION
|
|
@@ -26,6 +26,8 @@ app.add_typer(done.app, name="done")
|
|
|
26
26
|
app.add_typer(status.app, name="status")
|
|
27
27
|
app.add_typer(log.app, name="log")
|
|
28
28
|
app.add_typer(info.app, name="info")
|
|
29
|
+
app.add_typer(integrate.app, name="integrate")
|
|
30
|
+
app.add_typer(integrate.app, name="int")
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
def _version_callback(value: bool) -> None: # noqa: FBT001
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"""Integrate subcommand for gx."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import typer
|
|
6
|
+
from nclutils import pp
|
|
7
|
+
from nclutils.git import ahead_behind, current_branch, is_dirty, tracking_branch
|
|
8
|
+
|
|
9
|
+
from gx.lib.branch import is_remote_ref
|
|
10
|
+
from gx.lib.git import check_git_repo, git, raise_on_error, set_dry_run
|
|
11
|
+
from gx.lib.options import (
|
|
12
|
+
DRY_RUN_OPTION,
|
|
13
|
+
FF_ONLY_OPTION,
|
|
14
|
+
MERGE_OPTION,
|
|
15
|
+
REBASE_OPTION,
|
|
16
|
+
VERBOSE_OPTION,
|
|
17
|
+
)
|
|
18
|
+
from gx.lib.sync import (
|
|
19
|
+
SyncState,
|
|
20
|
+
announce_push_hint,
|
|
21
|
+
classify_sync_state,
|
|
22
|
+
ensure_one_strategy_flag,
|
|
23
|
+
fast_forward,
|
|
24
|
+
reconcile_divergence,
|
|
25
|
+
warn_if_stale_base,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
CONTEXT_SETTINGS = {"help_option_names": ["-h", "--help"]}
|
|
29
|
+
|
|
30
|
+
app = typer.Typer(rich_markup_mode="rich", context_settings=CONTEXT_SETTINGS)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
REF_ARGUMENT: str | None = typer.Argument(
|
|
34
|
+
None,
|
|
35
|
+
help="Ref to integrate into the current branch. Defaults to the upstream.",
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _resolve_target(ref: str | None) -> tuple[str, str | None]:
|
|
40
|
+
"""Resolve the target ref and the remote to fetch, if any.
|
|
41
|
+
|
|
42
|
+
Args:
|
|
43
|
+
ref: The positional ref argument, or None to use the upstream.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
A (target_ref, fetch_remote) tuple. fetch_remote is None when the
|
|
47
|
+
target is a local branch that needs no fetch.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
typer.Exit: When no ref is given and no upstream is configured.
|
|
51
|
+
"""
|
|
52
|
+
if ref is not None:
|
|
53
|
+
fetch_remote = ref.split("/", 1)[0] if is_remote_ref(ref) else None
|
|
54
|
+
return ref, fetch_remote
|
|
55
|
+
|
|
56
|
+
tracking = tracking_branch()
|
|
57
|
+
if tracking is None:
|
|
58
|
+
pp.info("Nothing to integrate: no upstream is configured.")
|
|
59
|
+
raise typer.Exit(0)
|
|
60
|
+
remote, remote_branch = tracking
|
|
61
|
+
return f"{remote}/{remote_branch}", remote
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@app.callback(invoke_without_command=True)
|
|
65
|
+
def integrate(
|
|
66
|
+
ctx: typer.Context, # noqa: ARG001
|
|
67
|
+
ref: str | None = REF_ARGUMENT,
|
|
68
|
+
verbose: int = VERBOSE_OPTION,
|
|
69
|
+
dry_run: bool = DRY_RUN_OPTION, # noqa: FBT001
|
|
70
|
+
rebase: bool = REBASE_OPTION, # noqa: FBT001
|
|
71
|
+
merge: bool = MERGE_OPTION, # noqa: FBT001
|
|
72
|
+
ff_only: bool = FF_ONLY_OPTION, # noqa: FBT001
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Reconcile the current branch with another ref, guiding rebase vs merge.
|
|
75
|
+
|
|
76
|
+
The current branch always receives. With no argument, reconciles against the
|
|
77
|
+
upstream; given a ref (e.g. main or origin/main), brings that ref's commits
|
|
78
|
+
into the current branch. On divergence you choose a rebase (linear history)
|
|
79
|
+
or a merge commit, unless a strategy flag or the integrate.strategy config
|
|
80
|
+
setting decides for you.
|
|
81
|
+
|
|
82
|
+
[bold]Examples:[/bold]
|
|
83
|
+
|
|
84
|
+
gx integrate Reconcile with the upstream
|
|
85
|
+
gx integrate main Bring main into the current branch
|
|
86
|
+
gx integrate main --merge Merge main in without prompting
|
|
87
|
+
gx int main -n Preview integrating main
|
|
88
|
+
"""
|
|
89
|
+
if verbose:
|
|
90
|
+
pp.configure(verbosity=verbose)
|
|
91
|
+
if dry_run:
|
|
92
|
+
set_dry_run(enabled=True)
|
|
93
|
+
check_git_repo()
|
|
94
|
+
|
|
95
|
+
ensure_one_strategy_flag(rebase=rebase, merge=merge, ff_only=ff_only)
|
|
96
|
+
|
|
97
|
+
branch = current_branch()
|
|
98
|
+
if branch is None:
|
|
99
|
+
pp.error("Cannot integrate in detached HEAD state.")
|
|
100
|
+
raise typer.Exit(1)
|
|
101
|
+
|
|
102
|
+
if is_dirty():
|
|
103
|
+
pp.error("Working tree has uncommitted changes. Commit or stash before integrating.")
|
|
104
|
+
raise typer.Exit(1)
|
|
105
|
+
|
|
106
|
+
target_ref, fetch_remote = _resolve_target(ref)
|
|
107
|
+
|
|
108
|
+
if fetch_remote is not None:
|
|
109
|
+
with pp.step(f"Fetch from {fetch_remote}"):
|
|
110
|
+
raise_on_error(git("fetch", fetch_remote))
|
|
111
|
+
|
|
112
|
+
if not git("rev-parse", "--verify", "--quiet", target_ref).ok:
|
|
113
|
+
pp.error(f"Cannot resolve ref '{target_ref}'.")
|
|
114
|
+
raise typer.Exit(1)
|
|
115
|
+
|
|
116
|
+
warn_if_stale_base(target_ref)
|
|
117
|
+
|
|
118
|
+
ahead, behind = ahead_behind(branch, target_ref)
|
|
119
|
+
state = classify_sync_state(ahead, behind)
|
|
120
|
+
|
|
121
|
+
if state is SyncState.UP_TO_DATE:
|
|
122
|
+
if ahead > 0:
|
|
123
|
+
pp.success(f"Already up to date with {target_ref}; {ahead} commit(s) ahead.")
|
|
124
|
+
announce_push_hint()
|
|
125
|
+
else:
|
|
126
|
+
pp.success(f"Already up to date with {target_ref}.")
|
|
127
|
+
return
|
|
128
|
+
|
|
129
|
+
if state is SyncState.FAST_FORWARD:
|
|
130
|
+
fast_forward(target_ref)
|
|
131
|
+
pp.success(f"Fast-forwarded to {target_ref}.")
|
|
132
|
+
announce_push_hint()
|
|
133
|
+
return
|
|
134
|
+
|
|
135
|
+
reconcile_divergence(
|
|
136
|
+
branch, target_ref, ahead, behind, rebase=rebase, merge=merge, ff_only=ff_only
|
|
137
|
+
)
|
|
138
|
+
pp.success(f"Integrated {target_ref} into {branch}.")
|
|
139
|
+
announce_push_hint()
|