Add optional check for "Signed-off-by:" tag

Certain projects (such as Coreboot) require a sign-off. Add a check for
the sign-off field which can be enabled per-project.

TEST=Enabled sign-off by check on Coreboot project. Verified that commit
without sign-off was caught by presubmit. Verified that adding sign-off
allowed presubmit pass.

Change-Id: I30e8b8ccc37413c3ea5942e8c4e3e628017b0b63
Reviewed-by: Mike Frysinger <>
Commit-Queue: Shawn Nematbakhsh <>
Tested-by: Shawn Nematbakhsh <>
diff --git a/ b/
index 8a06bdb..ac34055 100755
--- a/
+++ b/
@@ -633,6 +633,16 @@
     return HookFailure(msg)
+def _check_change_has_signoff_field(project, commit):
+  """Check for a non-empty 'Signed-off-by:' field in the commit message."""
+  SIGNOFF_RE = r'\nSigned-off-by: \S+'
+  if not, _get_commit_desc(commit)):
+    msg = ('Changelist description needs Signed-off-by: field\n'
+           'E.g. Signed-off-by: My Name <>')
+    return HookFailure(msg)
 def _run_project_hook_script(script, project, commit):
   """Runs a project hook script.
@@ -722,6 +732,7 @@
     'cros_license_check': _check_license,
     'tab_check': _check_no_tabs,
     'branch_check': _check_change_has_branch_field,
+    'signoff_check': _check_change_has_signoff_field,