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

Commit863a40e

Browse files
committed
Reduced hackyness of remote reference parsing.
This could however, introduce a chance of an assertion hitting once againas it has been commented out for quite a long time. Now it's back in a changed formthough, and once again tries to make sure we get proper results
1 parentde9a6bb commit863a40e

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

‎doc/source/changes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Changelog
33
=========
44

5+
0.3.3
6+
=====
7+
* When fetching, pulling or pushing, and an error occours, it will not be reported on stdout anymore. However, if there is a fatal error, it will still result in a GitCommandError to be thrown. This goes hand in hand with improved fetch result parsing.
8+
59
0.3.2.1
610
=======
711
* `Fix for #207<https://github.com/gitpython-developers/GitPython/issues/207>`_

‎git/remote.py

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ class PushInfo(object):
100100
NEW_TAG,NEW_HEAD,NO_MATCH,REJECTED,REMOTE_REJECTED,REMOTE_FAILURE,DELETED, \
101101
FORCED_UPDATE,FAST_FORWARD,UP_TO_DATE,ERROR= [1<<xforxinrange(11)]
102102

103-
_flag_map= {'X':NO_MATCH,'-':DELETED,'*':0,
104-
'+':FORCED_UPDATE,' ':FAST_FORWARD,
105-
'=':UP_TO_DATE,'!':ERROR}
103+
_flag_map= {'X':NO_MATCH,
104+
'-':DELETED,
105+
'*':0,
106+
'+':FORCED_UPDATE,
107+
' ':FAST_FORWARD,
108+
'=':UP_TO_DATE,
109+
'!':ERROR}
106110

107111
def__init__(self,flags,local_ref,remote_ref_string,remote,old_commit=None,
108112
summary=''):
@@ -299,6 +303,8 @@ def _from_line(cls, repo, line, fetch_line):
299303
ifremote_local_ref=="FETCH_HEAD":
300304
ref_type=SymbolicReference
301305
elifref_type_name=="tag"oris_tag_operation:
306+
# the ref_type_name can be branch, whereas we are still seeing a tag operation. It happens during
307+
# testing, which is based on actual git operations
302308
ref_type=TagReference
303309
elifref_type_namein ("remote-tracking","branch"):
304310
# note: remote-tracking is just the first part of the 'remote-tracking branch' token.
@@ -520,43 +526,29 @@ def _get_fetch_info_from_stderr(self, proc, progress):
520526
# this also waits for the command to finish
521527
# Skip some progress lines that don't provide relevant information
522528
fetch_info_lines=list()
523-
# fetches all for later in case we don't get any ... this handling is a bit fishy as
524-
# the underlying logic of git is not properly understood. This fix merely helps a test-case, and probably
525-
# won't be too wrong otherwise.
526-
fetch_info_lines_reserve=list()
529+
# Basically we want all fetch info lines which appear to be in regular form, and thus have a
530+
# command character. Everything else we ignore,
531+
cmds=set(PushInfo._flag_map.keys())&set(FetchInfo._flag_map.keys())
527532
forlineindigest_process_messages(proc.stderr,progress):
528-
# cc, _, _ = line.split('\t', 3)
529-
ifline.startswith('From')orline.startswith('remote: Total')orline.startswith('POST') \
530-
orline.startswith(' ='):
531-
# Why do we even skip lines that begin with a = ?
532-
ifline.startswith(' ='):
533-
fetch_info_lines_reserve.append(line)
534-
continue
535-
elifline.startswith('warning:'):
536-
print>>sys.stderr,line
537-
continue
538-
elifline.startswith('fatal:'):
533+
ifline.startswith('fatal:'):
539534
raiseGitCommandError(("Error when fetching: %s"%line,),2)
540535
# END handle special messages
541-
fetch_info_lines.append(line)
536+
forcmdincmds:
537+
ifline[1]==cmd:
538+
fetch_info_lines.append(line)
539+
continue
540+
# end find command code
541+
# end for each comand code we know
542542
# END for each line
543543

544544
# read head information
545545
fp=open(join(self.repo.git_dir,'FETCH_HEAD'),'r')
546546
fetch_head_info=fp.readlines()
547547
fp.close()
548548

549-
# NOTE: HACK Just disabling this line will make github repositories work much better.
550-
# I simply couldn't stand it anymore, so here is the quick and dirty fix ... .
551-
# This project needs a lot of work !
552-
# assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
553-
554-
# EVIL HACK: This basically fixes our test-case, and possibly helps better results to be returned in future
555-
# The actual question is why we are unable to properly parse progress messages and sync them to the
556-
# respective fetch-head information ... .
557-
iflen(fetch_info_lines)!=len(fetch_head_info)andlen(fetch_info_lines_reserve)==len(fetch_head_info):
558-
fetch_info_lines=fetch_info_lines_reserve
559-
# end
549+
# NOTE: We assume to fetch at least enough progress lines to allow matching each fetch head line with it.
550+
assertlen(fetch_info_lines)>=len(fetch_head_info),"len(%s) <= len(%s)"% (fetch_head_info,
551+
fetch_info_lines)
560552

561553
output.extend(FetchInfo._from_line(self.repo,err_line,fetch_line)
562554
forerr_line,fetch_lineinzip(fetch_info_lines,fetch_head_info))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp