mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 09:12:08 +02:00
patman: Allow reading metadata from a list of commits
We normally read from the current branch, but buildman will need to look at commits from another branch. Allow the metadata to be read from any list of commits, to provide this flexibility. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -237,7 +237,8 @@ class PatchStream:
|
|||||||
# Detect the start of a new commit
|
# Detect the start of a new commit
|
||||||
elif commit_match:
|
elif commit_match:
|
||||||
self.CloseCommit()
|
self.CloseCommit()
|
||||||
self.commit = commit.Commit(commit_match.group(1)[:7])
|
# TODO: We should store the whole hash, and just display a subset
|
||||||
|
self.commit = commit.Commit(commit_match.group(1)[:8])
|
||||||
|
|
||||||
# Detect tags in the commit message
|
# Detect tags in the commit message
|
||||||
elif tag_match:
|
elif tag_match:
|
||||||
@@ -334,6 +335,35 @@ class PatchStream:
|
|||||||
self.Finalize()
|
self.Finalize()
|
||||||
|
|
||||||
|
|
||||||
|
def GetMetaDataForList(commit_range, git_dir=None, count=None,
|
||||||
|
series = Series()):
|
||||||
|
"""Reads out patch series metadata from the commits
|
||||||
|
|
||||||
|
This does a 'git log' on the relevant commits and pulls out the tags we
|
||||||
|
are interested in.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
commit_range: Range of commits to count (e.g. 'HEAD..base')
|
||||||
|
git_dir: Path to git repositiory (None to use default)
|
||||||
|
count: Number of commits to list, or None for no limit
|
||||||
|
series: Series object to add information into. By default a new series
|
||||||
|
is started.
|
||||||
|
Returns:
|
||||||
|
A Series object containing information about the commits.
|
||||||
|
"""
|
||||||
|
params = ['git', 'log', '--no-color', '--reverse', commit_range]
|
||||||
|
if count is not None:
|
||||||
|
params[2:2] = ['-n%d' % count]
|
||||||
|
if git_dir:
|
||||||
|
params[1:1] = ['--git-dir', git_dir]
|
||||||
|
pipe = [params]
|
||||||
|
stdout = command.RunPipe(pipe, capture=True).stdout
|
||||||
|
ps = PatchStream(series, is_log=True)
|
||||||
|
for line in stdout.splitlines():
|
||||||
|
ps.ProcessLine(line)
|
||||||
|
ps.Finalize()
|
||||||
|
return series
|
||||||
|
|
||||||
def GetMetaData(start, count):
|
def GetMetaData(start, count):
|
||||||
"""Reads out patch series metadata from the commits
|
"""Reads out patch series metadata from the commits
|
||||||
|
|
||||||
@@ -344,15 +374,7 @@ def GetMetaData(start, count):
|
|||||||
start: Commit to start from: 0=HEAD, 1=next one, etc.
|
start: Commit to start from: 0=HEAD, 1=next one, etc.
|
||||||
count: Number of commits to list
|
count: Number of commits to list
|
||||||
"""
|
"""
|
||||||
pipe = [['git', 'log', '--no-color', '--reverse', 'HEAD~%d' % start,
|
return GetMetaDataForList('HEAD~%d' % start, None, count)
|
||||||
'-n%d' % count]]
|
|
||||||
stdout = command.RunPipe(pipe, capture=True).stdout
|
|
||||||
series = Series()
|
|
||||||
ps = PatchStream(series, is_log=True)
|
|
||||||
for line in stdout.splitlines():
|
|
||||||
ps.ProcessLine(line)
|
|
||||||
ps.Finalize()
|
|
||||||
return series
|
|
||||||
|
|
||||||
def FixPatch(backup_dir, fname, series, commit):
|
def FixPatch(backup_dir, fname, series, commit):
|
||||||
"""Fix up a patch file, by adding/removing as required.
|
"""Fix up a patch file, by adding/removing as required.
|
||||||
|
Reference in New Issue
Block a user