gitex 0.2.16__py3-none-any.whl → 0.2.18__py3-none-any.whl

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.
gitex/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.2.16"
1
+ __version__ = "0.2.18"
gitex/main.py CHANGED
@@ -37,8 +37,8 @@ def _filter_nodes(nodes):
37
37
  help="Launch interactive picker to choose files")
38
38
  @click.option("--no-files", is_flag=True,
39
39
  help="Only render the directory tree without file contents.")
40
- @click.option("-c", "--copy", "copy_clipboard", is_flag=True,
41
- help="Copy the final output to clipboard (Linux: wl-copy/xclip/xsel).")
40
+ @click.option("-v", "--verbose", is_flag=True,
41
+ help="Print output to terminal in addition to copying.")
42
42
  @click.option("-d", "--base-dir", default=None,
43
43
  help="Strip this prefix from file paths when rendering file contents.")
44
44
  @click.option("-ds", "--extract-docstrings", "extract_symbol",
@@ -54,7 +54,7 @@ def _filter_nodes(nodes):
54
54
  @click.option("--force", is_flag=True, help="Force execution on non-git directories (caution: may be slow).")
55
55
 
56
56
 
57
- def cli(path, interactive, no_files, copy_clipboard, base_dir, extract_symbol, include_empty_classes, dependency_focus, ignore_gitignore, show_hidden, force):
57
+ def cli(path, interactive, no_files, verbose, base_dir, extract_symbol, include_empty_classes, dependency_focus, ignore_gitignore, show_hidden, force):
58
58
  """
59
59
  Renders a repository's file tree and optional file contents for LLM prompts.
60
60
 
@@ -140,14 +140,13 @@ def cli(path, interactive, no_files, copy_clipboard, base_dir, extract_symbol, i
140
140
 
141
141
  final_output = "".join(out_parts)
142
142
 
143
- if copy_clipboard:
144
- ok = copy_to_clipboard(final_output)
145
- if ok:
146
- click.secho("[Copied to clipboard]", err=True)
147
- else:
148
- click.secho("[Failed to copy to clipboard – install wl-clipboard or xclip or xsel]", fg="yellow", err=True)
143
+ ok = copy_to_clipboard(final_output)
144
+ if ok:
145
+ click.secho("[Copied to clipboard]", err=True)
146
+ if verbose:
149
147
  click.echo(final_output)
150
148
  else:
149
+ click.secho("[Failed to copy to clipboard – install wl-clipboard or xclip or xsel]", fg="yellow", err=True)
151
150
  click.echo(final_output)
152
151
 
153
152
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitex
3
- Version: 0.2.16
3
+ Version: 0.2.18
4
4
  Summary: Terminal tool to prep codebases for LLMs
5
5
  Author-email: zozaai <info@zozaai.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
- gitex/__init__.py,sha256=nS1Qf8CA6pxMzqGCeAMZHTKK2igCSNakZ3o7kDK0JIQ,23
1
+ gitex/__init__.py,sha256=3RGPra41WobAbWeoPRqR_JXeysqFvK3H3AP1g9gjj3g,23
2
2
  gitex/dependency_mapper.py,sha256=alQ_3Bua-VCI-CtwMZH9vJYrLjlLFrYxbuYrydGFiMI,18236
3
3
  gitex/docstring_extractor.py,sha256=glqS3aihTP_FWBS76uB9TAojkH-8Qv9Rgflp75mWzXs,5037
4
- gitex/main.py,sha256=bKpxi3Os3wGN07-RBxnEvEkjpFshK82B8iGgOh6Ogv4,6646
4
+ gitex/main.py,sha256=dvPKfUvQ7rqta9-UDZw265aRzKOhrT4hdIVFmo-aLkQ,6576
5
5
  gitex/models.py,sha256=5saGOUkWz608Q65c0gUrXv3NESzCL1GXftJgDpjQSNc,532
6
6
  gitex/renderer.py,sha256=PPORG5HmGY-OXtGM7c9mswNXvB-OGAXAGEn3Q73GXVc,7196
7
7
  gitex/utils.py,sha256=ivweFCUly8QEqNWV3NtF2fCTEaz3ukjYYt40ROKxkvE,2181
@@ -9,13 +9,13 @@ gitex/picker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  gitex/picker/base.py,sha256=g3XOQBcy7o28ItwThxmqi7Hf_ZIK5KYKTUuFCumb3nA,3240
10
10
  gitex/picker/questionary.py,sha256=eMwn5eHbephpjKP-cGUBSKZNaHaklqbsZFHuWevTYU4,2208
11
11
  gitex/picker/textuals.py,sha256=mXiU4jLd-hCTkdH9Bk3O27UAi3_Mj-9GvdbgUEgZxTA,10393
12
- tests/test_cli.py,sha256=_kOysCaHaTyIUFrj7l-XMC5atY4p5Y9MirWiYw16oN0,3422
13
- tests/test_fences.py,sha256=FY_E4LJ6DVlHcaH8X49LW9SX6zusAJsVuoYr9fOJx2o,4270
12
+ tests/test_cli.py,sha256=T3V6TffCkSQAHlt7m4MYL-V-ADsIe89E2XCR3AktoVs,4987
13
+ tests/test_fences.py,sha256=00tzli0cG8yNxzAUobOj797SBJtTVAwVpbL7b5_nRIM,4313
14
14
  tests/test_render.py,sha256=DaRMPRDfqSteVO4Z6BIkF777V1cpXwnaGYSqbBUU3mk,7223
15
- tests/test_skip_binaries.py,sha256=3GBCpqvTfqOo3qLUQuLLAbiP9k99QIkO6T4czQ8MH7I,1892
15
+ tests/test_skip_binaries.py,sha256=r9izOgpb284y8bN7p_M9-5VixokW0WFA2npmAmxdMLk,1905
16
16
  tests/test_textual.py,sha256=V7zG1hhpAaxEFFWaGCaY2PFDBjfogCnjRD1wGUTXKEU,9887
17
- gitex-0.2.16.dist-info/METADATA,sha256=Y-NSYCWxyX7QK0xuSq_MLQS-znAyV5a3qpTuurxIsQA,4335
18
- gitex-0.2.16.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
19
- gitex-0.2.16.dist-info/entry_points.txt,sha256=YVGHi9Ock94uICcjGxm_eHtwBv3_RCiwpBKwIkMJhGI,41
20
- gitex-0.2.16.dist-info/top_level.txt,sha256=N-r2BJX8y5Wlkh3VtRSBC8jagKMDxFDP9iOwpN1H2do,12
21
- gitex-0.2.16.dist-info/RECORD,,
17
+ gitex-0.2.18.dist-info/METADATA,sha256=hOQIpFjygOyL-E_UZ7ht0x0GQGqGs8MwKC1W2hWF7f4,4335
18
+ gitex-0.2.18.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
19
+ gitex-0.2.18.dist-info/entry_points.txt,sha256=YVGHi9Ock94uICcjGxm_eHtwBv3_RCiwpBKwIkMJhGI,41
20
+ gitex-0.2.18.dist-info/top_level.txt,sha256=N-r2BJX8y5Wlkh3VtRSBC8jagKMDxFDP9iOwpN1H2do,12
21
+ gitex-0.2.18.dist-info/RECORD,,
tests/test_cli.py CHANGED
@@ -2,6 +2,7 @@ import shutil
2
2
  import tempfile
3
3
  import unittest
4
4
  from pathlib import Path
5
+ from unittest.mock import patch
5
6
 
6
7
  from click.testing import CliRunner
7
8
  from git import Repo
@@ -42,11 +43,15 @@ class TestGitExCLI(unittest.TestCase):
42
43
  # Should NOT output the file content to stdout
43
44
  self.assertNotIn("content inside non-git dir", result.stdout)
44
45
 
45
- def test_non_git_repo_force(self):
46
+ @patch("gitex.main.copy_to_clipboard")
47
+ def test_non_git_repo_force(self, mock_copy):
46
48
  """
47
49
  Test that using the --force flag allows gitex to run
48
50
  on a non-git directory.
49
51
  """
52
+ # Simulate copy failure so it prints to stdout by default fallback
53
+ mock_copy.return_value = False
54
+
50
55
  p = Path(self.test_dir) / "forced_file.txt"
51
56
  p.write_text("forced content", encoding="utf-8")
52
57
 
@@ -76,10 +81,14 @@ class TestGitExCLI(unittest.TestCase):
76
81
  self.assertIn("Skipping", result.stderr)
77
82
  self.assertNotIn("secret", result.stdout)
78
83
 
79
- def test_valid_git_repo(self):
84
+ @patch("gitex.main.copy_to_clipboard")
85
+ def test_valid_git_repo(self, mock_copy):
80
86
  """
81
87
  Test that gitex runs automatically on a valid git repository.
82
88
  """
89
+ # Simulate copy failure to ensure output falls back to stdout
90
+ mock_copy.return_value = False
91
+
83
92
  Repo.init(self.test_dir)
84
93
 
85
94
  p = Path(self.test_dir) / "repo_file.py"
@@ -89,6 +98,9 @@ class TestGitExCLI(unittest.TestCase):
89
98
 
90
99
  self.assertEqual(result.exit_code, 0)
91
100
  self.assertNotIn("Skipping", result.stderr)
101
+
102
+ # Verify fallback message
103
+ self.assertIn("Failed to copy", result.stderr)
92
104
 
93
105
  self.assertIn("repo_file.py", result.stdout)
94
106
 
@@ -97,6 +109,34 @@ class TestGitExCLI(unittest.TestCase):
97
109
  self.assertIn("print('hello git')", result.stdout)
98
110
  self.assertIn("```", result.stdout)
99
111
 
112
+ @patch("gitex.main.copy_to_clipboard")
113
+ def test_clipboard_success_silent(self, mock_copy):
114
+ """Test default behavior: copy succeeds, stdout is silent."""
115
+ mock_copy.return_value = True
116
+ Repo.init(self.test_dir)
117
+ p = Path(self.test_dir) / "file.txt"
118
+ p.write_text("data", encoding="utf-8")
119
+
120
+ result = self.runner.invoke(cli, [self.test_dir])
121
+
122
+ self.assertEqual(result.exit_code, 0)
123
+ self.assertIn("[Copied to clipboard]", result.stderr)
124
+ self.assertEqual("", result.stdout)
125
+
126
+ @patch("gitex.main.copy_to_clipboard")
127
+ def test_clipboard_success_verbose(self, mock_copy):
128
+ """Test verbose behavior: copy succeeds, stdout prints content."""
129
+ mock_copy.return_value = True
130
+ Repo.init(self.test_dir)
131
+ p = Path(self.test_dir) / "file.txt"
132
+ p.write_text("data", encoding="utf-8")
133
+
134
+ result = self.runner.invoke(cli, [self.test_dir, "-v"])
135
+
136
+ self.assertEqual(result.exit_code, 0)
137
+ self.assertIn("[Copied to clipboard]", result.stderr)
138
+ self.assertIn("data", result.stdout)
139
+
100
140
  def test_help_short_flag(self):
101
141
  result = self.runner.invoke(cli, ["-h"])
102
142
 
@@ -104,4 +144,4 @@ class TestGitExCLI(unittest.TestCase):
104
144
  self.assertIn("Usage:", result.output)
105
145
 
106
146
  if __name__ == "__main__":
107
- unittest.main()
147
+ unittest.main()
tests/test_fences.py CHANGED
@@ -81,7 +81,7 @@ def repo_dir(tmp_path: Path):
81
81
  def run_gitex(runner: CliRunner, repo_dir: Path):
82
82
  return runner.invoke(
83
83
  cli,
84
- [str(repo_dir)],
84
+ [str(repo_dir), "-v"], # Added -v to force output to stdout
85
85
  catch_exceptions=False, # IMPORTANT
86
86
  )
87
87
 
@@ -167,4 +167,4 @@ def test_language_tags_for_known_files(runner, repo_dir):
167
167
  for fname, lang in expected.items():
168
168
  block = extract_block(result.stdout, fname)
169
169
  first = block.splitlines()[0]
170
- assert first.endswith(lang), f"{fname} expected lang '{lang}', got {first!r}"
170
+ assert first.endswith(lang), f"{fname} expected lang '{lang}', got {first!r}"
@@ -1,4 +1,3 @@
1
- # tests/test_skip_binaries.py
2
1
  import re
3
2
  from pathlib import Path
4
3
 
@@ -35,7 +34,7 @@ def repo_dir(tmp_path: Path):
35
34
  def run_gitex(runner: CliRunner, repo_dir: Path):
36
35
  return runner.invoke(
37
36
  cli,
38
- [str(repo_dir)],
37
+ [str(repo_dir), "-v"], # Added -v to force output to stdout
39
38
  catch_exceptions=False, # IMPORTANT
40
39
  )
41
40
 
@@ -66,4 +65,4 @@ def test_text_file_is_rendered_normally(runner, repo_dir):
66
65
  result = run_gitex(runner, repo_dir)
67
66
  assert result.exit_code == 0
68
67
  assert "# hello.txt\n" in result.stdout
69
- assert "hello\n" in result.stdout
68
+ assert "hello\n" in result.stdout
File without changes