DCO Sign-Offs: Committing Code to Hyperledger Besu
What is the DCO sign off?
This stack overflow answer does a good job of explaining it:
It was introduced in the wake of the SCO lawsuit […] as a Developers Certificate of Origin. It is used to say that you certify that you have created the patch in question, or that you certify that to the best of your knowledge, it was created under an appropriate open-source license, or that it has been provided to you by someone else under those terms.
The answer also mentions only a few projects use the DCO sign off feature, and well, Hyperledger Besu is one of those projects. Since submitting the Java Ethereum client, formerly known as Pantheon, to the Linux Foundation's Hyperledger (where it is now known as Hyperledger Besu), we require contributors to add a line of text essentially signing their comment in order to affirm that the code submitted has originated from themselves (or that they have permission to use it).
If you want to read the contents of the Developer Certificate of Origin, see here: https://developercertificate.org.
How to sign off?
This should be done after following the instructions on how to commit.
There are several ways to add the line "Signed-off-by: Your Legal Name " to each of your commits.
1. Manually adding it.
You can add this line of text manually to your commit body on each commit. Although cumbersome, it possible and simple.
git commit -m "Fix typo in documentation Signed-off-by: Legal Name <[email protected]>"
git commit -m "Fix typo in documentation" -m "Signed-off-by: Legal Name <[email protected]>"
2. Automating this boring step
Computers can do things for us, so lets configure that.
git config user.name "Legal Name" git config user.email "[email protected]"
You can use
`-gin order to configure this globally on your machine.
Now all you need to do is add
--signoff to your
git commit commands.
git commit -s -m "Fix typo in documentation"
- Adding it if you forgot to sign-off. If you forgot to add the sign-off, you can also amend your commit with the sign-off.
git commit --amend -s
3. Adding alias
If you're already added your name and email to the config, you can add an alias to your local setup in order to automatically add that
-s t every commit command.
This can be done wither on your local CLI setup, or through a git alias as follows:
git config --global alias.c 'commit --signoff'
And now you can run
git commit c -m instead of
git commit -s -m.
For an example of the former using zsh:
echo alias gco='git commit -s' >> ~/.zshrc
For bash, replace
If you want to reduce your typing even futher, add the
echo alias gco='git commit -s -m' >> ~/.zshrc
Verify that your config was written.
$ tail ~/.zshrc
You should see the following, or similar:
alias gco=git commit -s
In order to test this last option out, you have to re-source the config file:
For bash, replace
If you've already pushed your changes to Github, you will have to
force push your branch after this with
git push -f.
For more information on DCO sign-off, including how to deal with DCO errors flagged by our bot, check out Hyperledger's wiki.