diff options
author | Sebastian Thiel <sebastian.thiel@icloud.com> | 2019-10-29 08:31:39 +0100 |
---|---|---|
committer | Sebastian Thiel <sebastian.thiel@icloud.com> | 2019-10-29 08:31:39 +0100 |
commit | 52ee6c19423297b4c667d34ed1bd621dafaabb0e (patch) | |
tree | 5ac04998b1f5b0fba24297e97f5592c74b617688 /git/refs/log.py | |
parent | 553500a3447667aaa9bd3b922742575562c03b68 (diff) | |
parent | 9932e647aaaaf6edd3a407b75edd08a96132ef5c (diff) | |
download | gitpython-52ee6c19423297b4c667d34ed1bd621dafaabb0e.tar.gz |
Merge branch 'fix/deepsource-issues' of https://github.com/imkaka/GitPython into imkaka-fix/deepsource-issues
Diffstat (limited to 'git/refs/log.py')
-rw-r--r-- | git/refs/log.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/git/refs/log.py b/git/refs/log.py index e8c2d7ad..432232ac 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -84,7 +84,7 @@ class RefLogEntry(tuple): return self[4] @classmethod - def new(self, oldhexsha, newhexsha, actor, time, tz_offset, message): + def new(cls, oldhexsha, newhexsha, actor, time, tz_offset, message): # skipcq: PYL-W0621 """:return: New instance of a RefLogEntry""" if not isinstance(actor, Actor): raise ValueError("Need actor instance, got %s" % actor) @@ -121,7 +121,7 @@ class RefLogEntry(tuple): # END handle missing end brace actor = Actor._from_string(info[82:email_end + 1]) - time, tz_offset = parse_date(info[email_end + 2:]) + time, tz_offset = parse_date(info[email_end + 2:]) # skipcq: PYL-W0621 return RefLogEntry((oldhexsha, newhexsha, actor, (time, tz_offset), msg)) @@ -216,10 +216,9 @@ class RefLog(list, Serializable): all other lines. Nonetheless, the whole file has to be read if the index is negative """ - fp = open(filepath, 'rb') - if index < 0: - return RefLogEntry.from_line(fp.readlines()[index].strip()) - else: + with open(filepath, 'rb') as fp: + if index < 0: + return RefLogEntry.from_line(fp.readlines()[index].strip()) # read until index is reached for i in xrange(index + 1): line = fp.readline() @@ -228,7 +227,7 @@ class RefLog(list, Serializable): # END abort on eof # END handle runup - if i != index or not line: + if i != index or not line: # skipcq:PYL-W0631 raise IndexError # END handle exception |