Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita943fa3

Browse files
committed
deprecation warning for Git.show() w/o string_newline=False
1 parent855befa commita943fa3

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

‎git/cmd.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,13 @@ def execute(
12101210
ifself.GIT_PYTHON_TRACEand (self.GIT_PYTHON_TRACE!="full"oras_process):
12111211
_logger.info(" ".join(redacted_command))
12121212

1213+
ifstrip_newline_in_stdoutandcommand[: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+
12131220
# Allow the user to have the command executed in their working dir.
12141221
try:
12151222
cwd=self._working_diroros.getcwd()# type: Union[None, str]

‎test/test_repo.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1377,13 +1377,23 @@ def test_rebasing(self, rw_dir):
13771377

13781378
@with_rw_directory
13791379
deftest_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+
defcreate_repo_commit_hello_newline(self,rw_dir):
13801384
r=Repo.init(rw_dir)
13811385
fp=osp.join(rw_dir,"hello.txt")
13821386
withopen(fp,"w")asfs:
13831387
fs.write("hello\n")
13841388
r.git.add(Git.polish_url(fp))
13851389
r.git.commit(message="init")
1386-
self.assertEqual(r.git.show("HEAD:hello.txt",strip_newline_in_stdout=False),"hello\n")
1390+
returnr
1391+
1392+
@with_rw_directory
1393+
deftest_warn_when_strip_newline_in_stdout(self,rw_dir):
1394+
r=self.create_repo_commit_hello_newline(rw_dir)
1395+
withpytest.warns(DeprecationWarning):
1396+
self.assertEqual(r.git.show("HEAD:hello.txt",strip_newline_in_stdout=True),"hello")
13871397

13881398
@pytest.mark.xfail(
13891399
sys.platform=="win32",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp