stg-layers 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,114 @@
1
+ Metadata-Version: 2.3
2
+ Name: stg-layers
3
+ Version: 0.1.0
4
+ Summary: A Textual browser for StGit patch stacks
5
+ Requires-Dist: rich>=15.0.0
6
+ Requires-Dist: textual>=8.2.8
7
+ Requires-Dist: unidiff>=1.0.1
8
+ Requires-Python: >=3.15
9
+ Description-Content-Type: text/markdown
10
+
11
+ # StGit Layers
12
+
13
+ A Textual browser for StGit repositories. It displays the patch stack,
14
+ staged changes, and unstaged changes as expandable file/hunk trees, with a
15
+ preview for the selected node. Files and individual text hunks in the staged
16
+ and unstaged sections can be staged or unstaged from the tree.
17
+
18
+ ## Requirements
19
+
20
+ - Python 3.15 or newer
21
+ - Git
22
+ - StGit (`stg`)
23
+
24
+ ## Install and run
25
+
26
+ Install the tool from a checkout with `uv`:
27
+
28
+ ```console
29
+ uv tool install .
30
+ cd /path/to/stgit-repository
31
+ stg-layers
32
+ ```
33
+
34
+ The default tree order shows **Unstaged changes**, **Staged changes**, then
35
+ **Patch stack**, with patches newest to oldest. Press **Shift+R** to reverse the
36
+ order: patches oldest to newest, then staged and unstaged changes. The patch
37
+ stack expands to patches > files > hunks; the staged and unstaged sections
38
+ expand to files > hunks. On startup, sections and patches are expanded to show
39
+ their files, while each file's hunks are collapsed. Non-ignored untracked files
40
+ appear as additions in **Unstaged changes**.
41
+
42
+ Use **Up/Down** to move between visible nodes. **Right** expands a node or moves
43
+ to its first child; **Left** collapses a node or moves to its parent. The preview
44
+ updates as the highlighted node changes. Press **Tab** to move focus between
45
+ the tree and read-only diff preview. The preview scrolls independently with
46
+ Page Up/Page Down or the mouse wheel.
47
+ Horizontal overflow is clipped in the tree to keep its scrollbar out of view.
48
+
49
+ With the tree focused, **Enter** stages the selected file or hunk under
50
+ **Unstaged changes**, and unstages the selected file or hunk under **Staged
51
+ changes**. After Enter, selection advances to the next file or hunk in the
52
+ source group, making repeated presses useful for staging or unstaging a series
53
+ of changes. **Ctrl+Down** also stages an unstaged file or hunk; on a staged file
54
+ it moves that file's staged contents into the current patch. **Ctrl+Up**
55
+ unstages a staged file or hunk; on a current-patch file it spills that file
56
+ into **Staged changes**. With the Ctrl shortcuts, selection follows the moved
57
+ file or hunk. The preview refreshes after all these operations, and expanded
58
+ file state is retained. Hunk actions preserve other hunks in the same file.
59
+ File actions include untracked files. Enter and the staged / unstaged
60
+ shortcuts update Git's index but leave working-tree contents and the patch
61
+ stack unchanged. Patch-stack nodes are not modified by Enter. Press
62
+ **c** while the tree is focused to edit StGit's
63
+ new-patch message template; select **Create** to add an empty patch on top of
64
+ the applied stack, or **Cancel**/Escape to leave the stack unchanged. Press
65
+ **e** on a patch node to edit that patch's StGit-generated message template.
66
+ Create applies the edited message to the selected patch; cancelling leaves it
67
+ unchanged. Moving a staged file into the current patch temporarily preserves
68
+ other staged files and leaves unstaged changes in the working tree. Spilling a
69
+ current-patch file temporarily preserves other staged files; if the selected
70
+ file already has staged changes, unstage those first. Hunk-level moves between
71
+ the staged and unstaged sections are supported, but patch moves remain
72
+ file-level. Files in other patches are not moved by these shortcuts. In the
73
+ reversed tree order, the Ctrl+Up and Ctrl+Down actions swap to follow the
74
+ displayed direction: Ctrl+Up stages or moves toward the patch stack, while
75
+ Ctrl+Down spills or unstages toward Unstaged changes. Press `r` to refresh
76
+ repository state and `q` to quit.
77
+
78
+ On a patch node, **Ctrl+Up** moves it one position toward newer patches and
79
+ **Ctrl+Down** moves it one position toward older patches; these actions swap in
80
+ reversed order to continue following the displayed direction. At the top or
81
+ bottom, the action does nothing. Patches cannot be moved across the applied /
82
+ unapplied boundary. Before reordering, StGit Layers stashes staged, unstaged,
83
+ and untracked changes, then restores them with their staged state after the
84
+ operation. The stash is removed only after restoration succeeds. If reordering
85
+ or restoring the changes causes a conflict, choose **Undo** to run
86
+ `stg undo --hard`, restore the prior stack, and retry restoring the stash;
87
+ **Quit** to resolve it in the terminal (the stash is retained); or **Refresh**
88
+ after resolving it there. If a stash-restore conflict is resolved manually,
89
+ the stash is retained as a backup. When the repository already has unresolved
90
+ index conflicts, StGit Layers is locked behind a **Refresh**/**Quit** dialog
91
+ until they are resolved.
92
+
93
+ On an unapplied patch node, press **p** to run `stg push <patch>`. On an applied
94
+ or current patch node, press **Shift+P** to run `stg pop <patch>`. StGit applies
95
+ or unapplies the selected patch and may reorder patches as needed. Staged,
96
+ unstaged, and untracked changes are stashed and restored with the staged state
97
+ preserved. If pushing, popping, or restoring the changes causes a conflict,
98
+ the same Undo/Quit/Refresh recovery applies.
99
+
100
+ Diff previews are shown as plain text. Preview line numbers are omitted because
101
+ they are not source-file line numbers.
102
+ Tree labels use bold section headings and distinct colors for patch statuses,
103
+ patch names, file paths, and file statuses. Patch labels display as
104
+ `[status patch-id] title`, with the status marker and patch ID sharing the
105
+ status color: `>`, `+`, `-`, and `~`.
106
+
107
+ ## Development
108
+
109
+ ```console
110
+ uv sync --dev
111
+ uv run pytest
112
+ uv run ty check
113
+ uv run ruff check
114
+ ```
@@ -0,0 +1,104 @@
1
+ # StGit Layers
2
+
3
+ A Textual browser for StGit repositories. It displays the patch stack,
4
+ staged changes, and unstaged changes as expandable file/hunk trees, with a
5
+ preview for the selected node. Files and individual text hunks in the staged
6
+ and unstaged sections can be staged or unstaged from the tree.
7
+
8
+ ## Requirements
9
+
10
+ - Python 3.15 or newer
11
+ - Git
12
+ - StGit (`stg`)
13
+
14
+ ## Install and run
15
+
16
+ Install the tool from a checkout with `uv`:
17
+
18
+ ```console
19
+ uv tool install .
20
+ cd /path/to/stgit-repository
21
+ stg-layers
22
+ ```
23
+
24
+ The default tree order shows **Unstaged changes**, **Staged changes**, then
25
+ **Patch stack**, with patches newest to oldest. Press **Shift+R** to reverse the
26
+ order: patches oldest to newest, then staged and unstaged changes. The patch
27
+ stack expands to patches > files > hunks; the staged and unstaged sections
28
+ expand to files > hunks. On startup, sections and patches are expanded to show
29
+ their files, while each file's hunks are collapsed. Non-ignored untracked files
30
+ appear as additions in **Unstaged changes**.
31
+
32
+ Use **Up/Down** to move between visible nodes. **Right** expands a node or moves
33
+ to its first child; **Left** collapses a node or moves to its parent. The preview
34
+ updates as the highlighted node changes. Press **Tab** to move focus between
35
+ the tree and read-only diff preview. The preview scrolls independently with
36
+ Page Up/Page Down or the mouse wheel.
37
+ Horizontal overflow is clipped in the tree to keep its scrollbar out of view.
38
+
39
+ With the tree focused, **Enter** stages the selected file or hunk under
40
+ **Unstaged changes**, and unstages the selected file or hunk under **Staged
41
+ changes**. After Enter, selection advances to the next file or hunk in the
42
+ source group, making repeated presses useful for staging or unstaging a series
43
+ of changes. **Ctrl+Down** also stages an unstaged file or hunk; on a staged file
44
+ it moves that file's staged contents into the current patch. **Ctrl+Up**
45
+ unstages a staged file or hunk; on a current-patch file it spills that file
46
+ into **Staged changes**. With the Ctrl shortcuts, selection follows the moved
47
+ file or hunk. The preview refreshes after all these operations, and expanded
48
+ file state is retained. Hunk actions preserve other hunks in the same file.
49
+ File actions include untracked files. Enter and the staged / unstaged
50
+ shortcuts update Git's index but leave working-tree contents and the patch
51
+ stack unchanged. Patch-stack nodes are not modified by Enter. Press
52
+ **c** while the tree is focused to edit StGit's
53
+ new-patch message template; select **Create** to add an empty patch on top of
54
+ the applied stack, or **Cancel**/Escape to leave the stack unchanged. Press
55
+ **e** on a patch node to edit that patch's StGit-generated message template.
56
+ Create applies the edited message to the selected patch; cancelling leaves it
57
+ unchanged. Moving a staged file into the current patch temporarily preserves
58
+ other staged files and leaves unstaged changes in the working tree. Spilling a
59
+ current-patch file temporarily preserves other staged files; if the selected
60
+ file already has staged changes, unstage those first. Hunk-level moves between
61
+ the staged and unstaged sections are supported, but patch moves remain
62
+ file-level. Files in other patches are not moved by these shortcuts. In the
63
+ reversed tree order, the Ctrl+Up and Ctrl+Down actions swap to follow the
64
+ displayed direction: Ctrl+Up stages or moves toward the patch stack, while
65
+ Ctrl+Down spills or unstages toward Unstaged changes. Press `r` to refresh
66
+ repository state and `q` to quit.
67
+
68
+ On a patch node, **Ctrl+Up** moves it one position toward newer patches and
69
+ **Ctrl+Down** moves it one position toward older patches; these actions swap in
70
+ reversed order to continue following the displayed direction. At the top or
71
+ bottom, the action does nothing. Patches cannot be moved across the applied /
72
+ unapplied boundary. Before reordering, StGit Layers stashes staged, unstaged,
73
+ and untracked changes, then restores them with their staged state after the
74
+ operation. The stash is removed only after restoration succeeds. If reordering
75
+ or restoring the changes causes a conflict, choose **Undo** to run
76
+ `stg undo --hard`, restore the prior stack, and retry restoring the stash;
77
+ **Quit** to resolve it in the terminal (the stash is retained); or **Refresh**
78
+ after resolving it there. If a stash-restore conflict is resolved manually,
79
+ the stash is retained as a backup. When the repository already has unresolved
80
+ index conflicts, StGit Layers is locked behind a **Refresh**/**Quit** dialog
81
+ until they are resolved.
82
+
83
+ On an unapplied patch node, press **p** to run `stg push <patch>`. On an applied
84
+ or current patch node, press **Shift+P** to run `stg pop <patch>`. StGit applies
85
+ or unapplies the selected patch and may reorder patches as needed. Staged,
86
+ unstaged, and untracked changes are stashed and restored with the staged state
87
+ preserved. If pushing, popping, or restoring the changes causes a conflict,
88
+ the same Undo/Quit/Refresh recovery applies.
89
+
90
+ Diff previews are shown as plain text. Preview line numbers are omitted because
91
+ they are not source-file line numbers.
92
+ Tree labels use bold section headings and distinct colors for patch statuses,
93
+ patch names, file paths, and file statuses. Patch labels display as
94
+ `[status patch-id] title`, with the status marker and patch ID sharing the
95
+ status color: `>`, `+`, `-`, and `~`.
96
+
97
+ ## Development
98
+
99
+ ```console
100
+ uv sync --dev
101
+ uv run pytest
102
+ uv run ty check
103
+ uv run ruff check
104
+ ```
@@ -0,0 +1,44 @@
1
+ [project]
2
+ name = "stg-layers"
3
+ version = "0.1.0"
4
+ description = "A Textual browser for StGit patch stacks"
5
+ readme = "README.md"
6
+ requires-python = ">=3.15"
7
+ dependencies = [
8
+ "rich>=15.0.0",
9
+ "textual>=8.2.8",
10
+ "unidiff>=1.0.1",
11
+ ]
12
+
13
+ [project.scripts]
14
+ stg-layers = "stg_layers:main"
15
+
16
+ [build-system]
17
+ requires = ["uv_build>=0.13.5,<0.14.0"]
18
+ build-backend = "uv_build"
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ "pytest>=9.2.0",
23
+ "ruff>=0.17.4",
24
+ "ty>=0.0.100",
25
+ ]
26
+
27
+ [tool.pytest.ini_options]
28
+ testpaths = ["tests"]
29
+
30
+ [tool.ruff]
31
+ line-length = 100
32
+ target-version = "py315"
33
+
34
+ [tool.ruff.lint]
35
+ select = [
36
+ "B",
37
+ "C901",
38
+ "E",
39
+ "F",
40
+ "I",
41
+ ]
42
+
43
+ [tool.ruff.lint.mccabe]
44
+ max-complexity = 8
@@ -0,0 +1,38 @@
1
+ [project]
2
+ name = "stg-layers"
3
+ version = "0.1.0"
4
+ description = "A Textual browser for StGit patch stacks"
5
+ readme = "README.md"
6
+ requires-python = ">=3.15"
7
+ dependencies = [
8
+ "rich>=15.0.0",
9
+ "textual>=8.2.8",
10
+ "unidiff>=1.0.1",
11
+ ]
12
+
13
+ [project.scripts]
14
+ stg-layers = "stg_layers:main"
15
+
16
+ [build-system]
17
+ requires = ["uv_build>=0.13.5,<0.14.0"]
18
+ build-backend = "uv_build"
19
+
20
+ [dependency-groups]
21
+ dev = [
22
+ "pytest>=9.2.0",
23
+ "ruff>=0.17.4",
24
+ "ty>=0.0.100",
25
+ ]
26
+
27
+ [tool.pytest.ini_options]
28
+ testpaths = ["tests"]
29
+
30
+ [tool.ruff]
31
+ line-length = 100
32
+ target-version = "py315"
33
+
34
+ [tool.ruff.lint]
35
+ select = ["B", "C901", "E", "F", "I"]
36
+
37
+ [tool.ruff.lint.mccabe]
38
+ max-complexity = 8
@@ -0,0 +1,18 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ from stg_layers.app import StgLayersApp
5
+ from stg_layers.repository import RepositoryError, StGitRepository
6
+
7
+
8
+ def main() -> None:
9
+ try:
10
+ repository = StGitRepository.discover(Path.cwd())
11
+ except RepositoryError as error:
12
+ print(f"stg-layers: {error}", file=sys.stderr)
13
+ raise SystemExit(1) from error
14
+
15
+ StgLayersApp(repository).run()
16
+
17
+
18
+ __all__ = ["main"]