Simplify the matching of the last line
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
parent
7fa3eb7d44
commit
13dc634282
1 changed files with 7 additions and 5 deletions
|
@ -261,12 +261,14 @@ class EntryFileSortKey:
|
||||||
Return None if the file was never checked into git.
|
Return None if the file was never checked into git.
|
||||||
"""
|
"""
|
||||||
hashes = subprocess.check_output(['git', 'log', '--format=%H', '--', filename])
|
hashes = subprocess.check_output(['git', 'log', '--format=%H', '--', filename])
|
||||||
if not hashes:
|
m = re.search(b'(.+)$', hashes)
|
||||||
# The file was never checked in.
|
if not m:
|
||||||
|
# The git output is empty. This means that the file was
|
||||||
|
# never checked in.
|
||||||
return None
|
return None
|
||||||
hashes = hashes.rstrip(b'\n')
|
# The last commit in the log is the oldest one, which is when the
|
||||||
last_hash = hashes[hashes.rfind(b'\n')+1:]
|
# file was created.
|
||||||
return last_hash
|
return m.group(0)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_merges(some_hash, target, *options):
|
def list_merges(some_hash, target, *options):
|
||||||
|
|
Loading…
Reference in a new issue