git-visual-timeline 0.2.1__tar.gz → 0.2.2__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_visual_timeline-0.2.1/src/git_visual_timeline.egg-info → git_visual_timeline-0.2.2}/PKG-INFO +49 -17
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/README.md +48 -16
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/pyproject.toml +1 -1
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2/src/git_visual_timeline.egg-info}/PKG-INFO +49 -17
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/SOURCES.txt +4 -0
- git_visual_timeline-0.2.2/src/gvt/__init__.py +1 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/app.py +22 -10
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/cli.py +31 -19
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/git/repo.py +54 -32
- git_visual_timeline-0.2.2/src/gvt/logging_setup.py +40 -0
- git_visual_timeline-0.2.2/tests/test_app_actions.py +125 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_app_integration.py +30 -0
- git_visual_timeline-0.2.2/tests/test_logging_setup.py +99 -0
- git_visual_timeline-0.2.2/tests/test_repo_resilience.py +60 -0
- git_visual_timeline-0.2.1/src/gvt/__init__.py +0 -1
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/LICENSE +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/setup.cfg +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/dependency_links.txt +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/entry_points.txt +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/requires.txt +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/top_level.txt +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/git/__init__.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/git/cache.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/styles/app.tcss +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/__init__.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/changed_files.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/commit_bar.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/commit_toast.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/diff_view.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/file_tree.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/modals.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/status_bar.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/gvt/widgets/timeline.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_cache.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_changed_files.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_diff_view_logic.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_git_repo.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_git_repo_extended.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_timeline_logic.py +0 -0
- {git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/tests/test_widgets.py +0 -0
{git_visual_timeline-0.2.1/src/git_visual_timeline.egg-info → git_visual_timeline-0.2.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-visual-timeline
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Git Visual Timeline — a keyboard-driven TUI for exploring file commit history
|
|
5
5
|
Author-email: Adam Reese <areese801@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -39,6 +39,10 @@ Dynamic: license-file
|
|
|
39
39
|
|
|
40
40
|
A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
|
|
41
41
|
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
**gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
|
|
45
|
+
|
|
42
46
|
## Install
|
|
43
47
|
|
|
44
48
|
```bash
|
|
@@ -55,30 +59,58 @@ gvt
|
|
|
55
59
|
gvt path/to/file.py
|
|
56
60
|
```
|
|
57
61
|
|
|
62
|
+
## Layout
|
|
63
|
+
|
|
64
|
+
gvt uses a 5-pane layout, each accessible by number key:
|
|
65
|
+
|
|
66
|
+
| Pane | Name | What it shows |
|
|
67
|
+
|------|------|---------------|
|
|
68
|
+
| 1 | Files | File tree with lazy-loading directories |
|
|
69
|
+
| 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
|
|
70
|
+
| 3 | Commits | Message, hash, date, and stats for visible commits |
|
|
71
|
+
| 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
|
|
72
|
+
| 5 | Changed Files | All files touched by the current commit |
|
|
73
|
+
|
|
58
74
|
## Features
|
|
59
75
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
### Timeline Navigation
|
|
77
|
+
|
|
78
|
+
Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
### Pin Mode
|
|
83
|
+
|
|
84
|
+
Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
|
|
85
|
+
|
|
86
|
+

|
|
87
|
+
|
|
88
|
+
### Inline Blame
|
|
89
|
+
|
|
90
|
+
Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
### File Search
|
|
95
|
+
|
|
96
|
+
Press `f` for an fzf-style fuzzy file picker that filters as you type.
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
|
100
|
+
### All Features
|
|
101
|
+
|
|
102
|
+
- **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
|
|
64
103
|
- **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
|
|
65
|
-
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch
|
|
66
|
-
- **File search** (`f`) — fzf-style file picker
|
|
104
|
+
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
|
|
67
105
|
- **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
|
|
68
|
-
- **
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **Changed files pane** — see all files touched by the current commit, select to navigate
|
|
72
|
-
- **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
|
|
73
|
-
- **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
|
|
106
|
+
- **Contributor breakdown** (`B`) — who changed the file and how much
|
|
107
|
+
- **WIP indicator** — hollow tick showing uncommitted changes
|
|
108
|
+
- **Copy to clipboard** (`y`/`Y`) — short or full commit hash
|
|
74
109
|
- **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
|
|
75
110
|
- **Remember last file** — reopens to the last file you were viewing per repo
|
|
76
|
-
- **
|
|
77
|
-
- **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
|
|
78
|
-
- **Lazy file tree** — loads directories on demand for large repos
|
|
111
|
+
- **tmux integration** — seamless pane switching at edges
|
|
79
112
|
- **Preloaded diffs** — adjacent commits pre-cached for instant navigation
|
|
80
113
|
- **Context-sensitive status bar** showing relevant shortcuts per pane
|
|
81
|
-
- **Untracked files** — shown in a separate section, viewable as read-only preview
|
|
82
114
|
|
|
83
115
|
## Keybindings
|
|
84
116
|
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
|
|
4
4
|
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
|
|
8
|
+
|
|
5
9
|
## Install
|
|
6
10
|
|
|
7
11
|
```bash
|
|
@@ -18,30 +22,58 @@ gvt
|
|
|
18
22
|
gvt path/to/file.py
|
|
19
23
|
```
|
|
20
24
|
|
|
25
|
+
## Layout
|
|
26
|
+
|
|
27
|
+
gvt uses a 5-pane layout, each accessible by number key:
|
|
28
|
+
|
|
29
|
+
| Pane | Name | What it shows |
|
|
30
|
+
|------|------|---------------|
|
|
31
|
+
| 1 | Files | File tree with lazy-loading directories |
|
|
32
|
+
| 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
|
|
33
|
+
| 3 | Commits | Message, hash, date, and stats for visible commits |
|
|
34
|
+
| 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
|
|
35
|
+
| 5 | Changed Files | All files touched by the current commit |
|
|
36
|
+
|
|
21
37
|
## Features
|
|
22
38
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
39
|
+
### Timeline Navigation
|
|
40
|
+
|
|
41
|
+
Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+
### Pin Mode
|
|
46
|
+
|
|
47
|
+
Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
|
|
48
|
+
|
|
49
|
+

|
|
50
|
+
|
|
51
|
+
### Inline Blame
|
|
52
|
+
|
|
53
|
+
Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
|
|
54
|
+
|
|
55
|
+

|
|
56
|
+
|
|
57
|
+
### File Search
|
|
58
|
+
|
|
59
|
+
Press `f` for an fzf-style fuzzy file picker that filters as you type.
|
|
60
|
+
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
### All Features
|
|
64
|
+
|
|
65
|
+
- **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
|
|
27
66
|
- **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
|
|
28
|
-
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch
|
|
29
|
-
- **File search** (`f`) — fzf-style file picker
|
|
67
|
+
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
|
|
30
68
|
- **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
|
|
31
|
-
- **
|
|
32
|
-
- **
|
|
33
|
-
- **
|
|
34
|
-
- **Changed files pane** — see all files touched by the current commit, select to navigate
|
|
35
|
-
- **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
|
|
36
|
-
- **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
|
|
69
|
+
- **Contributor breakdown** (`B`) — who changed the file and how much
|
|
70
|
+
- **WIP indicator** — hollow tick showing uncommitted changes
|
|
71
|
+
- **Copy to clipboard** (`y`/`Y`) — short or full commit hash
|
|
37
72
|
- **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
|
|
38
73
|
- **Remember last file** — reopens to the last file you were viewing per repo
|
|
39
|
-
- **
|
|
40
|
-
- **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
|
|
41
|
-
- **Lazy file tree** — loads directories on demand for large repos
|
|
74
|
+
- **tmux integration** — seamless pane switching at edges
|
|
42
75
|
- **Preloaded diffs** — adjacent commits pre-cached for instant navigation
|
|
43
76
|
- **Context-sensitive status bar** showing relevant shortcuts per pane
|
|
44
|
-
- **Untracked files** — shown in a separate section, viewable as read-only preview
|
|
45
77
|
|
|
46
78
|
## Keybindings
|
|
47
79
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "git-visual-timeline"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Git Visual Timeline — a keyboard-driven TUI for exploring file commit history"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
{git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2/src/git_visual_timeline.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-visual-timeline
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Git Visual Timeline — a keyboard-driven TUI for exploring file commit history
|
|
5
5
|
Author-email: Adam Reese <areese801@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -39,6 +39,10 @@ Dynamic: license-file
|
|
|
39
39
|
|
|
40
40
|
A keyboard-driven TUI for exploring the commit history of any file in a git repo. Think lazygit meets a video timeline scrubber, focused on per-file history.
|
|
41
41
|
|
|
42
|
+

|
|
43
|
+
|
|
44
|
+
**gvt is a read-only history explorer, not a git UI.** It doesn't stage, commit, push, or manage branches — lazygit is great for that. gvt does one thing: lets you scrub through a file's commit timeline, see what changed and when, and understand how code evolved over time. It's the tool you reach for when you're staring at a file and asking "how did this get here?"
|
|
45
|
+
|
|
42
46
|
## Install
|
|
43
47
|
|
|
44
48
|
```bash
|
|
@@ -55,30 +59,58 @@ gvt
|
|
|
55
59
|
gvt path/to/file.py
|
|
56
60
|
```
|
|
57
61
|
|
|
62
|
+
## Layout
|
|
63
|
+
|
|
64
|
+
gvt uses a 5-pane layout, each accessible by number key:
|
|
65
|
+
|
|
66
|
+
| Pane | Name | What it shows |
|
|
67
|
+
|------|------|---------------|
|
|
68
|
+
| 1 | Files | File tree with lazy-loading directories |
|
|
69
|
+
| 2 | Timeline | Heatmap of commits (green=adds, red=deletes, amber=mixed) |
|
|
70
|
+
| 3 | Commits | Message, hash, date, and stats for visible commits |
|
|
71
|
+
| 4 | Diff | Syntax-highlighted diff with blame, search, and context controls |
|
|
72
|
+
| 5 | Changed Files | All files touched by the current commit |
|
|
73
|
+
|
|
58
74
|
## Features
|
|
59
75
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
76
|
+
### Timeline Navigation
|
|
77
|
+
|
|
78
|
+
Scrub through a file's commit history one tick at a time. Each tick is colored by change type — green for additions, red for deletions, amber for mixed.
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
### Pin Mode
|
|
83
|
+
|
|
84
|
+
Press `x` to pin a commit, then move to another and press `x` again to diff any two commits. Press `x` a third time to clear. Use `X` to snap the nearest pin to your cursor.
|
|
85
|
+
|
|
86
|
+

|
|
87
|
+
|
|
88
|
+
### Inline Blame
|
|
89
|
+
|
|
90
|
+
Toggle blame annotations with `b` to see who last modified each line, right-aligned alongside the diff.
|
|
91
|
+
|
|
92
|
+

|
|
93
|
+
|
|
94
|
+
### File Search
|
|
95
|
+
|
|
96
|
+
Press `f` for an fzf-style fuzzy file picker that filters as you type.
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
|
100
|
+
### All Features
|
|
101
|
+
|
|
102
|
+
- **Syntax-highlighted diffs** with inline, whole-file (`w`), and side-by-side (`d`) views
|
|
64
103
|
- **Diff search** (`/`) — regex search within the diff with `n`/`p` to navigate matches
|
|
65
|
-
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch
|
|
66
|
-
- **File search** (`f`) — fzf-style file picker
|
|
104
|
+
- **Commit search** (`c`) — fuzzy search all repo commits by message, branch, or author
|
|
67
105
|
- **Time filter** (`t`) — filter timeline by date range (1w, 1m, 3m, 6m, 1y, custom date)
|
|
68
|
-
- **
|
|
69
|
-
- **
|
|
70
|
-
- **
|
|
71
|
-
- **Changed files pane** — see all files touched by the current commit, select to navigate
|
|
72
|
-
- **Side-by-side diff** (`d`) — toggle between inline and side-by-side diff views
|
|
73
|
-
- **Copy to clipboard** (`y`/`Y`) — copy short or full commit hash
|
|
106
|
+
- **Contributor breakdown** (`B`) — who changed the file and how much
|
|
107
|
+
- **WIP indicator** — hollow tick showing uncommitted changes
|
|
108
|
+
- **Copy to clipboard** (`y`/`Y`) — short or full commit hash
|
|
74
109
|
- **Open in editor** (`e`) — open current file in `$VISUAL`/`$EDITOR`/vim
|
|
75
110
|
- **Remember last file** — reopens to the last file you were viewing per repo
|
|
76
|
-
- **
|
|
77
|
-
- **tmux integration** — seamless pane switching at edges (add `gvt` to your `is_vim` regex)
|
|
78
|
-
- **Lazy file tree** — loads directories on demand for large repos
|
|
111
|
+
- **tmux integration** — seamless pane switching at edges
|
|
79
112
|
- **Preloaded diffs** — adjacent commits pre-cached for instant navigation
|
|
80
113
|
- **Context-sensitive status bar** showing relevant shortcuts per pane
|
|
81
|
-
- **Untracked files** — shown in a separate section, viewable as read-only preview
|
|
82
114
|
|
|
83
115
|
## Keybindings
|
|
84
116
|
|
{git_visual_timeline-0.2.1 → git_visual_timeline-0.2.2}/src/git_visual_timeline.egg-info/SOURCES.txt
RENAMED
|
@@ -10,6 +10,7 @@ src/git_visual_timeline.egg-info/top_level.txt
|
|
|
10
10
|
src/gvt/__init__.py
|
|
11
11
|
src/gvt/app.py
|
|
12
12
|
src/gvt/cli.py
|
|
13
|
+
src/gvt/logging_setup.py
|
|
13
14
|
src/gvt/git/__init__.py
|
|
14
15
|
src/gvt/git/cache.py
|
|
15
16
|
src/gvt/git/repo.py
|
|
@@ -23,11 +24,14 @@ src/gvt/widgets/file_tree.py
|
|
|
23
24
|
src/gvt/widgets/modals.py
|
|
24
25
|
src/gvt/widgets/status_bar.py
|
|
25
26
|
src/gvt/widgets/timeline.py
|
|
27
|
+
tests/test_app_actions.py
|
|
26
28
|
tests/test_app_integration.py
|
|
27
29
|
tests/test_cache.py
|
|
28
30
|
tests/test_changed_files.py
|
|
29
31
|
tests/test_diff_view_logic.py
|
|
30
32
|
tests/test_git_repo.py
|
|
31
33
|
tests/test_git_repo_extended.py
|
|
34
|
+
tests/test_logging_setup.py
|
|
35
|
+
tests/test_repo_resilience.py
|
|
32
36
|
tests/test_timeline_logic.py
|
|
33
37
|
tests/test_widgets.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.2"
|
|
@@ -9,15 +9,20 @@ import subprocess
|
|
|
9
9
|
from datetime import datetime, timezone
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
|
|
12
|
+
from git.exc import GitCommandError
|
|
12
13
|
from rich.text import Text
|
|
13
14
|
from textual import on, work
|
|
14
15
|
from textual.app import App, ComposeResult
|
|
15
16
|
from textual.binding import Binding
|
|
16
17
|
from textual.containers import Container, Horizontal, Vertical
|
|
18
|
+
from textual.css.query import NoMatches
|
|
17
19
|
from textual.widget import Widget
|
|
18
20
|
|
|
19
21
|
from gvt.git.cache import DiffCache
|
|
20
22
|
from gvt.git.repo import CommitInfo, GitRepo
|
|
23
|
+
from gvt.logging_setup import get_logger
|
|
24
|
+
|
|
25
|
+
log = get_logger(__name__)
|
|
21
26
|
from gvt.widgets.changed_files import ChangedFilesWidget, ChangedFileSelected, ChangedFileHighlighted
|
|
22
27
|
from gvt.widgets.commit_bar import CommitMessageBar, ShowCommitDetail
|
|
23
28
|
from gvt.widgets.diff_view import DiffContextChanged, DiffViewWidget
|
|
@@ -259,8 +264,8 @@ class GVTApp(App):
|
|
|
259
264
|
is_wip=True,
|
|
260
265
|
)
|
|
261
266
|
commits.append(wip_commit)
|
|
262
|
-
except
|
|
263
|
-
|
|
267
|
+
except GitCommandError as e:
|
|
268
|
+
log.warning("WIP probe for %s failed: %s", file_path, e)
|
|
264
269
|
|
|
265
270
|
self.call_from_thread(self._apply_loaded_file, file_path, commits)
|
|
266
271
|
|
|
@@ -489,8 +494,8 @@ class GVTApp(App):
|
|
|
489
494
|
try:
|
|
490
495
|
widget = self.query_one(f"#{widget_id}")
|
|
491
496
|
widget.focus()
|
|
492
|
-
except
|
|
493
|
-
|
|
497
|
+
except NoMatches:
|
|
498
|
+
log.debug("focus_pane: widget #%s not present", widget_id)
|
|
494
499
|
|
|
495
500
|
def action_focus_next_pane(self) -> None:
|
|
496
501
|
self._current_pane_idx = (self._current_pane_idx + 1) % len(self._pane_order)
|
|
@@ -732,7 +737,8 @@ class GVTApp(App):
|
|
|
732
737
|
self.notify("No clipboard tool found", timeout=2)
|
|
733
738
|
return
|
|
734
739
|
self.notify(f"Copied {text}", timeout=2)
|
|
735
|
-
except
|
|
740
|
+
except (subprocess.CalledProcessError, OSError) as e:
|
|
741
|
+
log.warning("clipboard copy failed: %s", e)
|
|
736
742
|
self.notify("Failed to copy to clipboard", timeout=2)
|
|
737
743
|
|
|
738
744
|
def action_open_in_editor(self) -> None:
|
|
@@ -740,11 +746,17 @@ class GVTApp(App):
|
|
|
740
746
|
return
|
|
741
747
|
editor = os.environ.get("VISUAL") or os.environ.get("EDITOR") or "vim"
|
|
742
748
|
file_path = os.path.join(self.repo_path, self.current_file)
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
749
|
+
result = None
|
|
750
|
+
with self.suspend():
|
|
751
|
+
try:
|
|
752
|
+
result = subprocess.run([editor, file_path])
|
|
753
|
+
except (OSError, FileNotFoundError) as e:
|
|
754
|
+
log.warning("editor %s failed to launch: %s", editor, e)
|
|
755
|
+
if result is None:
|
|
756
|
+
self.notify(f"Could not launch editor: {editor}", timeout=3)
|
|
757
|
+
elif result.returncode != 0:
|
|
758
|
+
log.warning("editor %s exited with code %d", editor, result.returncode)
|
|
759
|
+
self.notify(f"Editor exited with code {result.returncode}", timeout=2)
|
|
748
760
|
|
|
749
761
|
@work(thread=True)
|
|
750
762
|
def _load_blame(self, file_path: str, commit_sha: str) -> None:
|
|
@@ -26,31 +26,41 @@ def main():
|
|
|
26
26
|
|
|
27
27
|
args = parser.parse_args()
|
|
28
28
|
|
|
29
|
-
# Validate we're in a git repo
|
|
30
29
|
from git import InvalidGitRepositoryError, Repo
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
initial_file = None
|
|
32
|
+
abs_target = os.path.abspath(args.file) if args.file else None
|
|
33
|
+
|
|
34
|
+
if abs_target:
|
|
35
|
+
# Determine which repo the target lives in.
|
|
36
|
+
# If the target is a directory, treat it as a repo root (or search up);
|
|
37
|
+
# if it's a file, search from its parent directory.
|
|
38
|
+
search_dir = abs_target if os.path.isdir(abs_target) else os.path.dirname(abs_target)
|
|
39
|
+
try:
|
|
40
|
+
repo = Repo(search_dir, search_parent_directories=True)
|
|
41
|
+
except InvalidGitRepositoryError:
|
|
42
|
+
print(f"Error: {args.file} is not inside a git repository", file=sys.stderr)
|
|
43
|
+
sys.exit(1)
|
|
37
44
|
|
|
38
|
-
# Validate file argument if provided
|
|
39
|
-
if args.file:
|
|
40
45
|
repo_root = repo.working_tree_dir
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
if os.path.isdir(abs_target):
|
|
47
|
+
# Target is a directory (repo root) — open without initial file
|
|
48
|
+
initial_file = None
|
|
49
|
+
else:
|
|
50
|
+
if not os.path.exists(abs_target):
|
|
51
|
+
print(f"Error: file not found: {args.file}", file=sys.stderr)
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
initial_file = os.path.relpath(abs_target, repo_root)
|
|
54
|
+
else:
|
|
55
|
+
# No argument — use cwd's repo
|
|
56
|
+
try:
|
|
57
|
+
repo = Repo(os.getcwd(), search_parent_directories=True)
|
|
58
|
+
except InvalidGitRepositoryError:
|
|
59
|
+
print("Error: not a git repository (or any parent)", file=sys.stderr)
|
|
45
60
|
sys.exit(1)
|
|
46
61
|
|
|
47
62
|
from gvt.app import GVTApp
|
|
48
63
|
|
|
49
|
-
initial_file = None
|
|
50
|
-
if args.file:
|
|
51
|
-
repo_root = repo.working_tree_dir
|
|
52
|
-
initial_file = os.path.relpath(os.path.abspath(args.file), repo_root)
|
|
53
|
-
|
|
54
64
|
import signal
|
|
55
65
|
import subprocess
|
|
56
66
|
|
|
@@ -65,8 +75,10 @@ def main():
|
|
|
65
75
|
sys.stdout.write("\033[0m") # reset colors
|
|
66
76
|
sys.stdout.write("\033c") # full terminal reset
|
|
67
77
|
sys.stdout.flush()
|
|
68
|
-
except Exception:
|
|
69
|
-
|
|
78
|
+
except Exception as e:
|
|
79
|
+
# Signal handler — must never raise. Log best-effort then exit.
|
|
80
|
+
from gvt.logging_setup import get_logger
|
|
81
|
+
get_logger(__name__).warning("terminal cleanup failed: %s", e)
|
|
70
82
|
os._exit(128 + signum)
|
|
71
83
|
|
|
72
84
|
signal.signal(signal.SIGTERM, _cleanup_terminal)
|
|
@@ -7,6 +7,11 @@ from dataclasses import dataclass
|
|
|
7
7
|
from datetime import datetime, timezone
|
|
8
8
|
|
|
9
9
|
from git import Repo
|
|
10
|
+
from git.exc import GitCommandError
|
|
11
|
+
|
|
12
|
+
from gvt.logging_setup import get_logger
|
|
13
|
+
|
|
14
|
+
log = get_logger(__name__)
|
|
10
15
|
|
|
11
16
|
|
|
12
17
|
@dataclass
|
|
@@ -54,6 +59,22 @@ class GitRepo:
|
|
|
54
59
|
self.repo = Repo(path, search_parent_directories=True)
|
|
55
60
|
self.root = self.repo.working_tree_dir
|
|
56
61
|
|
|
62
|
+
def _build_ref_map(self) -> dict[str, list[str]]:
|
|
63
|
+
"""Build a sha -> [ref names] map, tolerating individual bad refs."""
|
|
64
|
+
ref_map: dict[str, list[str]] = {}
|
|
65
|
+
try:
|
|
66
|
+
refs = list(self.repo.refs)
|
|
67
|
+
except (GitCommandError, AttributeError, ValueError) as e:
|
|
68
|
+
log.warning("failed to list refs: %s", e)
|
|
69
|
+
return ref_map
|
|
70
|
+
for ref in refs:
|
|
71
|
+
try:
|
|
72
|
+
sha = ref.commit.hexsha
|
|
73
|
+
ref_map.setdefault(sha, []).append(ref.name)
|
|
74
|
+
except (GitCommandError, AttributeError, ValueError) as e:
|
|
75
|
+
log.debug("skipping ref %s: %s", getattr(ref, "name", "?"), e)
|
|
76
|
+
return ref_map
|
|
77
|
+
|
|
57
78
|
def get_file_commits(self, path: str) -> list[CommitInfo]:
|
|
58
79
|
"""
|
|
59
80
|
Get all commits that touched a file, ordered oldest-first.
|
|
@@ -62,16 +83,7 @@ class GitRepo:
|
|
|
62
83
|
rel_path = self._to_relative(path)
|
|
63
84
|
|
|
64
85
|
# Build ref map
|
|
65
|
-
ref_map
|
|
66
|
-
try:
|
|
67
|
-
for ref in self.repo.refs:
|
|
68
|
-
try:
|
|
69
|
-
sha = ref.commit.hexsha
|
|
70
|
-
ref_map.setdefault(sha, []).append(ref.name)
|
|
71
|
-
except Exception:
|
|
72
|
-
pass
|
|
73
|
-
except Exception:
|
|
74
|
-
pass
|
|
86
|
+
ref_map = self._build_ref_map()
|
|
75
87
|
|
|
76
88
|
# Use git log with --numstat for stats, avoiding gitpython's object parser
|
|
77
89
|
output = self.repo.git.log(
|
|
@@ -145,19 +157,11 @@ class GitRepo:
|
|
|
145
157
|
Get recent commits across the entire repo (not file-specific).
|
|
146
158
|
Uses git log directly. Returns newest-first for search display.
|
|
147
159
|
"""
|
|
148
|
-
ref_map
|
|
149
|
-
try:
|
|
150
|
-
for ref in self.repo.refs:
|
|
151
|
-
try:
|
|
152
|
-
sha = ref.commit.hexsha
|
|
153
|
-
ref_map.setdefault(sha, []).append(ref.name)
|
|
154
|
-
except Exception:
|
|
155
|
-
pass
|
|
156
|
-
except Exception:
|
|
157
|
-
pass
|
|
160
|
+
ref_map = self._build_ref_map()
|
|
158
161
|
|
|
159
162
|
output = self.repo.git.log(
|
|
160
163
|
f"--max-count={max_count}",
|
|
164
|
+
"--no-merges",
|
|
161
165
|
"--format=---GVT_START---%n%H%n%at%n%an%n%s",
|
|
162
166
|
"--shortstat",
|
|
163
167
|
)
|
|
@@ -259,7 +263,8 @@ class GitRepo:
|
|
|
259
263
|
rel_path = self._to_relative(path)
|
|
260
264
|
try:
|
|
261
265
|
return self.repo.git.show(f"{commit_sha}:{rel_path}")
|
|
262
|
-
except
|
|
266
|
+
except GitCommandError as e:
|
|
267
|
+
log.warning("git show %s:%s failed: %s", commit_sha, rel_path, e)
|
|
263
268
|
return ""
|
|
264
269
|
|
|
265
270
|
def get_blame(self, path: str, commit_sha: str) -> list[tuple[str, str, str]]:
|
|
@@ -273,7 +278,8 @@ class GitRepo:
|
|
|
273
278
|
commit_sha, "--", rel_path,
|
|
274
279
|
porcelain=True,
|
|
275
280
|
)
|
|
276
|
-
except
|
|
281
|
+
except GitCommandError as e:
|
|
282
|
+
log.warning("git blame %s -- %s failed: %s", commit_sha, rel_path, e)
|
|
277
283
|
return []
|
|
278
284
|
|
|
279
285
|
lines: list[tuple[str, str, str]] = []
|
|
@@ -340,18 +346,32 @@ class GitRepo:
|
|
|
340
346
|
"""
|
|
341
347
|
Get all files changed in a commit with their stats.
|
|
342
348
|
Returns list of (file_path, additions, deletions).
|
|
349
|
+
|
|
350
|
+
Uses git diff-tree directly to avoid gitpython's commit.stats
|
|
351
|
+
which can fail with ValueError on repos with dubious ownership
|
|
352
|
+
or other gitpython object-traversal bugs.
|
|
343
353
|
"""
|
|
344
|
-
commit = self.repo.commit(commit_sha)
|
|
345
|
-
files = []
|
|
346
354
|
try:
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
+
output = self.repo.git.diff_tree(
|
|
356
|
+
"--numstat", "-r", "--root", "--no-commit-id", commit_sha
|
|
357
|
+
)
|
|
358
|
+
except (GitCommandError, ValueError) as e:
|
|
359
|
+
log.warning("diff-tree for %s failed: %s", commit_sha, e)
|
|
360
|
+
return []
|
|
361
|
+
|
|
362
|
+
if not output:
|
|
363
|
+
return []
|
|
364
|
+
|
|
365
|
+
files = []
|
|
366
|
+
for line in output.strip().split("\n"):
|
|
367
|
+
parts = line.split("\t")
|
|
368
|
+
if len(parts) != 3:
|
|
369
|
+
continue
|
|
370
|
+
adds_str, dels_str, file_path = parts
|
|
371
|
+
adds = int(adds_str) if adds_str != "-" else 0
|
|
372
|
+
dels = int(dels_str) if dels_str != "-" else 0
|
|
373
|
+
files.append((file_path, adds, dels))
|
|
374
|
+
|
|
355
375
|
return sorted(files, key=lambda x: x[0])
|
|
356
376
|
|
|
357
377
|
def get_tracked_files(self) -> list[str]:
|
|
@@ -393,6 +413,8 @@ class GitRepo:
|
|
|
393
413
|
try:
|
|
394
414
|
current = self.repo.active_branch.name
|
|
395
415
|
except TypeError:
|
|
416
|
+
# Detached HEAD — expected when viewing a specific commit.
|
|
417
|
+
log.debug("detached HEAD; active_branch unavailable")
|
|
396
418
|
current = "HEAD"
|
|
397
419
|
return branches, current
|
|
398
420
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Structured logging for gvt — writes to ~/.config/gvt/gvt.log.
|
|
2
|
+
|
|
3
|
+
gvt is a full-screen Textual TUI, so stderr logging would corrupt the display.
|
|
4
|
+
Instead we write to a rotating file. Level is controlled via GVT_LOG_LEVEL
|
|
5
|
+
(default WARNING).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
import os
|
|
12
|
+
from logging.handlers import RotatingFileHandler
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
_LOG_PATH = Path.home() / ".config" / "gvt" / "gvt.log"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def get_logger(name: str = "gvt") -> logging.Logger:
|
|
19
|
+
"""Return a module logger with a rotating file handler attached once."""
|
|
20
|
+
logger = logging.getLogger(name)
|
|
21
|
+
if logger.handlers:
|
|
22
|
+
return logger
|
|
23
|
+
|
|
24
|
+
try:
|
|
25
|
+
_LOG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
handler = RotatingFileHandler(
|
|
27
|
+
_LOG_PATH, maxBytes=512_000, backupCount=2
|
|
28
|
+
)
|
|
29
|
+
handler.setFormatter(
|
|
30
|
+
logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s")
|
|
31
|
+
)
|
|
32
|
+
logger.addHandler(handler)
|
|
33
|
+
except OSError:
|
|
34
|
+
# If we can't create the log directory, fall back to a null handler so
|
|
35
|
+
# logging calls remain no-ops rather than crashing the app.
|
|
36
|
+
logger.addHandler(logging.NullHandler())
|
|
37
|
+
|
|
38
|
+
logger.setLevel(os.environ.get("GVT_LOG_LEVEL", "WARNING").upper())
|
|
39
|
+
logger.propagate = False
|
|
40
|
+
return logger
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"""Tests for user-facing action handlers that surface errors via notify."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def test_copy_to_clipboard_reports_failure(fixture_app, monkeypatch):
|
|
7
|
+
"""Clipboard-tool failure is reported to the user via notify."""
|
|
8
|
+
monkeypatch.setattr("gvt.app.shutil.which", lambda x: "/usr/bin/pbcopy")
|
|
9
|
+
|
|
10
|
+
def boom(*a, **k):
|
|
11
|
+
raise OSError("permission denied")
|
|
12
|
+
|
|
13
|
+
monkeypatch.setattr("gvt.app.subprocess.run", boom)
|
|
14
|
+
|
|
15
|
+
called = []
|
|
16
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
17
|
+
fixture_app._copy_to_clipboard("abc123")
|
|
18
|
+
|
|
19
|
+
assert called
|
|
20
|
+
assert any("Failed" in m for m in called)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_copy_to_clipboard_reports_nonzero_exit(fixture_app, monkeypatch):
|
|
24
|
+
"""A CalledProcessError from the clipboard tool is caught and reported."""
|
|
25
|
+
monkeypatch.setattr("gvt.app.shutil.which", lambda x: "/usr/bin/pbcopy")
|
|
26
|
+
|
|
27
|
+
def failing(*a, **k):
|
|
28
|
+
raise subprocess.CalledProcessError(1, a[0])
|
|
29
|
+
|
|
30
|
+
monkeypatch.setattr("gvt.app.subprocess.run", failing)
|
|
31
|
+
|
|
32
|
+
called = []
|
|
33
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
34
|
+
fixture_app._copy_to_clipboard("abc123")
|
|
35
|
+
|
|
36
|
+
assert any("Failed" in m for m in called)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_copy_to_clipboard_no_tool(fixture_app, monkeypatch):
|
|
40
|
+
"""When no clipboard tool is installed, user sees a clear message."""
|
|
41
|
+
monkeypatch.setattr("gvt.app.shutil.which", lambda x: None)
|
|
42
|
+
|
|
43
|
+
called = []
|
|
44
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
45
|
+
fixture_app._copy_to_clipboard("abc123")
|
|
46
|
+
|
|
47
|
+
assert any("No clipboard" in m for m in called)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def test_copy_to_clipboard_success(fixture_app, monkeypatch):
|
|
51
|
+
"""Happy path: successful copy notifies 'Copied ...'."""
|
|
52
|
+
monkeypatch.setattr("gvt.app.shutil.which", lambda x: "/usr/bin/pbcopy")
|
|
53
|
+
|
|
54
|
+
runs = []
|
|
55
|
+
|
|
56
|
+
def fake_run(cmd, input=None, check=False, **k):
|
|
57
|
+
runs.append((cmd, input))
|
|
58
|
+
return subprocess.CompletedProcess(cmd, 0)
|
|
59
|
+
|
|
60
|
+
monkeypatch.setattr("gvt.app.subprocess.run", fake_run)
|
|
61
|
+
|
|
62
|
+
called = []
|
|
63
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
64
|
+
fixture_app._copy_to_clipboard("abc123")
|
|
65
|
+
|
|
66
|
+
assert runs, "subprocess.run should have been invoked"
|
|
67
|
+
assert any("Copied abc123" in m for m in called)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def test_open_in_editor_launch_failure(fixture_app, monkeypatch):
|
|
71
|
+
"""If the editor binary cannot launch, user is notified."""
|
|
72
|
+
fixture_app.current_file = "hello.py"
|
|
73
|
+
monkeypatch.setenv("EDITOR", "nonexistent-editor-xyz")
|
|
74
|
+
import contextlib
|
|
75
|
+
monkeypatch.setattr(
|
|
76
|
+
fixture_app, "suspend", lambda: contextlib.nullcontext()
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
def boom(*a, **k):
|
|
80
|
+
raise FileNotFoundError("no such editor")
|
|
81
|
+
|
|
82
|
+
monkeypatch.setattr("gvt.app.subprocess.run", boom)
|
|
83
|
+
|
|
84
|
+
called = []
|
|
85
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
86
|
+
fixture_app.action_open_in_editor()
|
|
87
|
+
|
|
88
|
+
assert any("Could not launch" in m for m in called)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def test_open_in_editor_nonzero_exit(fixture_app, monkeypatch):
|
|
92
|
+
"""If the editor exits nonzero, user is notified."""
|
|
93
|
+
fixture_app.current_file = "hello.py"
|
|
94
|
+
monkeypatch.setenv("EDITOR", "fake-editor")
|
|
95
|
+
import contextlib
|
|
96
|
+
monkeypatch.setattr(
|
|
97
|
+
fixture_app, "suspend", lambda: contextlib.nullcontext()
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def fake_run(cmd, **k):
|
|
101
|
+
return subprocess.CompletedProcess(cmd, 2)
|
|
102
|
+
|
|
103
|
+
monkeypatch.setattr("gvt.app.subprocess.run", fake_run)
|
|
104
|
+
|
|
105
|
+
called = []
|
|
106
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
107
|
+
fixture_app.action_open_in_editor()
|
|
108
|
+
|
|
109
|
+
assert any("exited with code 2" in m for m in called)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def test_open_in_editor_no_current_file(fixture_app, monkeypatch):
|
|
113
|
+
"""Without a current_file, action is a no-op (does not notify or launch)."""
|
|
114
|
+
fixture_app.current_file = None
|
|
115
|
+
runs = []
|
|
116
|
+
monkeypatch.setattr(
|
|
117
|
+
"gvt.app.subprocess.run", lambda *a, **k: runs.append(a)
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
called = []
|
|
121
|
+
fixture_app.notify = lambda msg, **k: called.append(msg)
|
|
122
|
+
fixture_app.action_open_in_editor()
|
|
123
|
+
|
|
124
|
+
assert not runs
|
|
125
|
+
assert not called
|
|
@@ -12,6 +12,7 @@ from gvt.widgets.diff_view import DiffViewWidget
|
|
|
12
12
|
from gvt.widgets.file_tree import FileTreeWidget
|
|
13
13
|
from gvt.widgets.changed_files import ChangedFilesWidget
|
|
14
14
|
from gvt.widgets.commit_bar import CommitMessageBar
|
|
15
|
+
from gvt.widgets.modals import CommitFilesModal, CommitSearchModal
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
@pytest.fixture
|
|
@@ -136,6 +137,35 @@ async def test_commit_search_with_cache(app_repo):
|
|
|
136
137
|
await pilot.pause()
|
|
137
138
|
|
|
138
139
|
|
|
140
|
+
@pytest.mark.asyncio
|
|
141
|
+
async def test_commit_search_select_shows_file_picker(app_repo):
|
|
142
|
+
"""Select a commit from search → CommitFilesModal should appear."""
|
|
143
|
+
app = make_app(app_repo, initial_file="hello.py")
|
|
144
|
+
async with app.run_test(size=(120, 40)) as pilot:
|
|
145
|
+
await pilot.pause()
|
|
146
|
+
await pilot.pause()
|
|
147
|
+
# Pre-populate cache
|
|
148
|
+
all_commits = app.git_repo.get_all_commits()
|
|
149
|
+
app._all_commits_cache = all_commits
|
|
150
|
+
|
|
151
|
+
# Open commit search
|
|
152
|
+
await pilot.press("c")
|
|
153
|
+
await pilot.pause()
|
|
154
|
+
assert isinstance(app.screen, CommitSearchModal), (
|
|
155
|
+
f"Expected CommitSearchModal, got {type(app.screen).__name__}"
|
|
156
|
+
)
|
|
157
|
+
# Press Enter to select the first commit
|
|
158
|
+
await pilot.press("enter")
|
|
159
|
+
await pilot.pause()
|
|
160
|
+
await pilot.pause()
|
|
161
|
+
# CommitFilesModal should now be on the screen stack
|
|
162
|
+
assert isinstance(app.screen, CommitFilesModal), (
|
|
163
|
+
f"Expected CommitFilesModal, got {type(app.screen).__name__}"
|
|
164
|
+
)
|
|
165
|
+
await pilot.press("escape")
|
|
166
|
+
await pilot.pause()
|
|
167
|
+
|
|
168
|
+
|
|
139
169
|
@pytest.mark.asyncio
|
|
140
170
|
async def test_time_filter_opens_and_closes(app_repo):
|
|
141
171
|
app = make_app(app_repo, initial_file="hello.py")
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"""Tests for gvt.logging_setup — file handler creation and fallback."""
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def _reset_logger(name: str) -> None:
|
|
8
|
+
"""Drop handlers on a named logger so get_logger reinstalls them."""
|
|
9
|
+
logger = logging.getLogger(name)
|
|
10
|
+
for h in list(logger.handlers):
|
|
11
|
+
logger.removeHandler(h)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def test_logger_writes_to_file(tmp_path, monkeypatch):
|
|
15
|
+
"""Warnings go to ~/.config/gvt/gvt.log when HOME is writable."""
|
|
16
|
+
monkeypatch.setenv("HOME", str(tmp_path))
|
|
17
|
+
monkeypatch.setenv("GVT_LOG_LEVEL", "DEBUG")
|
|
18
|
+
|
|
19
|
+
import gvt.logging_setup
|
|
20
|
+
importlib.reload(gvt.logging_setup)
|
|
21
|
+
_reset_logger("gvt.test_writes")
|
|
22
|
+
|
|
23
|
+
log = gvt.logging_setup.get_logger("gvt.test_writes")
|
|
24
|
+
log.warning("hello from test")
|
|
25
|
+
for h in log.handlers:
|
|
26
|
+
h.flush()
|
|
27
|
+
|
|
28
|
+
log_file = tmp_path / ".config" / "gvt" / "gvt.log"
|
|
29
|
+
assert log_file.exists()
|
|
30
|
+
assert "hello from test" in log_file.read_text()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def test_logger_respects_level(tmp_path, monkeypatch):
|
|
34
|
+
"""DEBUG messages should be written when GVT_LOG_LEVEL=DEBUG."""
|
|
35
|
+
monkeypatch.setenv("HOME", str(tmp_path))
|
|
36
|
+
monkeypatch.setenv("GVT_LOG_LEVEL", "DEBUG")
|
|
37
|
+
|
|
38
|
+
import gvt.logging_setup
|
|
39
|
+
importlib.reload(gvt.logging_setup)
|
|
40
|
+
_reset_logger("gvt.test_level")
|
|
41
|
+
|
|
42
|
+
log = gvt.logging_setup.get_logger("gvt.test_level")
|
|
43
|
+
log.debug("debug-line")
|
|
44
|
+
for h in log.handlers:
|
|
45
|
+
h.flush()
|
|
46
|
+
|
|
47
|
+
log_file = tmp_path / ".config" / "gvt" / "gvt.log"
|
|
48
|
+
assert log_file.exists()
|
|
49
|
+
assert "debug-line" in log_file.read_text()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_logger_default_level_warning(tmp_path, monkeypatch):
|
|
53
|
+
"""Without GVT_LOG_LEVEL, default level is WARNING (DEBUG filtered)."""
|
|
54
|
+
monkeypatch.setenv("HOME", str(tmp_path))
|
|
55
|
+
monkeypatch.delenv("GVT_LOG_LEVEL", raising=False)
|
|
56
|
+
|
|
57
|
+
import gvt.logging_setup
|
|
58
|
+
importlib.reload(gvt.logging_setup)
|
|
59
|
+
_reset_logger("gvt.test_default")
|
|
60
|
+
|
|
61
|
+
log = gvt.logging_setup.get_logger("gvt.test_default")
|
|
62
|
+
log.debug("debug-should-be-filtered")
|
|
63
|
+
log.warning("warn-should-pass")
|
|
64
|
+
for h in log.handlers:
|
|
65
|
+
h.flush()
|
|
66
|
+
|
|
67
|
+
log_file = tmp_path / ".config" / "gvt" / "gvt.log"
|
|
68
|
+
contents = log_file.read_text() if log_file.exists() else ""
|
|
69
|
+
assert "debug-should-be-filtered" not in contents
|
|
70
|
+
assert "warn-should-pass" in contents
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_logger_falls_back_on_unwritable_dir(monkeypatch):
|
|
74
|
+
"""If the log dir cannot be created, get_logger must not raise."""
|
|
75
|
+
monkeypatch.setenv("HOME", "/dev/null/definitely-not-writable")
|
|
76
|
+
|
|
77
|
+
import gvt.logging_setup
|
|
78
|
+
importlib.reload(gvt.logging_setup)
|
|
79
|
+
_reset_logger("gvt.test_fallback")
|
|
80
|
+
|
|
81
|
+
log = gvt.logging_setup.get_logger("gvt.test_fallback")
|
|
82
|
+
# Logging must be a no-op, not raise.
|
|
83
|
+
log.warning("should not crash")
|
|
84
|
+
assert log.handlers # fallback NullHandler attached
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def test_logger_handlers_not_duplicated(tmp_path, monkeypatch):
|
|
88
|
+
"""Calling get_logger twice returns the same logger without adding handlers."""
|
|
89
|
+
monkeypatch.setenv("HOME", str(tmp_path))
|
|
90
|
+
|
|
91
|
+
import gvt.logging_setup
|
|
92
|
+
importlib.reload(gvt.logging_setup)
|
|
93
|
+
_reset_logger("gvt.test_dup")
|
|
94
|
+
|
|
95
|
+
log1 = gvt.logging_setup.get_logger("gvt.test_dup")
|
|
96
|
+
handler_count = len(log1.handlers)
|
|
97
|
+
log2 = gvt.logging_setup.get_logger("gvt.test_dup")
|
|
98
|
+
assert log1 is log2
|
|
99
|
+
assert len(log2.handlers) == handler_count
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Tests verifying GitRepo degrades gracefully on bad input / corrupt state."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
|
|
5
|
+
from git import Repo
|
|
6
|
+
|
|
7
|
+
from gvt.git.repo import GitRepo
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def test_get_file_at_commit_unknown_sha(git_repo):
|
|
11
|
+
"""Unknown sha returns empty string rather than raising."""
|
|
12
|
+
assert git_repo.get_file_at_commit("hello.py", "deadbeef" * 5) == ""
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_get_file_at_commit_missing_path(git_repo):
|
|
16
|
+
"""Valid sha but missing path returns empty string."""
|
|
17
|
+
commits = git_repo.get_file_commits("hello.py")
|
|
18
|
+
assert git_repo.get_file_at_commit("does-not-exist.py", commits[-1].hexsha) == ""
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_get_blame_unknown_sha(git_repo):
|
|
22
|
+
"""Unknown sha returns empty list."""
|
|
23
|
+
assert git_repo.get_blame("hello.py", "deadbeef" * 5) == []
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_get_blame_missing_file(git_repo):
|
|
27
|
+
"""Missing path returns empty list."""
|
|
28
|
+
commits = git_repo.get_file_commits("hello.py")
|
|
29
|
+
assert git_repo.get_blame("does-not-exist.py", commits[-1].hexsha) == []
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_get_commit_files_unknown_sha(git_repo):
|
|
33
|
+
"""Unknown sha returns empty list."""
|
|
34
|
+
assert git_repo.get_commit_files("deadbeef" * 5) == []
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_build_ref_map_tolerates_corrupt_ref(fixture_repo):
|
|
38
|
+
"""A corrupt refs/heads/* file must not prevent history from loading."""
|
|
39
|
+
bad_ref = os.path.join(fixture_repo, ".git", "refs", "heads", "bad-ref")
|
|
40
|
+
with open(bad_ref, "w") as f:
|
|
41
|
+
f.write("not-a-sha\n")
|
|
42
|
+
|
|
43
|
+
gr = GitRepo(fixture_repo)
|
|
44
|
+
commits = gr.get_file_commits("hello.py")
|
|
45
|
+
assert len(commits) >= 1
|
|
46
|
+
|
|
47
|
+
# get_all_commits also uses _build_ref_map
|
|
48
|
+
all_commits = gr.get_all_commits()
|
|
49
|
+
assert len(all_commits) >= 1
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_get_branches_detached_head(fixture_repo):
|
|
53
|
+
"""Detached HEAD returns 'HEAD' as current branch."""
|
|
54
|
+
r = Repo(fixture_repo)
|
|
55
|
+
head_sha = r.head.commit.hexsha
|
|
56
|
+
r.git.checkout(head_sha) # detach
|
|
57
|
+
|
|
58
|
+
gr = GitRepo(fixture_repo)
|
|
59
|
+
_, current = gr.get_branches()
|
|
60
|
+
assert current == "HEAD"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|