nit-cli 0.4.2__tar.gz → 0.4.3__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.
- {nit_cli-0.4.2 → nit_cli-0.4.3}/PKG-INFO +1 -1
- {nit_cli-0.4.2 → nit_cli-0.4.3}/pyproject.toml +1 -1
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/app.py +29 -7
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/git.py +10 -9
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/PKG-INFO +1 -1
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_git.py +14 -1
- {nit_cli-0.4.2 → nit_cli-0.4.3}/LICENSE +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/README.md +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/setup.cfg +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/__init__.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/cli.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/comments.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/diff_parser.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/models.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/syntax.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/SOURCES.txt +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/dependency_links.txt +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/entry_points.txt +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/requires.txt +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/top_level.txt +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_app.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_cli.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_comments.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_diff_parser.py +0 -0
- {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_syntax.py +0 -0
|
@@ -614,6 +614,7 @@ class NitApp(App):
|
|
|
614
614
|
padding: 0 1;
|
|
615
615
|
text-style: bold;
|
|
616
616
|
width: 1fr;
|
|
617
|
+
overflow: hidden;
|
|
617
618
|
}
|
|
618
619
|
#seg-branch {
|
|
619
620
|
background: ansi_magenta;
|
|
@@ -831,6 +832,7 @@ class NitApp(App):
|
|
|
831
832
|
comment_counts = Counter(c.file_path for c in self.comments)
|
|
832
833
|
|
|
833
834
|
dir_nodes: dict[str, object] = {}
|
|
835
|
+
tree_order: list[int] = []
|
|
834
836
|
for dirname in sorted(dirs):
|
|
835
837
|
parts = dirname.split("/")
|
|
836
838
|
current = tree.root
|
|
@@ -847,6 +849,9 @@ class NitApp(App):
|
|
|
847
849
|
label = _file_label(fd, comment_counts[fd.path])
|
|
848
850
|
leaf = current.add_leaf(label)
|
|
849
851
|
leaf.data = i
|
|
852
|
+
tree_order.append(i)
|
|
853
|
+
|
|
854
|
+
self._tree_order = tree_order
|
|
850
855
|
|
|
851
856
|
def _update_file_list(self) -> None:
|
|
852
857
|
self._build_file_tree()
|
|
@@ -874,7 +879,10 @@ class NitApp(App):
|
|
|
874
879
|
mode_label = DIFF_MODE_LABELS.get(self.diff_mode, self.diff_mode)
|
|
875
880
|
n_comments = len(self.comments)
|
|
876
881
|
n_files = len(self.file_diffs)
|
|
877
|
-
|
|
882
|
+
branch_display = self.branch
|
|
883
|
+
if len(branch_display) > 30:
|
|
884
|
+
branch_display = branch_display[:29] + "…"
|
|
885
|
+
self.query_one("#seg-branch", Label).update(f"⎇ {branch_display}")
|
|
878
886
|
ws_indicator = " [no-ws]" if self.ignore_whitespace else ""
|
|
879
887
|
self.query_one("#seg-mode", Label).update(f"⇄ {mode_label}{ws_indicator}")
|
|
880
888
|
self.query_one("#seg-files", Label).update(f"▤ {n_files} files")
|
|
@@ -949,14 +957,28 @@ class NitApp(App):
|
|
|
949
957
|
self.query_one("#diff-view", DiffView).jump_to_next_hunk(forward=False)
|
|
950
958
|
|
|
951
959
|
def action_next_file(self) -> None:
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
960
|
+
order = getattr(self, "_tree_order", [])
|
|
961
|
+
if not order:
|
|
962
|
+
return
|
|
963
|
+
try:
|
|
964
|
+
pos = order.index(self._file_index)
|
|
965
|
+
except ValueError:
|
|
966
|
+
pos = -1
|
|
967
|
+
new_pos = (pos + 1) % len(order)
|
|
968
|
+
self._file_index = order[new_pos]
|
|
969
|
+
self._select_file(self._file_index)
|
|
955
970
|
|
|
956
971
|
def action_prev_file(self) -> None:
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
972
|
+
order = getattr(self, "_tree_order", [])
|
|
973
|
+
if not order:
|
|
974
|
+
return
|
|
975
|
+
try:
|
|
976
|
+
pos = order.index(self._file_index)
|
|
977
|
+
except ValueError:
|
|
978
|
+
pos = 0
|
|
979
|
+
new_pos = (pos - 1) % len(order)
|
|
980
|
+
self._file_index = order[new_pos]
|
|
981
|
+
self._select_file(self._file_index)
|
|
960
982
|
|
|
961
983
|
def action_next_comment(self) -> None:
|
|
962
984
|
self.query_one("#diff-view", DiffView).jump_to_next_comment(forward=True)
|
|
@@ -43,15 +43,16 @@ def get_current_branch(cwd: Path | None = None) -> str:
|
|
|
43
43
|
|
|
44
44
|
def get_main_branch(cwd: Path | None = None) -> str:
|
|
45
45
|
for name in ("main", "master"):
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
for ref in (f"refs/remotes/origin/{name}", f"refs/heads/{name}"):
|
|
47
|
+
result = subprocess.run(
|
|
48
|
+
["git", "rev-parse", "--verify", ref],
|
|
49
|
+
capture_output=True,
|
|
50
|
+
text=True,
|
|
51
|
+
cwd=cwd,
|
|
52
|
+
timeout=GIT_TIMEOUT,
|
|
53
|
+
)
|
|
54
|
+
if result.returncode == 0:
|
|
55
|
+
return f"origin/{name}" if ref.startswith("refs/remotes") else name
|
|
55
56
|
return "main"
|
|
56
57
|
|
|
57
58
|
|
|
@@ -28,10 +28,23 @@ def test_get_current_branch(git_repo):
|
|
|
28
28
|
assert branch == "main"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def
|
|
31
|
+
def test_get_main_branch_local_only(git_repo):
|
|
32
32
|
assert git.get_main_branch(cwd=git_repo) == "main"
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def test_get_main_branch_prefers_remote(git_repo):
|
|
36
|
+
# Add a fake remote ref for origin/main
|
|
37
|
+
subprocess.run(
|
|
38
|
+
["git", "remote", "add", "origin", "https://example.com/repo.git"],
|
|
39
|
+
cwd=git_repo, capture_output=True,
|
|
40
|
+
)
|
|
41
|
+
subprocess.run(
|
|
42
|
+
["git", "update-ref", "refs/remotes/origin/main", "HEAD"],
|
|
43
|
+
cwd=git_repo, capture_output=True,
|
|
44
|
+
)
|
|
45
|
+
assert git.get_main_branch(cwd=git_repo) == "origin/main"
|
|
46
|
+
|
|
47
|
+
|
|
35
48
|
def test_get_unstaged_diff_empty(git_repo):
|
|
36
49
|
diff = git.get_unstaged_diff(cwd=git_repo)
|
|
37
50
|
assert diff == ""
|
|
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
|