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.
Files changed (25) hide show
  1. {nit_cli-0.4.2 → nit_cli-0.4.3}/PKG-INFO +1 -1
  2. {nit_cli-0.4.2 → nit_cli-0.4.3}/pyproject.toml +1 -1
  3. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/app.py +29 -7
  4. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/git.py +10 -9
  5. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/PKG-INFO +1 -1
  6. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_git.py +14 -1
  7. {nit_cli-0.4.2 → nit_cli-0.4.3}/LICENSE +0 -0
  8. {nit_cli-0.4.2 → nit_cli-0.4.3}/README.md +0 -0
  9. {nit_cli-0.4.2 → nit_cli-0.4.3}/setup.cfg +0 -0
  10. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/__init__.py +0 -0
  11. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/cli.py +0 -0
  12. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/comments.py +0 -0
  13. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/diff_parser.py +0 -0
  14. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/models.py +0 -0
  15. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit/syntax.py +0 -0
  16. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/SOURCES.txt +0 -0
  17. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/dependency_links.txt +0 -0
  18. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/entry_points.txt +0 -0
  19. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/requires.txt +0 -0
  20. {nit_cli-0.4.2 → nit_cli-0.4.3}/src/nit_cli.egg-info/top_level.txt +0 -0
  21. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_app.py +0 -0
  22. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_cli.py +0 -0
  23. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_comments.py +0 -0
  24. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_diff_parser.py +0 -0
  25. {nit_cli-0.4.2 → nit_cli-0.4.3}/tests/test_syntax.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nit-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Terminal diff viewer with inline review comments
5
5
  Author: Joshua Zink-Duda
6
6
  License-Expression: GPL-3.0-only
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nit-cli"
7
- version = "0.4.2"
7
+ version = "0.4.3"
8
8
  description = "Terminal diff viewer with inline review comments"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-only"
@@ -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
- self.query_one("#seg-branch", Label).update(f"⎇ {self.branch}")
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
- if self._file_index < len(self.file_diffs) - 1:
953
- self._file_index += 1
954
- self._select_file(self._file_index)
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
- if self._file_index > 0:
958
- self._file_index -= 1
959
- self._select_file(self._file_index)
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
- result = subprocess.run(
47
- ["git", "rev-parse", "--verify", f"refs/heads/{name}"],
48
- capture_output=True,
49
- text=True,
50
- cwd=cwd,
51
- timeout=GIT_TIMEOUT,
52
- )
53
- if result.returncode == 0:
54
- return name
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nit-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Terminal diff viewer with inline review comments
5
5
  Author: Joshua Zink-Duda
6
6
  License-Expression: GPL-3.0-only
@@ -28,10 +28,23 @@ def test_get_current_branch(git_repo):
28
28
  assert branch == "main"
29
29
 
30
30
 
31
- def test_get_main_branch(git_repo):
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