This only works on git repositories.
Change-Id: I45a0a66dfaaf517cdc5d85fc15f60e403bccfeb9
Co-Authored-By: Eric Ball <eball@linuxfoundation.org>
Co-Authored-By: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Jeremy Phelps <jphelps@linuxfoundation.org>
--- /dev/null
+****
+Dco
+****
+
+.. program-output:: lftools dco --help
+
+Commands
+========
+
+.. contents:: Check Commands
+ :local:
+
+check
+---------
+
+.. program-output:: lftools dco check --help
+ List of git shas that are missing DCO (Signed-off-by line).
+
config
deploy
+ dco
license
nexus
openstack
import click
from lftools.cli.config import config_sys
+from lftools.cli.dco import dco
from lftools.cli.deploy import deploy
from lftools.cli.jenkins import jenkins_cli
from lftools.cli.license import license
cli.add_command(config_sys)
cli.add_command(deploy)
+cli.add_command(dco)
cli.add_command(jenkins_cli, name='jenkins')
cli.add_command(license)
cli.add_command(nexus)
--- /dev/null
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+"""Script to check a git repository for commits missing DCO."""
+
+import subprocess
+import sys
+
+import click
+
+
+@click.group()
+@click.pass_context
+def dco(ctx):
+ """Check repository for commits missing DCO."""
+ pass
+
+
+@click.command()
+@click.argument('repo-path', required=False)
+@click.pass_context
+def check(ctx, repo_path):
+ """Check repository for commits missing DCO.
+
+ This check will exclude merge commits and empty commits.
+ It operates in your current working directory which has to
+ be a git repository. Alternatively, you can opt to pass in the
+ path to a git repo.
+ Refer to https://developercertificate.org/
+ """
+ if not repo_path:
+ repo_path = "."
+ status = subprocess.call(['dco', repo_path])
+ sys.exit(status)
+
+
+dco.add_command(check)
lftools=lftools.cli:main
''',
scripts=[
+ 'shell/dco',
'shell/deploy',
'shell/sign',
- 'shell/version',
+ 'shell/version'
],
data_files=[('etc', ['etc/logging.ini'])],
)
--- /dev/null
+#!/bin/bash
+# SPDX-License-Identifier: EPL-1.0
+##############################################################################
+# Copyright (c) 2018 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+# This script determines if a git repo contains commits missing DCO.
+# It operates in your current working directory which must be a git repo.
+# Alternatively you can pass it a path to a git repo.
+
+REPO_PATH="$1"
+
+cd $REPO_PATH || exit 1
+
+status=0
+while IFS= read -a line; do
+ my_array+=( "$line" )
+ done < <( git branch -r | grep -v origin/HEAD )
+for branch in "${my_array[@]}"
+do
+ status=1
+ branch=$(echo "$branch" | xargs)
+ echo "Checking commits in branch $branch for commits missing DCO..."
+ git log $branch --no-merges --pretty="%H" --grep 'Signed-off-by' --invert-grep * | \
+ while read commit_hash; do
+ echo "ERROR: Commit $commit_hash is missing Signed-off-by line."
+ done
+done
+exit $status