8000 chore(remote): added debug helper · arpitjain799/GitPython@dc81244 · GitHub
[go: up one dir, main page]

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

Appearance settings

Commit dc81244

Browse files
committed
chore(remote): added debug helper
Write debug files for stderr output as well as FETCH_INFO into the git repository, e.g. into `.git/` Help with gitpython-developers#301
1 parent cfc70fe commit dc81244

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

git/remote.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ class Remote(LazyMixin, Iterable):
346346
NOTE: When querying configuration, the configuration accessor will be cached
347347
to speed up subsequent accesses."""
348348

349-
__slots__ = ("repo", "name", "_config_reader")
349+
__slots__ = ("repo", "name", "_config_reader", "fetch_no")
350350
_id_attribute_ = "name"
351351

352352
def __init__(self, repo, name):
@@ -356,6 +356,7 @@ def __init__(self, repo, name):
356356
:param name: the name of the remote, i.e. 'origin'"""
357357
self.repo = repo
358358
self.name = name
359+
self.fetch_no = 0
359360

360361
if os.name == 'nt':
361362
# some oddity: on windows, python 2.5, it for some reason does not realize
@@ -551,6 +552,9 @@ def _get_fetch_info_from_stderr(self, proc, progress):
551552
progress_handler = progress.new_message_handler()
552553

553554
def my_progress_handler(line):
555+
stderr_fetch = open(join(self.repo.git_dir, '%03i_debug_git-python_stderr' % self.fetch_no), 'ab')
556+
stderr_fetch.write((line + '\n').encode(defenc))
557+
stderr_fetch.close()
554558
for pline in progress_handler(line):
555559
if line.startswith('fatal:') or line.startswith('error:'):
556560
raise GitCommandError(("Error when fetching: %s" % line,), 2)
@@ -567,6 +571,11 @@ def my_progress_handler(line):
567571
# We are only interested in stderr here ...
568572
handle_process_output(proc, None, my_progress_handler, finalize_process)
569573

574+
import shutil
575+
shutil.copyfile(join(self.repo.git_dir, 'FETCH_HEAD'), join(self.repo.git_dir,
576+
'%03i_debug_git-python_FETCH_HEAD' % self.fetch_no))
577+
self.fetch_no += 1
578+
570579
# read head information
571580
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb')
572581
fetch_head_info = [l.decode(defenc) for l in fp.readlines()]

0 commit comments

Comments
 (0)
0