gx-git 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.
Files changed (37) hide show
  1. gx_git-0.1.0/.github/workflows/ci.yml +45 -0
  2. gx_git-0.1.0/.github/workflows/release.yml +57 -0
  3. gx_git-0.1.0/.gitignore +15 -0
  4. gx_git-0.1.0/LICENSE +21 -0
  5. gx_git-0.1.0/PKG-INFO +57 -0
  6. gx_git-0.1.0/README.md +25 -0
  7. gx_git-0.1.0/pyproject.toml +67 -0
  8. gx_git-0.1.0/src/gx/__init__.py +3 -0
  9. gx_git-0.1.0/src/gx/commands/__init__.py +0 -0
  10. gx_git-0.1.0/src/gx/commands/_switch_tui.py +161 -0
  11. gx_git-0.1.0/src/gx/commands/conflicts.py +263 -0
  12. gx_git-0.1.0/src/gx/commands/context.py +173 -0
  13. gx_git-0.1.0/src/gx/commands/drift.py +130 -0
  14. gx_git-0.1.0/src/gx/commands/nuke.py +214 -0
  15. gx_git-0.1.0/src/gx/commands/oops.py +167 -0
  16. gx_git-0.1.0/src/gx/commands/recap.py +339 -0
  17. gx_git-0.1.0/src/gx/commands/sweep.py +199 -0
  18. gx_git-0.1.0/src/gx/commands/switch.py +139 -0
  19. gx_git-0.1.0/src/gx/commands/undo.py +351 -0
  20. gx_git-0.1.0/src/gx/commands/who.py +227 -0
  21. gx_git-0.1.0/src/gx/main.py +56 -0
  22. gx_git-0.1.0/src/gx/utils/__init__.py +0 -0
  23. gx_git-0.1.0/src/gx/utils/config.py +10 -0
  24. gx_git-0.1.0/src/gx/utils/display.py +79 -0
  25. gx_git-0.1.0/src/gx/utils/git.py +186 -0
  26. gx_git-0.1.0/tests/__init__.py +0 -0
  27. gx_git-0.1.0/tests/conftest.py +68 -0
  28. gx_git-0.1.0/tests/test_conflicts.py +72 -0
  29. gx_git-0.1.0/tests/test_context.py +62 -0
  30. gx_git-0.1.0/tests/test_drift.py +58 -0
  31. gx_git-0.1.0/tests/test_nuke.py +71 -0
  32. gx_git-0.1.0/tests/test_oops.py +64 -0
  33. gx_git-0.1.0/tests/test_recap.py +47 -0
  34. gx_git-0.1.0/tests/test_sweep.py +52 -0
  35. gx_git-0.1.0/tests/test_switch.py +50 -0
  36. gx_git-0.1.0/tests/test_undo.py +77 -0
  37. gx_git-0.1.0/tests/test_who.py +45 -0
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, dev]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v5
14
+ - uses: actions/setup-python@v6
15
+ with:
16
+ python-version: "3.12"
17
+ - run: pip install ruff mypy
18
+ - run: ruff check src/
19
+ - run: mypy src/gx/ --ignore-missing-imports
20
+
21
+ test:
22
+ runs-on: ${{ matrix.os }}
23
+ strategy:
24
+ matrix:
25
+ os:
26
+ - ubuntu-latest
27
+ - ubuntu-24.04-arm
28
+ - macos-latest
29
+ - windows-latest
30
+ - windows-11-arm
31
+ python-version: ["3.9", "3.12", "3.13"]
32
+ exclude:
33
+ - os: windows-11-arm
34
+ python-version: "3.9"
35
+ - os: ubuntu-24.04-arm
36
+ python-version: "3.9"
37
+ steps:
38
+ - uses: actions/checkout@v5
39
+ - uses: actions/setup-python@v6
40
+ with:
41
+ python-version: ${{ matrix.python-version }}
42
+ - run: pip install -e ".[dev]"
43
+ - run: gx --version
44
+ - run: gx --help
45
+ - run: python -m pytest tests/ -v
@@ -0,0 +1,57 @@
1
+ name: Release & Publish
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+
7
+ permissions:
8
+ contents: write
9
+ id-token: write
10
+
11
+ jobs:
12
+ release:
13
+ runs-on: ubuntu-latest
14
+ environment: pypi
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ with:
18
+ fetch-depth: 0
19
+ fetch-tags: true
20
+
21
+ - name: Get version from pyproject.toml
22
+ id: version
23
+ run: |
24
+ VERSION=$(grep '^version' pyproject.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')
25
+ echo "version=$VERSION" >> "$GITHUB_OUTPUT"
26
+ echo "tag=v$VERSION" >> "$GITHUB_OUTPUT"
27
+
28
+ - name: Check if tag exists
29
+ id: check
30
+ run: |
31
+ if git rev-parse "v${{ steps.version.outputs.version }}" >/dev/null 2>&1; then
32
+ echo "exists=true" >> "$GITHUB_OUTPUT"
33
+ else
34
+ echo "exists=false" >> "$GITHUB_OUTPUT"
35
+ fi
36
+
37
+ - name: Create release
38
+ if: steps.check.outputs.exists == 'false'
39
+ run: |
40
+ gh release create "${{ steps.version.outputs.tag }}" \
41
+ --title "${{ steps.version.outputs.tag }}" \
42
+ --generate-notes
43
+ env:
44
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45
+
46
+ # Build and publish always run — skip-existing makes re-runs safe
47
+ - uses: actions/setup-python@v6
48
+ with:
49
+ python-version: "3.12"
50
+
51
+ - name: Build package
52
+ run: pip install build && python -m build
53
+
54
+ - name: Publish to PyPI
55
+ uses: pypa/gh-action-pypi-publish@release/v1
56
+ with:
57
+ skip-existing: true
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ *.egg
9
+ .pytest_cache/
10
+ .mypy_cache/
11
+ .ruff_cache/
12
+ *.so
13
+ .venv/
14
+ venv/
15
+ env/
gx_git-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 gx contributors
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.
gx_git-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,57 @@
1
+ Metadata-Version: 2.4
2
+ Name: gx-git
3
+ Version: 0.1.0
4
+ Summary: Git Productivity Toolkit — 10 focused commands for daily git friction
5
+ Project-URL: Homepage, https://github.com/mubbie/gx-cli
6
+ Project-URL: Repository, https://github.com/mubbie/gx-cli
7
+ Project-URL: Issues, https://github.com/mubbie/gx-cli/issues
8
+ Author: Mubbie Idoko
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: cli,developer-tools,git,productivity
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Version Control :: Git
23
+ Classifier: Topic :: Utilities
24
+ Requires-Python: >=3.9
25
+ Requires-Dist: rich>=13.0
26
+ Requires-Dist: textual>=0.40
27
+ Requires-Dist: typer>=0.9
28
+ Provides-Extra: dev
29
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
30
+ Requires-Dist: pytest>=7.0; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # gx — Git Productivity Toolkit
34
+
35
+ A terminal-based Git utility that bundles 10 focused productivity commands into a single CLI.
36
+
37
+ ## Install
38
+
39
+ ```
40
+ pipx install gx-git
41
+ ```
42
+
43
+ ## Commands
44
+
45
+ | Command | Description |
46
+ |---------|-------------|
47
+ | `gx undo` | Smart undo — figures out what to undo |
48
+ | `gx redo` | Redo the last undo |
49
+ | `gx who` | Who knows this code best |
50
+ | `gx nuke` | Delete branches with confidence |
51
+ | `gx recap` | What did I (or my team) do recently |
52
+ | `gx sweep` | Clean up merged branches and stale refs |
53
+ | `gx oops` | Quick-fix the last commit |
54
+ | `gx context` | Repo status at a glance (alias: `gx ctx`) |
55
+ | `gx drift` | How far you've diverged from the HEAD branch |
56
+ | `gx switch` | Fuzzy branch switcher |
57
+ | `gx conflicts` | Preview merge conflicts before merging |
gx_git-0.1.0/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # gx — Git Productivity Toolkit
2
+
3
+ A terminal-based Git utility that bundles 10 focused productivity commands into a single CLI.
4
+
5
+ ## Install
6
+
7
+ ```
8
+ pipx install gx-git
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ | Command | Description |
14
+ |---------|-------------|
15
+ | `gx undo` | Smart undo — figures out what to undo |
16
+ | `gx redo` | Redo the last undo |
17
+ | `gx who` | Who knows this code best |
18
+ | `gx nuke` | Delete branches with confidence |
19
+ | `gx recap` | What did I (or my team) do recently |
20
+ | `gx sweep` | Clean up merged branches and stale refs |
21
+ | `gx oops` | Quick-fix the last commit |
22
+ | `gx context` | Repo status at a glance (alias: `gx ctx`) |
23
+ | `gx drift` | How far you've diverged from the HEAD branch |
24
+ | `gx switch` | Fuzzy branch switcher |
25
+ | `gx conflicts` | Preview merge conflicts before merging |
@@ -0,0 +1,67 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "gx-git"
7
+ version = "0.1.0"
8
+ description = "Git Productivity Toolkit — 10 focused commands for daily git friction"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ {name = "Mubbie Idoko"},
14
+ ]
15
+ keywords = ["git", "cli", "productivity", "developer-tools"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Environment :: Console",
19
+ "Intended Audience :: Developers",
20
+ "License :: OSI Approved :: MIT License",
21
+ "Programming Language :: Python :: 3",
22
+ "Programming Language :: Python :: 3.9",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ "Programming Language :: Python :: 3.13",
27
+ "Topic :: Software Development :: Version Control :: Git",
28
+ "Topic :: Utilities",
29
+ ]
30
+ dependencies = [
31
+ "typer>=0.9",
32
+ "rich>=13.0",
33
+ "textual>=0.40",
34
+ ]
35
+
36
+ [project.scripts]
37
+ gx = "gx.main:app"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/mubbie/gx-cli"
41
+ Repository = "https://github.com/mubbie/gx-cli"
42
+ Issues = "https://github.com/mubbie/gx-cli/issues"
43
+
44
+ [tool.hatch.build.targets.wheel]
45
+ packages = ["src/gx"]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ pythonpath = ["src"]
50
+
51
+ [project.optional-dependencies]
52
+ dev = [
53
+ "pytest>=7.0",
54
+ "pytest-cov>=4.0",
55
+ ]
56
+
57
+ [tool.ruff]
58
+ target-version = "py39"
59
+ line-length = 120
60
+
61
+ [tool.ruff.lint]
62
+ select = ["E", "F", "I", "W"]
63
+
64
+ [tool.mypy]
65
+ python_version = "3.9"
66
+ warn_return_any = true
67
+ warn_unused_configs = true
@@ -0,0 +1,3 @@
1
+ """gx — Git Productivity Toolkit."""
2
+
3
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,161 @@
1
+ """Textual TUI for gx switch — fuzzy branch picker."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from textual import work
6
+ from textual.app import App, ComposeResult
7
+ from textual.containers import Vertical
8
+ from textual.widgets import Footer, Header, Input, Static
9
+ from textual.reactive import reactive
10
+
11
+ from gx.utils.git import run_git, GitError, time_ago
12
+
13
+
14
+ class BranchItem(Static):
15
+ """A single branch row."""
16
+
17
+ def __init__(self, branch: dict, **kwargs) -> None:
18
+ self.branch = branch
19
+ age = time_ago(branch["date"])
20
+ ahead_behind = branch.get("ahead_behind", "")
21
+ text = f" {branch['name']:<35} {ahead_behind:<20} {age:<15} {branch['author']}"
22
+ super().__init__(text, **kwargs)
23
+ self.add_class("branch-item")
24
+
25
+ def on_click(self) -> None:
26
+ self.app.selected = self.branch["name"]
27
+ self.app.exit(self.branch["name"])
28
+
29
+
30
+ class SwitchApp(App):
31
+ """Fuzzy branch picker TUI."""
32
+
33
+ CSS = """
34
+ Screen {
35
+ background: $surface;
36
+ }
37
+ #branch-list {
38
+ height: 1fr;
39
+ overflow-y: auto;
40
+ }
41
+ .branch-item {
42
+ height: 1;
43
+ padding: 0 1;
44
+ }
45
+ .branch-item:hover {
46
+ background: $accent;
47
+ }
48
+ .branch-item.highlighted {
49
+ background: $accent;
50
+ color: $text;
51
+ }
52
+ #search {
53
+ dock: bottom;
54
+ margin: 0 1;
55
+ }
56
+ #hint {
57
+ dock: bottom;
58
+ height: 1;
59
+ color: $text-muted;
60
+ text-align: center;
61
+ }
62
+ """
63
+
64
+ BINDINGS = [
65
+ ("escape", "quit", "Cancel"),
66
+ ("up", "move_up", "Up"),
67
+ ("down", "move_down", "Down"),
68
+ ("enter", "select", "Select"),
69
+ ]
70
+
71
+ selected: str | None = None
72
+ highlight_index: reactive[int] = reactive(0)
73
+
74
+ def __init__(self, branches: list[dict], head_branch: str) -> None:
75
+ super().__init__()
76
+ self.all_branches = branches
77
+ self.filtered_branches = list(branches)
78
+ self.head_branch = head_branch
79
+
80
+ def compose(self) -> ComposeResult:
81
+ yield Header(show_clock=False)
82
+ yield Vertical(id="branch-list")
83
+ yield Input(placeholder="Type to filter branches...", id="search")
84
+ yield Static("\u2191\u2193 Navigate Enter Select Esc Cancel", id="hint")
85
+
86
+ def on_mount(self) -> None:
87
+ self._render_branches()
88
+ self._load_ahead_behind()
89
+ self.query_one("#search", Input).focus()
90
+
91
+ def _render_branches(self) -> None:
92
+ container = self.query_one("#branch-list", Vertical)
93
+ container.remove_children()
94
+ for i, branch in enumerate(self.filtered_branches):
95
+ item = BranchItem(branch, id=f"branch-{i}")
96
+ if i == self.highlight_index:
97
+ item.add_class("highlighted")
98
+ container.mount(item)
99
+
100
+ def on_input_changed(self, event: Input.Changed) -> None:
101
+ query = event.value.lower()
102
+ if query:
103
+ self.filtered_branches = [
104
+ b for b in self.all_branches
105
+ if query in b["name"].lower()
106
+ ]
107
+ else:
108
+ self.filtered_branches = list(self.all_branches)
109
+ self.highlight_index = 0
110
+ self._render_branches()
111
+
112
+ def watch_highlight_index(self, old: int, new: int) -> None:
113
+ # Update highlighting
114
+ container = self.query_one("#branch-list", Vertical)
115
+ children = list(container.children)
116
+ if 0 <= old < len(children):
117
+ children[old].remove_class("highlighted")
118
+ if 0 <= new < len(children):
119
+ children[new].add_class("highlighted")
120
+ children[new].scroll_visible()
121
+
122
+ def action_move_up(self) -> None:
123
+ if self.highlight_index > 0:
124
+ self.highlight_index -= 1
125
+
126
+ def action_move_down(self) -> None:
127
+ if self.highlight_index < len(self.filtered_branches) - 1:
128
+ self.highlight_index += 1
129
+
130
+ def action_select(self) -> None:
131
+ if self.filtered_branches:
132
+ idx = min(self.highlight_index, len(self.filtered_branches) - 1)
133
+ self.selected = self.filtered_branches[idx]["name"]
134
+ self.exit(self.selected)
135
+
136
+ def action_quit(self) -> None:
137
+ self.selected = None
138
+ self.exit(None)
139
+
140
+ @work(thread=True)
141
+ def _load_ahead_behind(self) -> None:
142
+ """Load ahead/behind counts in background."""
143
+ for branch in self.all_branches:
144
+ try:
145
+ ab = run_git([
146
+ "rev-list", "--left-right", "--count",
147
+ f"{branch['name']}...{self.head_branch}"
148
+ ])
149
+ ahead, behind = ab.split()
150
+ branch["ahead_behind"] = f"{ahead} ahead, {behind} behind"
151
+ except (GitError, ValueError):
152
+ branch["ahead_behind"] = ""
153
+
154
+ self.call_from_thread(self._render_branches)
155
+
156
+
157
+ def run_switch_tui(branches: list[dict], head_branch: str) -> str | None:
158
+ """Run the Textual TUI and return the selected branch name."""
159
+ app = SwitchApp(branches, head_branch)
160
+ result = app.run()
161
+ return result