Skip to content

Contribution tips and tricks

Paul Jolly edited this page Jul 29, 2021 · 14 revisions

Automatically signing every commit

The Contribution Guide explains the role the Developer Certificate of Origin plays in contributions to the CUE project. It also explains how git commit -s can be used to sign-off each commit. But:

  • it's easy to forget the -s flag;
  • it's not always possible/easy to fix up other tools that wrap the git commit step.

You can automate the sign-off step using a git hook. Run the following commands in the root of a git repository where you want to automatically sign-off each commit:

cat <<EOD > .git/hooks/prepare-commit-msg
#!/bin/sh

NAME=$(git config user.name)
EMAIL=$(git config user.email)

if [ -z "$NAME" ]; then
    echo "empty git config user.name"
    exit 1
fi

if [ -z "$EMAIL" ]; then
    echo "empty git config user.email"
    exit 1
fi

git interpret-trailers --if-exists doNothing --trailer \
    "Signed-off-by: $NAME <$EMAIL>" \
    --in-place "$1"
EOD
chmod +x .git/hooks/prepare-commit-msg

(if you already have a prepare-commit-msg hook, adapt it accordingly).

Making GerritHub config changes

Whilst some config changes can be made via the Gerrit UI, the majority cannot. Changes to Gerrit config files should be submitted for review in the usual way, but pushed for review against the meta/config branch. The process for submitting a change against this branch is slightly different to the default branch:

# We assume you have a local clone of the CUE repo
git fetch origin refs/meta/config:refs/remotes/origin/meta/config
git checkout -b my_config_change origin/meta/config

# Make config changes

git codereview change -s -a -m 'Important configuration changes'
git push origin meta/config:meta/config
Clone this wiki locally