Commit e62f905e1cbe55efd7438d4ef6c5d349373f2314
1 parent
dc191505b9
Exists in
master
and in
53 other branches
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>
Showing 1 changed file with 29 additions and 7 deletions Side-by-side Diff
tools/patman/patchstream.py
... | ... | @@ -237,7 +237,8 @@ |
237 | 237 | # Detect the start of a new commit |
238 | 238 | elif commit_match: |
239 | 239 | self.CloseCommit() |
240 | - self.commit = commit.Commit(commit_match.group(1)[:7]) | |
240 | + # TODO: We should store the whole hash, and just display a subset | |
241 | + self.commit = commit.Commit(commit_match.group(1)[:8]) | |
241 | 242 | |
242 | 243 | # Detect tags in the commit message |
243 | 244 | elif tag_match: |
244 | 245 | |
245 | 246 | |
246 | 247 | |
247 | 248 | |
... | ... | @@ -334,25 +335,46 @@ |
334 | 335 | self.Finalize() |
335 | 336 | |
336 | 337 | |
337 | -def GetMetaData(start, count): | |
338 | +def GetMetaDataForList(commit_range, git_dir=None, count=None, | |
339 | + series = Series()): | |
338 | 340 | """Reads out patch series metadata from the commits |
339 | 341 | |
340 | 342 | This does a 'git log' on the relevant commits and pulls out the tags we |
341 | 343 | are interested in. |
342 | 344 | |
343 | 345 | Args: |
344 | - start: Commit to start from: 0=HEAD, 1=next one, etc. | |
345 | - count: Number of commits to list | |
346 | + commit_range: Range of commits to count (e.g. 'HEAD..base') | |
347 | + git_dir: Path to git repositiory (None to use default) | |
348 | + count: Number of commits to list, or None for no limit | |
349 | + series: Series object to add information into. By default a new series | |
350 | + is started. | |
351 | + Returns: | |
352 | + A Series object containing information about the commits. | |
346 | 353 | """ |
347 | - pipe = [['git', 'log', '--no-color', '--reverse', 'HEAD~%d' % start, | |
348 | - '-n%d' % count]] | |
354 | + params = ['git', 'log', '--no-color', '--reverse', commit_range] | |
355 | + if count is not None: | |
356 | + params[2:2] = ['-n%d' % count] | |
357 | + if git_dir: | |
358 | + params[1:1] = ['--git-dir', git_dir] | |
359 | + pipe = [params] | |
349 | 360 | stdout = command.RunPipe(pipe, capture=True).stdout |
350 | - series = Series() | |
351 | 361 | ps = PatchStream(series, is_log=True) |
352 | 362 | for line in stdout.splitlines(): |
353 | 363 | ps.ProcessLine(line) |
354 | 364 | ps.Finalize() |
355 | 365 | return series |
366 | + | |
367 | +def GetMetaData(start, count): | |
368 | + """Reads out patch series metadata from the commits | |
369 | + | |
370 | + This does a 'git log' on the relevant commits and pulls out the tags we | |
371 | + are interested in. | |
372 | + | |
373 | + Args: | |
374 | + start: Commit to start from: 0=HEAD, 1=next one, etc. | |
375 | + count: Number of commits to list | |
376 | + """ | |
377 | + return GetMetaDataForList('HEAD~%d' % start, None, count) | |
356 | 378 | |
357 | 379 | def FixPatch(backup_dir, fname, series, commit): |
358 | 380 | """Fix up a patch file, by adding/removing as required. |