Agent Wranglers

OSS-9Recommended

Record each contributor's right to submit

Require each contributor to state, for every commit, that they have the right to submit it under the project's licence. Use the Developer Certificate of Origin sign-off or a contributor licence agreement, and check it in CI.

How to do it

Without a record, someone can later claim that code was taken from an employer or another project. The Developer Certificate of Origin 1.1 is a short statement a contributor accepts by adding Signed-off-by: Name <email> to each commit, which git commit -s does. A contributor licence agreement is a signed contract instead. Some agreements hand the copyright to the project, which allows a later licence change, as Changing the licence without every copyright holder's consent explains. Many contributors refuse those, so say why you need one. Accept the record from a bot only for the bot's own commits.

Examples

JavaScript example

import { execFileSync } from 'node:child_process';

const log = execFileSync('git', ['log', '--format=%H%x00%ae%x00%B%x1e', 'origin/main..HEAD'], { encoding: 'utf8' });
const unsigned = log.split('\x1e').filter(entry => entry.trim()).map(entry => entry.trim().split('\0'))
  .filter(([, email, body]) => !body.includes('Signed-off-by:') || !body.includes(`<${email}>`))
  .map(([hash]) => hash.slice(0, 12));
if (unsigned.length) throw new Error(`Commits without a matching sign-off: ${unsigned.join(', ')}`);

Python example

import subprocess

log = subprocess.run(["git", "log", "--format=%H%x00%ae%x00%B%x1e", "origin/main..HEAD"],
                     capture_output=True, text=True, check=True).stdout
entries = [entry.strip().split("\0") for entry in log.split("\x1e") if entry.strip()]
unsigned = [commit[:12] for commit, email, body in entries if "Signed-off-by:" not in body or f"<{email}>" not in body]
assert not unsigned, f"Commits without a matching sign-off: {unsigned}"

How to check

A required CI check fails a pull request with any commit whose message lacks a Signed-off-by: line matching the commit author's email. With a contributor agreement, the check fails for an author who has not signed it.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/open-source/contributions/contributor-sign-off">Agent Wranglers open source maintenance playbook</a>. In code you write, add a comment next to it with the same link.