+from __future__ import print_function
from subprocess import check_output
import os
-from os.path import dirname
import shlex
import re
-from itertools import ifilterfalse
+from os.path import dirname
+try:
+ from itertools import filterfalse
+except ImportError:
+ from itertools import ifilterfalse as filterfalse
import pytest
target_branch = os.getenv('ghprbTargetBranch', 'master')
source_branch = 'HEAD'
- workspace = os.getenv('WORKSPACE') or dirname(dirname(dirname(dirname(os.path.abspath(__file__)))))
+ workspace = os.getenv('WORKSPACE') or dirname(
+ dirname(dirname(dirname(os.path.abspath(__file__)))))
ceph_checkout = os.path.join(workspace, 'ceph')
@classmethod
def command(cls, command):
- print "Running command: %s" % (command,)
- return check_output(shlex.split(command), cwd=cls.ceph_checkout)
+ print("Running command:", command)
+ return check_output(shlex.split(command), cwd=cls.ceph_checkout).decode()
@classmethod
def setup_class(cls):
signed_off_regex = r'Signed-off-by: \S.* <[^@]+@[^@]+\.[^@]+>'
# '-z' puts a '\0' between commits, see later split('\0')
check_signed_off_commits = 'git log -z --no-merges origin/%s..%s' % (
- self.target_branch, self.source_branch)
- wrong_commits = list(ifilterfalse(
- re.compile(signed_off_regex).search,
- self.command(check_signed_off_commits).split('\0')))
+ self.target_branch, self.source_branch)
+ wrong_commits = list(filterfalse(
+ re.compile(signed_off_regex).search,
+ self.command(check_signed_off_commits).split('\0')))
if wrong_commits:
raise AssertionError("\n".join([
"Following commit/s is/are not signed, please make sure all TestCommits",
"are signed following the 'Submitting Patches' guide:",
"https://github.com/ceph/ceph/blob/master/SubmittingPatches.rst#1-sign-your-work",
- ""] +
+ ""] +
wrong_commits
- )
- )
-
+ ))