git-visual-timeline 0.2.0__tar.gz → 0.2.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_visual_timeline-0.2.0/src/git_visual_timeline.egg-info → git_visual_timeline-0.2.1}/PKG-INFO +1 -1
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/pyproject.toml +4 -1
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1/src/git_visual_timeline.egg-info}/PKG-INFO +1 -1
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/SOURCES.txt +1 -0
- git_visual_timeline-0.2.1/src/gvt/__init__.py +1 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/app.py +30 -19
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/git/cache.py +22 -12
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/git/repo.py +16 -7
- git_visual_timeline-0.2.1/src/gvt/styles/app.tcss +178 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/commit_bar.py +1 -1
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/diff_view.py +2 -6
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/modals.py +0 -89
- git_visual_timeline-0.2.0/src/gvt/__init__.py +0 -1
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/LICENSE +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/README.md +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/setup.cfg +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/dependency_links.txt +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/entry_points.txt +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/requires.txt +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/git_visual_timeline.egg-info/top_level.txt +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/cli.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/git/__init__.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/__init__.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/changed_files.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/commit_toast.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/file_tree.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/status_bar.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/src/gvt/widgets/timeline.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_app_integration.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_cache.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_changed_files.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_diff_view_logic.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_git_repo.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_git_repo_extended.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_timeline_logic.py +0 -0
- {git_visual_timeline-0.2.0 → git_visual_timeline-0.2.1}/tests/test_widgets.py +0 -0
|
@@ -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.1"
|
|
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"}
|
|
@@ -54,6 +54,9 @@ gvt = "gvt.cli:main"
|
|
|
54
54
|
[tool.setuptools.packages.find]
|
|
55
55
|
where = ["src"]
|
|
56
56
|
|
|
57
|
+
[tool.setuptools.package-data]
|
|
58
|
+
gvt = ["styles/*.tcss"]
|
|
59
|
+
|
|
57
60
|
[tool.ruff]
|
|
58
61
|
line-length = 88
|
|
59
62
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.1"
|
|
@@ -4,8 +4,12 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import hashlib
|
|
6
6
|
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import subprocess
|
|
9
|
+
from datetime import datetime, timezone
|
|
7
10
|
from pathlib import Path
|
|
8
11
|
|
|
12
|
+
from rich.text import Text
|
|
9
13
|
from textual import on, work
|
|
10
14
|
from textual.app import App, ComposeResult
|
|
11
15
|
from textual.binding import Binding
|
|
@@ -23,7 +27,6 @@ from gvt.widgets.modals import (
|
|
|
23
27
|
CommitFilesModal,
|
|
24
28
|
CommitSearchModal,
|
|
25
29
|
FileSearchModal,
|
|
26
|
-
FlashAuthorModal,
|
|
27
30
|
HelpModal,
|
|
28
31
|
QuitConfirmModal,
|
|
29
32
|
TimeFilterModal,
|
|
@@ -206,7 +209,6 @@ class GVTApp(App):
|
|
|
206
209
|
diff_view.set_diff("")
|
|
207
210
|
diff_view.set_message("")
|
|
208
211
|
# Build a simple preview with line numbers
|
|
209
|
-
from rich.text import Text
|
|
210
212
|
lines = []
|
|
211
213
|
for i, line_text in enumerate(content.split("\n"), 1):
|
|
212
214
|
t = Text()
|
|
@@ -240,8 +242,6 @@ class GVTApp(App):
|
|
|
240
242
|
@work(thread=True)
|
|
241
243
|
def _do_load_file(self, file_path: str) -> None:
|
|
242
244
|
"""Load file commits in background thread."""
|
|
243
|
-
from datetime import datetime, timezone
|
|
244
|
-
|
|
245
245
|
commits = self.git_repo.get_file_commits(file_path)
|
|
246
246
|
|
|
247
247
|
# Append WIP tick if file has uncommitted changes
|
|
@@ -373,11 +373,18 @@ class GVTApp(App):
|
|
|
373
373
|
@work(thread=True)
|
|
374
374
|
def _load_diff(self, file_path: str, left_idx: int, right_idx: int) -> None:
|
|
375
375
|
"""Load diff between two commits, using cache."""
|
|
376
|
-
|
|
376
|
+
commits = list(self.current_commits)
|
|
377
|
+
if not commits:
|
|
377
378
|
return
|
|
378
379
|
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
if left_idx >= len(commits) or right_idx >= len(commits):
|
|
381
|
+
return
|
|
382
|
+
|
|
383
|
+
if self.current_file != file_path:
|
|
384
|
+
return
|
|
385
|
+
|
|
386
|
+
left = commits[left_idx]
|
|
387
|
+
right = commits[right_idx]
|
|
381
388
|
diff_view = self.query_one("#diff-view", DiffViewWidget)
|
|
382
389
|
|
|
383
390
|
if left.hexsha == right.hexsha:
|
|
@@ -426,11 +433,11 @@ class GVTApp(App):
|
|
|
426
433
|
@work(thread=True, exclusive=True, group="preload")
|
|
427
434
|
def _preload_adjacent_diffs(self, file_path: str, cursor_idx: int, context: int) -> None:
|
|
428
435
|
"""Preload diffs for adjacent timeline positions into the cache."""
|
|
429
|
-
|
|
436
|
+
commits = list(self.current_commits)
|
|
437
|
+
if not commits or len(commits) < 2:
|
|
430
438
|
return
|
|
431
439
|
|
|
432
440
|
cache_key_suffix = f"_ctx{context}"
|
|
433
|
-
commits = self.current_commits
|
|
434
441
|
|
|
435
442
|
# Adjacent pairs to preload: (N-1 → N) and (N → N+1)
|
|
436
443
|
pairs = []
|
|
@@ -503,7 +510,6 @@ class GVTApp(App):
|
|
|
503
510
|
def _tmux_select_pane(direction: str) -> None:
|
|
504
511
|
"""Hand off navigation to tmux if running inside tmux."""
|
|
505
512
|
if os.environ.get("TMUX"):
|
|
506
|
-
import subprocess
|
|
507
513
|
subprocess.run(["tmux", "select-pane", f"-{direction}"], check=False)
|
|
508
514
|
|
|
509
515
|
def action_focus_left(self) -> None:
|
|
@@ -677,7 +683,8 @@ class GVTApp(App):
|
|
|
677
683
|
if diff_view.blame_enabled and self.current_file and self.current_commits:
|
|
678
684
|
timeline = self.query_one("#timeline-widget", TimelineWidget)
|
|
679
685
|
right_commit = self.current_commits[timeline.right_cursor]
|
|
680
|
-
|
|
686
|
+
if not right_commit.is_wip:
|
|
687
|
+
self._load_blame(self.current_file, right_commit.hexsha)
|
|
681
688
|
|
|
682
689
|
def action_flash_last_author(self) -> None:
|
|
683
690
|
"""Show who last modified the file and contributor breakdown."""
|
|
@@ -686,10 +693,18 @@ class GVTApp(App):
|
|
|
686
693
|
timeline = self.query_one("#timeline-widget", TimelineWidget)
|
|
687
694
|
commit = self.current_commits[timeline.cursor]
|
|
688
695
|
contributors = self.git_repo.get_file_contributors(self.current_file)
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
)
|
|
696
|
+
|
|
697
|
+
# Build contributor text for notification (no modal — avoids ghosting)
|
|
698
|
+
total = sum(count for _, count in contributors)
|
|
699
|
+
lines = [f"Last modified by {commit.author} ({commit.short_hash})"]
|
|
700
|
+
if total:
|
|
701
|
+
lines.append("")
|
|
702
|
+
for name, count in contributors[:8]:
|
|
703
|
+
pct = count / total * 100
|
|
704
|
+
bar = "█" * max(1, round(count / total * 20))
|
|
705
|
+
lines.append(f" {bar} {name} {count} commits ({pct:.0f}%)")
|
|
706
|
+
self.clear_notifications()
|
|
707
|
+
self.notify("\n".join(lines), title="Contributors", timeout=5)
|
|
693
708
|
|
|
694
709
|
def action_copy_short_hash(self) -> None:
|
|
695
710
|
if not self.current_commits:
|
|
@@ -706,8 +721,6 @@ class GVTApp(App):
|
|
|
706
721
|
self._copy_to_clipboard(commit.hexsha)
|
|
707
722
|
|
|
708
723
|
def _copy_to_clipboard(self, text: str) -> None:
|
|
709
|
-
import subprocess
|
|
710
|
-
import shutil
|
|
711
724
|
try:
|
|
712
725
|
if shutil.which("pbcopy"):
|
|
713
726
|
subprocess.run(["pbcopy"], input=text.encode(), check=True)
|
|
@@ -725,12 +738,10 @@ class GVTApp(App):
|
|
|
725
738
|
def action_open_in_editor(self) -> None:
|
|
726
739
|
if not self.current_file:
|
|
727
740
|
return
|
|
728
|
-
import shutil
|
|
729
741
|
editor = os.environ.get("VISUAL") or os.environ.get("EDITOR") or "vim"
|
|
730
742
|
file_path = os.path.join(self.repo_path, self.current_file)
|
|
731
743
|
self.suspend()
|
|
732
744
|
try:
|
|
733
|
-
import subprocess
|
|
734
745
|
subprocess.run([editor, file_path])
|
|
735
746
|
finally:
|
|
736
747
|
self.resume()
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import threading
|
|
5
6
|
from collections import OrderedDict
|
|
6
7
|
from typing import Callable
|
|
7
8
|
|
|
@@ -14,6 +15,7 @@ class DiffCache:
|
|
|
14
15
|
def __init__(self, max_size: int = 100):
|
|
15
16
|
self.max_size = max_size
|
|
16
17
|
self._cache: OrderedDict[tuple[str, str, str], str] = OrderedDict()
|
|
18
|
+
self._lock = threading.Lock()
|
|
17
19
|
|
|
18
20
|
def get_or_compute(
|
|
19
21
|
self,
|
|
@@ -26,30 +28,38 @@ class DiffCache:
|
|
|
26
28
|
Return cached diff or compute it and cache the result.
|
|
27
29
|
"""
|
|
28
30
|
key = (file_path, commit_a, commit_b)
|
|
29
|
-
|
|
30
|
-
self._cache
|
|
31
|
-
|
|
31
|
+
with self._lock:
|
|
32
|
+
if key in self._cache:
|
|
33
|
+
self._cache.move_to_end(key)
|
|
34
|
+
return self._cache[key]
|
|
32
35
|
|
|
36
|
+
# Compute outside the lock to avoid blocking other threads
|
|
33
37
|
value = compute_fn()
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
self._cache
|
|
38
|
+
|
|
39
|
+
with self._lock:
|
|
40
|
+
self._cache[key] = value
|
|
41
|
+
if len(self._cache) > self.max_size:
|
|
42
|
+
self._cache.popitem(last=False)
|
|
37
43
|
return value
|
|
38
44
|
|
|
39
45
|
def get(self, file_path: str, commit_a: str, commit_b: str) -> str | None:
|
|
40
46
|
"""Return cached diff or None."""
|
|
41
47
|
key = (file_path, commit_a, commit_b)
|
|
42
|
-
|
|
43
|
-
self._cache
|
|
44
|
-
|
|
48
|
+
with self._lock:
|
|
49
|
+
if key in self._cache:
|
|
50
|
+
self._cache.move_to_end(key)
|
|
51
|
+
return self._cache[key]
|
|
45
52
|
return None
|
|
46
53
|
|
|
47
54
|
def has(self, file_path: str, commit_a: str, commit_b: str) -> bool:
|
|
48
55
|
"""Check if a diff is already cached."""
|
|
49
|
-
|
|
56
|
+
with self._lock:
|
|
57
|
+
return (file_path, commit_a, commit_b) in self._cache
|
|
50
58
|
|
|
51
59
|
def clear(self) -> None:
|
|
52
|
-
self.
|
|
60
|
+
with self._lock:
|
|
61
|
+
self._cache.clear()
|
|
53
62
|
|
|
54
63
|
def __len__(self) -> int:
|
|
55
|
-
|
|
64
|
+
with self._lock:
|
|
65
|
+
return len(self._cache)
|
|
@@ -221,8 +221,6 @@ class GitRepo:
|
|
|
221
221
|
Get unified diff for a file between two commits.
|
|
222
222
|
"""
|
|
223
223
|
rel_path = self._to_relative(path)
|
|
224
|
-
a = self.repo.commit(commit_a)
|
|
225
|
-
b = self.repo.commit(commit_b)
|
|
226
224
|
# Use git diff directly for context line control
|
|
227
225
|
diff_output = self.repo.git.diff(
|
|
228
226
|
f"-U{context_lines}", commit_a, commit_b, "--", rel_path
|
|
@@ -312,18 +310,29 @@ class GitRepo:
|
|
|
312
310
|
Returns list of (author_name, commit_count).
|
|
313
311
|
"""
|
|
314
312
|
rel_path = self._to_relative(path)
|
|
315
|
-
|
|
313
|
+
output = self.repo.git.log(
|
|
314
|
+
"--format=%ae%n%an",
|
|
315
|
+
"--follow",
|
|
316
|
+
"--", rel_path,
|
|
317
|
+
)
|
|
318
|
+
if not output:
|
|
319
|
+
return []
|
|
320
|
+
|
|
321
|
+
lines = output.strip().split("\n")
|
|
316
322
|
by_email: dict[str, tuple[str, int]] = {}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
323
|
+
# Lines come in pairs: email, then name
|
|
324
|
+
for i in range(0, len(lines) - 1, 2):
|
|
325
|
+
email = lines[i].strip()
|
|
326
|
+
name = lines[i + 1].strip()
|
|
327
|
+
if not email:
|
|
328
|
+
continue
|
|
320
329
|
if email in by_email:
|
|
321
330
|
prev_name, prev_count = by_email[email]
|
|
322
|
-
# Keep the longer name (more likely to be the full name)
|
|
323
331
|
best_name = name if len(name) > len(prev_name) else prev_name
|
|
324
332
|
by_email[email] = (best_name, prev_count + 1)
|
|
325
333
|
else:
|
|
326
334
|
by_email[email] = (name, 1)
|
|
335
|
+
|
|
327
336
|
result = [(name, count) for name, count in by_email.values()]
|
|
328
337
|
return sorted(result, key=lambda x: x[1], reverse=True)
|
|
329
338
|
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/* Tokyo Night color scheme for gvt */
|
|
2
|
+
|
|
3
|
+
Screen {
|
|
4
|
+
background: #1a1b26;
|
|
5
|
+
color: #c0caf5;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/* Pane containers */
|
|
9
|
+
#left-pane {
|
|
10
|
+
width: 25%;
|
|
11
|
+
height: 100%;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#file-tree-pane {
|
|
15
|
+
height: 1fr;
|
|
16
|
+
border: solid #3b4261;
|
|
17
|
+
border-title-color: #565f89;
|
|
18
|
+
border-title-align: left;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
#file-tree-pane:focus-within {
|
|
22
|
+
border: solid #7aa2f7;
|
|
23
|
+
border-title-color: #7aa2f7;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#right-pane {
|
|
27
|
+
width: 75%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
#timeline-pane {
|
|
32
|
+
height: auto;
|
|
33
|
+
min-height: 9;
|
|
34
|
+
max-height: 12;
|
|
35
|
+
border: solid #3b4261;
|
|
36
|
+
border-title-color: #565f89;
|
|
37
|
+
border-title-align: left;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#timeline-pane:focus-within {
|
|
41
|
+
border: solid #7aa2f7;
|
|
42
|
+
border-title-color: #7aa2f7;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#commit-bar-pane {
|
|
46
|
+
height: auto;
|
|
47
|
+
min-height: 4;
|
|
48
|
+
max-height: 6;
|
|
49
|
+
border: solid #3b4261;
|
|
50
|
+
border-title-color: #565f89;
|
|
51
|
+
border-title-align: left;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#commit-bar-pane:focus-within {
|
|
55
|
+
border: solid #7aa2f7;
|
|
56
|
+
border-title-color: #7aa2f7;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
#diff-pane {
|
|
60
|
+
height: 1fr;
|
|
61
|
+
border: solid #3b4261;
|
|
62
|
+
border-title-color: #565f89;
|
|
63
|
+
border-title-align: left;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#diff-pane:focus-within {
|
|
67
|
+
border: solid #7aa2f7;
|
|
68
|
+
border-title-color: #7aa2f7;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#changed-files-pane {
|
|
73
|
+
height: auto;
|
|
74
|
+
min-height: 16;
|
|
75
|
+
max-height: 32;
|
|
76
|
+
border: solid #3b4261;
|
|
77
|
+
border-title-color: #565f89;
|
|
78
|
+
border-title-align: left;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
#changed-files-pane:focus-within {
|
|
82
|
+
border: solid #7aa2f7;
|
|
83
|
+
border-title-color: #7aa2f7;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Status bar */
|
|
87
|
+
GVTStatusBar {
|
|
88
|
+
dock: bottom;
|
|
89
|
+
height: 2;
|
|
90
|
+
background: #1a1b26;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* File tree */
|
|
94
|
+
FileTreeWidget {
|
|
95
|
+
background: #1a1b26;
|
|
96
|
+
scrollbar-background: #1a1b26;
|
|
97
|
+
scrollbar-color: #3b4261;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
FileTreeWidget .file-entry {
|
|
101
|
+
color: #c0caf5;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
FileTreeWidget .file-entry--selected {
|
|
105
|
+
background: #283457;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
FileTreeWidget .dir-entry {
|
|
109
|
+
color: #7aa2f7;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/* Timeline */
|
|
113
|
+
TimelineWidget {
|
|
114
|
+
background: #1a1b26;
|
|
115
|
+
height: 100%;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Commit bar */
|
|
119
|
+
CommitMessageBar {
|
|
120
|
+
background: #1a1b26;
|
|
121
|
+
height: 100%;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* Changed files */
|
|
125
|
+
ChangedFilesWidget {
|
|
126
|
+
background: #1a1b26;
|
|
127
|
+
scrollbar-background: #1a1b26;
|
|
128
|
+
scrollbar-color: #3b4261;
|
|
129
|
+
height: 100%;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Diff view */
|
|
133
|
+
DiffViewWidget {
|
|
134
|
+
background: #1a1b26;
|
|
135
|
+
scrollbar-background: #1a1b26;
|
|
136
|
+
scrollbar-color: #3b4261;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* Modals */
|
|
140
|
+
.modal-overlay {
|
|
141
|
+
align: center middle;
|
|
142
|
+
background: rgba(0, 0, 0, 0.7);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.modal-container {
|
|
146
|
+
width: 70%;
|
|
147
|
+
height: 70%;
|
|
148
|
+
background: #1a1b26;
|
|
149
|
+
border: solid #7aa2f7;
|
|
150
|
+
padding: 1 2;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.modal-input {
|
|
154
|
+
background: #24283b;
|
|
155
|
+
color: #c0caf5;
|
|
156
|
+
border: solid #3b4261;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.modal-input:focus {
|
|
160
|
+
border: solid #7aa2f7;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.modal-results {
|
|
164
|
+
background: #1a1b26;
|
|
165
|
+
color: #c0caf5;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.modal-result--selected {
|
|
169
|
+
background: #283457;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.commit-detail-popup {
|
|
173
|
+
width: 60%;
|
|
174
|
+
height: 50%;
|
|
175
|
+
background: #1a1b26;
|
|
176
|
+
border: solid #7aa2f7;
|
|
177
|
+
padding: 1 2;
|
|
178
|
+
}
|
|
@@ -80,7 +80,7 @@ class CommitMessageBar(Widget, can_focus=True):
|
|
|
80
80
|
|
|
81
81
|
# Truncate message
|
|
82
82
|
first_line = commit.first_line
|
|
83
|
-
max_msg_len = max(20, 60
|
|
83
|
+
max_msg_len = max(20, self.size.width - 50) if self.size.width > 0 else 60
|
|
84
84
|
if len(first_line) > max_msg_len:
|
|
85
85
|
row.append(first_line[:max_msg_len] + "...", style=COLOR_MSG)
|
|
86
86
|
else:
|
|
@@ -128,8 +128,7 @@ class DiffViewWidget(ScrollView, can_focus=True):
|
|
|
128
128
|
self._hunk_positions.append(len(self._lines))
|
|
129
129
|
line.append(raw_line, style=f"bold {COLOR_HUNK}")
|
|
130
130
|
# Parse new file line number from @@ -a,b +c,d @@
|
|
131
|
-
|
|
132
|
-
match = re.search(r"\+(\d+)", raw_line)
|
|
131
|
+
match = re_module.search(r"\+(\d+)", raw_line)
|
|
133
132
|
if match:
|
|
134
133
|
new_file_line = int(match.group(1)) - 1
|
|
135
134
|
elif raw_line.startswith("+"):
|
|
@@ -165,8 +164,7 @@ class DiffViewWidget(ScrollView, can_focus=True):
|
|
|
165
164
|
for raw_line in diff.split("\n"):
|
|
166
165
|
if raw_line.startswith("@@"):
|
|
167
166
|
# Parse @@ -a,b +c,d @@ to get new file line number
|
|
168
|
-
|
|
169
|
-
match = re.search(r"\+(\d+)", raw_line)
|
|
167
|
+
match = re_module.search(r"\+(\d+)", raw_line)
|
|
170
168
|
if match:
|
|
171
169
|
new_line = int(match.group(1)) - 1
|
|
172
170
|
elif raw_line.startswith("+"):
|
|
@@ -225,8 +223,6 @@ class DiffViewWidget(ScrollView, can_focus=True):
|
|
|
225
223
|
self._lines.append(Text("No diff to display", style=COLOR_DIM))
|
|
226
224
|
return
|
|
227
225
|
|
|
228
|
-
import re
|
|
229
|
-
|
|
230
226
|
# Parse diff into pairs of (old_line, new_line)
|
|
231
227
|
pairs: list[tuple[str | None, str | None, str]] = [] # (left, right, type)
|
|
232
228
|
old_buf: list[str] = []
|
|
@@ -441,95 +441,6 @@ class CommitFilesModal(ModalScreen):
|
|
|
441
441
|
self.dismiss(None)
|
|
442
442
|
|
|
443
443
|
|
|
444
|
-
class FlashAuthorModal(ModalScreen):
|
|
445
|
-
"""Shows who last modified the file and a contributor breakdown."""
|
|
446
|
-
|
|
447
|
-
DEFAULT_CSS = """
|
|
448
|
-
FlashAuthorModal {
|
|
449
|
-
align: center middle;
|
|
450
|
-
background: rgba(0, 0, 0, 0.6);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
#flash-author-container {
|
|
454
|
-
width: 60;
|
|
455
|
-
height: auto;
|
|
456
|
-
max-height: 20;
|
|
457
|
-
background: #1a1b26;
|
|
458
|
-
border: solid #7aa2f7;
|
|
459
|
-
padding: 1 2;
|
|
460
|
-
overflow-y: auto;
|
|
461
|
-
}
|
|
462
|
-
"""
|
|
463
|
-
|
|
464
|
-
BINDINGS = [
|
|
465
|
-
("escape", "dismiss_modal", "Close"),
|
|
466
|
-
]
|
|
467
|
-
|
|
468
|
-
# Rotating colors for the bar chart
|
|
469
|
-
BAR_COLORS = [COLOR_ACCENT, COLOR_PURPLE, COLOR_GREEN, COLOR_AMBER, COLOR_RED]
|
|
470
|
-
|
|
471
|
-
def __init__(
|
|
472
|
-
self,
|
|
473
|
-
author: str,
|
|
474
|
-
short_hash: str,
|
|
475
|
-
date,
|
|
476
|
-
contributors: list[tuple[str, int]],
|
|
477
|
-
file_path: str,
|
|
478
|
-
**kwargs,
|
|
479
|
-
) -> None:
|
|
480
|
-
super().__init__(**kwargs)
|
|
481
|
-
self.author = author
|
|
482
|
-
self.short_hash = short_hash
|
|
483
|
-
self.date = date
|
|
484
|
-
self.contributors = contributors
|
|
485
|
-
self.file_path = file_path
|
|
486
|
-
|
|
487
|
-
def compose(self) -> ComposeResult:
|
|
488
|
-
text = Text()
|
|
489
|
-
|
|
490
|
-
# Header: last modifier
|
|
491
|
-
text.append("Last modified by ", style=COLOR_DIM)
|
|
492
|
-
text.append(f"{self.author}\n", style=f"bold {COLOR_ACCENT}")
|
|
493
|
-
text.append(f"{self.short_hash} {self.date.strftime('%Y-%m-%d %H:%M')}\n\n", style=COLOR_DIM)
|
|
494
|
-
|
|
495
|
-
# Contributor breakdown
|
|
496
|
-
total = sum(count for _, count in self.contributors)
|
|
497
|
-
if total == 0:
|
|
498
|
-
text.append("No contributors found", style=COLOR_DIM)
|
|
499
|
-
else:
|
|
500
|
-
text.append("Contributors\n", style=f"bold {COLOR_DIM}")
|
|
501
|
-
|
|
502
|
-
bar_width = 40
|
|
503
|
-
|
|
504
|
-
# Stacked bar — one line showing proportional segments
|
|
505
|
-
text.append(" ")
|
|
506
|
-
for i, (author, count) in enumerate(self.contributors):
|
|
507
|
-
color = self.BAR_COLORS[i % len(self.BAR_COLORS)]
|
|
508
|
-
segment_width = max(1, round(count / total * bar_width))
|
|
509
|
-
text.append("█" * segment_width, style=color)
|
|
510
|
-
text.append("\n\n")
|
|
511
|
-
|
|
512
|
-
# Legend with counts
|
|
513
|
-
for i, (author, count) in enumerate(self.contributors):
|
|
514
|
-
color = self.BAR_COLORS[i % len(self.BAR_COLORS)]
|
|
515
|
-
pct = count / total * 100
|
|
516
|
-
text.append(" ██", style=color)
|
|
517
|
-
text.append(f" {author}", style=COLOR_TEXT)
|
|
518
|
-
text.append(f" {count} commits ({pct:.0f}%)\n", style=COLOR_DIM)
|
|
519
|
-
|
|
520
|
-
text.append(f"\n Press any key to close", style=COLOR_DIM)
|
|
521
|
-
|
|
522
|
-
with Container(id="flash-author-container"):
|
|
523
|
-
yield Static(text)
|
|
524
|
-
|
|
525
|
-
def on_key(self, event) -> None:
|
|
526
|
-
self.dismiss(None)
|
|
527
|
-
event.prevent_default()
|
|
528
|
-
|
|
529
|
-
def action_dismiss_modal(self) -> None:
|
|
530
|
-
self.dismiss(None)
|
|
531
|
-
|
|
532
|
-
|
|
533
444
|
class QuitConfirmModal(ModalScreen):
|
|
534
445
|
"""Simple y/n quit confirmation."""
|
|
535
446
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.0"
|
|
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
|