1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/hack/travis/dco.py
Tianon Gravi a4f3cd62a3 Update Travis to check for new 1.1 DCO version
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
2014-01-09 09:52:17 -07:00

49 lines
1.3 KiB
Python
Executable file

#!/usr/bin/env python
import re
import subprocess
import yaml
from env import commit_range
commit_format = '-%n hash: "%h"%n author: %aN <%aE>%n message: |%n%w(0,2,2)%B'
gitlog = subprocess.check_output([
'git', 'log', '--reverse',
'--format=format:'+commit_format,
'..'.join(commit_range), '--',
])
commits = yaml.load(gitlog)
if not commits:
exit(0) # what? how can we have no commits?
DCO = 'Docker-DCO-1.1-Signed-off-by:'
p = re.compile(r'^{0} ([^<]+) <([^<>@]+@[^<>]+)> \(github: (\S+)\)$'.format(re.escape(DCO)), re.MULTILINE|re.UNICODE)
failed_commits = 0
for commit in commits:
commit['stat'] = subprocess.check_output([
'git', 'log', '--format=format:', '--max-count=1',
'--name-status', commit['hash'], '--',
])
if commit['stat'] == '':
print 'Commit {0} has no actual changed content, skipping.'.format(commit['hash'])
continue
m = p.search(commit['message'])
if not m:
print 'Commit {1} does not have a properly formatted "{0}" marker.'.format(DCO, commit['hash'])
failed_commits += 1
continue # print ALL the commits that don't have a proper DCO
(name, email, github) = m.groups()
# TODO verify that "github" is the person who actually made this commit via the GitHub API
if failed_commits > 0:
exit(failed_commits)
print 'All commits have a valid "{0}" marker.'.format(DCO)
exit(0)