2018-05-06 21:58:06 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2012-01-14 15:12:45 +00:00
|
|
|
# Copyright (c) 2011 The Chromium OS Authors.
|
|
|
|
#
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
# Separates a tag: at the beginning of the subject from the rest of it
|
2013-03-26 13:09:40 +00:00
|
|
|
re_subject_tag = re.compile('([^:\s]*):\s*(.*)')
|
2012-01-14 15:12:45 +00:00
|
|
|
|
|
|
|
class Commit:
|
|
|
|
"""Holds information about a single commit/patch in the series.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
hash: Commit hash (as a string)
|
|
|
|
|
|
|
|
Variables:
|
|
|
|
hash: Commit hash
|
|
|
|
subject: Subject line
|
|
|
|
tags: List of maintainer tag strings
|
|
|
|
changes: Dict containing a list of changes (single line strings).
|
|
|
|
The dict is indexed by change version (an integer)
|
|
|
|
cc_list: List of people to aliases/emails to cc on this commit
|
2013-11-12 10:14:41 +00:00
|
|
|
notes: List of lines in the commit (not series) notes
|
2019-09-27 16:23:56 +00:00
|
|
|
change_id: the Change-Id: tag that was stripped from this commit
|
|
|
|
and can be used to generate the Message-Id.
|
2012-01-14 15:12:45 +00:00
|
|
|
"""
|
|
|
|
def __init__(self, hash):
|
|
|
|
self.hash = hash
|
|
|
|
self.subject = None
|
|
|
|
self.tags = []
|
|
|
|
self.changes = {}
|
|
|
|
self.cc_list = []
|
2014-04-20 16:50:14 +00:00
|
|
|
self.signoff_set = set()
|
2013-11-12 10:14:41 +00:00
|
|
|
self.notes = []
|
2019-09-27 16:23:56 +00:00
|
|
|
self.change_id = None
|
2012-01-14 15:12:45 +00:00
|
|
|
|
|
|
|
def AddChange(self, version, info):
|
|
|
|
"""Add a new change line to the change list for a version.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
version: Patch set version (integer: 1, 2, 3)
|
|
|
|
info: Description of change in this version
|
|
|
|
"""
|
|
|
|
if not self.changes.get(version):
|
|
|
|
self.changes[version] = []
|
|
|
|
self.changes[version].append(info)
|
|
|
|
|
|
|
|
def CheckTags(self):
|
|
|
|
"""Create a list of subject tags in the commit
|
|
|
|
|
|
|
|
Subject tags look like this:
|
|
|
|
|
2013-03-26 13:09:41 +00:00
|
|
|
propounder: fort: Change the widget to propound correctly
|
2012-01-14 15:12:45 +00:00
|
|
|
|
2013-03-26 13:09:41 +00:00
|
|
|
Here the tags are propounder and fort. Multiple tags are supported.
|
|
|
|
The list is updated in self.tag.
|
2012-01-14 15:12:45 +00:00
|
|
|
|
|
|
|
Returns:
|
|
|
|
None if ok, else the name of a tag with no email alias
|
|
|
|
"""
|
|
|
|
str = self.subject
|
|
|
|
m = True
|
|
|
|
while m:
|
|
|
|
m = re_subject_tag.match(str)
|
|
|
|
if m:
|
|
|
|
tag = m.group(1)
|
|
|
|
self.tags.append(tag)
|
|
|
|
str = m.group(2)
|
|
|
|
return None
|
|
|
|
|
|
|
|
def AddCc(self, cc_list):
|
|
|
|
"""Add a list of people to Cc when we send this patch.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
cc_list: List of aliases or email addresses
|
|
|
|
"""
|
|
|
|
self.cc_list += cc_list
|
2014-04-20 16:50:14 +00:00
|
|
|
|
|
|
|
def CheckDuplicateSignoff(self, signoff):
|
|
|
|
"""Check a list of signoffs we have send for this patch
|
|
|
|
|
|
|
|
Args:
|
|
|
|
signoff: Signoff line
|
|
|
|
Returns:
|
|
|
|
True if this signoff is new, False if we have already seen it.
|
|
|
|
"""
|
|
|
|
if signoff in self.signoff_set:
|
|
|
|
return False
|
|
|
|
self.signoff_set.add(signoff)
|
|
|
|
return True
|