GitPython을 가지고 뭔가 만들다가 에러를 만났다.
fetch()를 실행하는데, 뭔가가 맞지 않다고 에러라고 하는데... 아무리 살펴봐도 에러가 발생한 상황이 아닌데...
그래서 찾아봤는데 이는 GitPython이 최신 버전의 Git 과의 궁합에서 발생한 에러/버그 상황이다.
https://github.com/gitpython-developers/GitPython/issues/142
해결 방법은 파일 수정이라고 한다.
$ sudo nano /usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/remote.py
...
def _get_fetch_info_from_stderr(self, proc, progress):
# skip first line as it is some remote info we are not interested in
output = IterableList('name')
# lines which are no progress are fetch info lines
# this also waits for the command to finish
# Skip some progress lines that don't provide relevant information
fetch_info_lines = list()
for line in digest_process_messages(proc.stderr, progress):
if line.startswith('From') or line.startswith('remote: Total'):
continue
elif line.startswith('warning:'):
print >> sys.stderr, line
continue
...
def _get_fetch_info_from_stderr(self, proc, progress):
# skip first line as it is some remote info we are not interested in
output = IterableList('name')
# lines which are no progress are fetch info lines
# this also waits for the command to finish
# Skip some progress lines that don't provide relevant information
fetch_info_lines = list()
for line in digest_process_messages(proc.stderr, progress):
if line.startswith('From') or line.startswith('remote: Total'):
continue
elif line.startswith('warning:'):
print >> sys.stderr, line
continue
...
위와 같은 코드를 아래와 같이 변경하면 된다고 한다.
...
def _get_fetch_info_from_stderr(self, proc, progress):
# skip first line as it is some remote info we are not interested in
output = IterableList('name')
# lines which are no progress are fetch info lines
# this also waits for the command to finish
# Skip some progress lines that don't provide relevant information
fetch_info_lines = list()
for line in digest_process_messages(proc.stderr, progress):
#if line.startswith('From') or line.startswith('remote: Total'):
if line.startswith('From') or line.startswith('remote: Total') \
or line.startswith('POST') or line.startswith(' ='):
continue
elif line.startswith('warning:'):
print >> sys.stderr, line
continue
...
def _get_fetch_info_from_stderr(self, proc, progress):
# skip first line as it is some remote info we are not interested in
output = IterableList('name')
# lines which are no progress are fetch info lines
# this also waits for the command to finish
# Skip some progress lines that don't provide relevant information
fetch_info_lines = list()
for line in digest_process_messages(proc.stderr, progress):
#if line.startswith('From') or line.startswith('remote: Total'):
if line.startswith('From') or line.startswith('remote: Total') \
or line.startswith('POST') or line.startswith(' ='):
continue
elif line.startswith('warning:'):
print >> sys.stderr, line
continue
...
그런데, 위와 같이 하여도 에러는 여전하였다.
Git을 다룬다는 것 자체도 좀 마이너하고, 특히나 GitPython을 다루는 분들이 많지 않고...
자료를 찾기가 너무 어려워서 다시 원점으로 돌아가서 현재 개발중인 코드를 살펴보다가 답을 찾았다.
...
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'),'r')
fetch_head_info = fp.readlines()
fp.close()
assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info))
finalize_process(proc)
return output
...
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'),'r')
fetch_head_info = fp.readlines()
fp.close()
assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info))
finalize_process(proc)
return output
...
에러메시지를 출력하는 부분이 위와 같이 있는데, 그냥 확 주석처리해버리면 된다.
...
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'),'r')
fetch_head_info = fp.readlines()
fp.close()
# NOTE: HACK Just disabling this line will make github repositories work much better.
# I simply couldn't stand it anymore, so here is the quick and dirty fix ... .
# This project needs a lot of work !
# assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info))
...
# read head information
fp = open(join(self.repo.git_dir, 'FETCH_HEAD'),'r')
fetch_head_info = fp.readlines()
fp.close()
# NOTE: HACK Just disabling this line will make github repositories work much better.
# I simply couldn't stand it anymore, so here is the quick and dirty fix ... .
# This project needs a lot of work !
# assert len(fetch_info_lines) == len(fetch_head_info), "len(%s) != len(%s)" % (fetch_head_info, fetch_info_lines)
output.extend(FetchInfo._from_line(self.repo, err_line, fetch_line)
for err_line,fetch_line in zip(fetch_info_lines, fetch_head_info))
...
프로젝트 담당자도 인정했다시피 이렇게 주석처리하는 것이 정석은 아니다.
여력이 되시는 분은 이 부분에 대해서 도움을 주면 좋을 것 같다.
뭐 여하튼... 문제 해결!!!
반응형
'Programming > Python' 카테고리의 다른 글
카카오톡 봇 만들어보기 (with Python) (2) | 2018.10.28 |
---|---|
삼성 링크 / AllShare .mta 파일 삭제하기 (0) | 2014.08.17 |
윈도우즈 환경에서 파이썬 실행하기 (0) | 2014.08.17 |
Python으로 Git을 다뤄보자. (Ubuntu 14.04 LTS 64bit, GitPython 0.3.2 RC1) (2) | 2014.07.04 |
나는 누군가 또 여긴 어딘가 ? [ path ] (1) | 2013.05.08 |