Skip to content

Commit 0842965

Browse files
committed
pkgdev commit: make sign-off off by default
Make sign-off off by default, and enable the user to pass if manually using `--signoff`, or by setting `commit.signoff` in config file. Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent f7b90de commit 0842965

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

doc/man/config.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ related values. To find all possible configuration options, run:
3333
[gentoo]
3434
push.ask = true
3535

36+
- Sign off all commits for the 'gentoo' repository::
37+
38+
[gentoo]
39+
push.signoff = true
40+
3641
- When committing, stage all files in current working directory (note that this
3742
option doesn't expect value, therefore no value is defined post equal sign)::
3843

src/pkgdev/scripts/pkgdev_commit.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ def parse_known_args(self, args=None, namespace=None):
4343
args.append('--dry-run')
4444
if namespace.verbosity:
4545
args.append('-v')
46+
if namespace.signoff:
47+
args.append('--signoff')
4648
namespace.commit_args = args
4749
return namespace, []
4850

@@ -120,6 +122,17 @@ def __call__(self, parser, namespace, value, option_string=None):
120122
This is performed by default for the gentoo repo, but can be forcibly
121123
disabled or enabled as required.
122124
""")
125+
commit_opts.add_argument(
126+
'--signoff', nargs='?', const=True, action=arghparse.StoreBool,
127+
help='Add a Signed-off-by at the end of the commit log message',
128+
docs="""
129+
Add a Signed-off-by trailer by the committer at the end of the commit
130+
log message.
131+
132+
For commiting to the Gentoo repository, under GLEP-76, the commiter
133+
shall certify agreement to the Certificate of Origin by adding
134+
Signed-off-by line containing the committer's legal name.
135+
""")
123136

124137
msg_actions = commit_opts.add_mutually_exclusive_group()
125138
msg_actions.add_argument(
@@ -721,9 +734,8 @@ def _commit_validate(parser, namespace):
721734
namespace.scan_args.extend(shlex.split(namespace.pkgcheck_scan))
722735
namespace.scan_args.extend(['--exit', 'GentooCI', '--staged'])
723736

724-
# assume signed commits means also requiring signoffs
725737
if namespace.repo.config.sign_commits:
726-
namespace.commit_args.extend(['--signoff', '--gpg-sign'])
738+
namespace.commit_args.append('--gpg-sign')
727739

728740

729741
def update_manifests(options, out, err, changes):

tests/scripts/test_pkgdev_commit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,19 @@ def test_commit_signing(self, repo, make_git_repo, tool):
5858
options, _ = tool.parse_args(['commit', '-u'])
5959
assert '--signoff' not in options.commit_args
6060
assert '--gpg-sign' not in options.commit_args
61+
62+
options, _ = tool.parse_args(['commit', '-u', '--signoff'])
63+
assert '--signoff' in options.commit_args
64+
assert '--gpg-sign' not in options.commit_args
6165
# signed commits enabled by layout.conf setting
6266
with open(pjoin(git_repo.path, 'metadata/layout.conf'), 'a+') as f:
6367
f.write('sign-commits = true\n')
6468
with chdir(repo.location):
6569
options, _ = tool.parse_args(['commit', '-u'])
70+
assert '--signoff' not in options.commit_args
71+
assert '--gpg-sign' in options.commit_args
72+
73+
options, _ = tool.parse_args(['commit', '-u', '--signoff'])
6674
assert '--signoff' in options.commit_args
6775
assert '--gpg-sign' in options.commit_args
6876

0 commit comments

Comments
 (0)