| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 855befa commit a943fa3
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1210,6 +1210,13 @@ def execute( | |||
| 1210 | 1210 | if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != "full" or as_process): | |
| 1211 | 1211 | _logger.info(" ".join(redacted_command)) | |
| 1212 | 1212 | ||
| 1213 | + if strip_newline_in_stdout and command[:2] == ["git", "show"]: | ||
| 1214 | + warnings.warn( | ||
| 1215 | + "Git.show() has strip_newline_in_stdout=True by default, which probably isn't what you want and will " | ||
| 1216 | + "change in a future version. It is recommended to use Git.show(..., strip_newline_in_stdout=False)", | ||
| 1217 | + DeprecationWarning | ||
| 1218 | + ) | ||
| 1219 | + | ||
| 1213 | 1220 | # Allow the user to have the command executed in their working dir. | |
| 1214 | 1221 | try: | |
| 1215 | 1222 | cwd = self._working_dir or os.getcwd() # type: Union[None, str] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1377,13 +1377,23 @@ def test_rebasing(self, rw_dir): | |||
| 1377 | 1377 | ||
| 1378 | 1378 | @with_rw_directory | |
| 1379 | 1379 | def test_do_not_strip_newline_in_stdout(self, rw_dir): | |
| 1380 | + r = self.create_repo_commit_hello_newline(rw_dir) | ||
| 1381 | + self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n") | ||
| 1382 | + | ||
| 1383 | + def create_repo_commit_hello_newline(self, rw_dir): | ||
| 1380 | 1384 | r = Repo.init(rw_dir) | |
| 1381 | 1385 | fp = osp.join(rw_dir, "hello.txt") | |
| 1382 | 1386 | with open(fp, "w") as fs: | |
| 1383 | 1387 | fs.write("hello\n") | |
| 1384 | 1388 | r.git.add(Git.polish_url(fp)) | |
| 1385 | 1389 | r.git.commit(message="init") | |
| 1386 | - self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n") | ||
| 1390 | + return r | ||
| 1391 | + | ||
| 1392 | + @with_rw_directory | ||
| 1393 | + def test_warn_when_strip_newline_in_stdout(self, rw_dir): | ||
| 1394 | + r = self.create_repo_commit_hello_newline(rw_dir) | ||
| 1395 | + with pytest.warns(DeprecationWarning): | ||
| 1396 | + self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=True), "hello") | ||
| 1387 | 1397 | ||
| 1388 | 1398 | @pytest.mark.xfail( | |
| 1389 | 1399 | sys.platform == "win32", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments