-
Notifications
You must be signed in to change notification settings - Fork 0
Contributing to Sanmill
Thanks for taking the time to contribute to Sanmill!
Nevertheless, you can use GitHub to send your Pull Requests commits to us conveniently.
In addition, we highly recommend you read our submission guidelines.
Your friendly Sanmill community!
Here are some guidelines for people who want to contribute their code to this software.
Decide what to base your work on.
In general, always base your work on the oldest branch that your change is relevant to.
-
A bugfix should be based on
maint
in general. If the bug is not present inmaint
, base it onmaster
. For a bug that's not yet inmaster
, find the topic that introduces the regression and base your work on the tip of the topic. -
A new feature should be based on
master
in general if the new feature depends on a topic indev
, but not inmaster
, base your work on the tip of that topic. -
Corrections and enhancements to a topic not yet in
master
should be based on the tip of that topic. If the topic has not been merged todev
, it's alright to add a note to squash minor corrections into the series. -
In the exceptional case that a new feature depends on several topics not in
master
, start working ondev
privately and create pull requests for discussion. Before the final merge, you may have to wait until some of the dependent topics graduate tomaster
, and rebase your work.
To find the tip of a topic branch, run git log --first-parent master..dev
and look for the merge commit. The second parent of this commit is the tip of the topic branch.
Make separate commits for logically separate changes.
Unless your commit is trivial, you should make separate commits for logically separate changes.
Explain the change(s) that is detailed enough to judge if it is good to do without reading the actual commit message to determine how well the code does what the explanation promises to do.
If your description starts to get too long, that's a sign that you probably need to split up your Git commit to finer-grained pieces. That being said, Git commits that plainly describe the things that help reviewers check the commit and future maintainers understand the code is the most beautiful commits. Descriptions that summarize the point in the subject well and describe the motivation for the change, the approach is taken by the change, and, if relevant, how this differs substantially from the prior version are all good things to have.
Make sure that you have tests for the bug you are fixing.
Oh, another thing. We are picky about whitespaces. To help ensure this does not happen, run git diff --check
on your changes before you Git commit.
Describe your changes well.
The commit message's first line should be a short description (50 characters is the soft limit) and should skip the full stop. It is also conventional in most cases to prefix the first line with "area: " where the area is a filename or identifier for the general area of the code being modified, e.g.
- doc: Clarify the distinction between sign-off and PGP-signing
- Readme.md: Improve the intro section
If in doubt which identifier to use, run git log --no-merges
on the files you are modifying to see the current conventions.
The title sentence after the "area:" prefix omits the full stop at the end.
The body should provide a meaningful commit message, which:
-
Explains the problem the change tries to solve, i.e., what is wrong with the current code without the change.
-
Justifies how the change solves the problem, i.e., why the result is better.
-
Alternate solutions considered but discarded if any.
Describe your changes in imperative mood, e.g., "Make xyzzy do frotz" instead of "Makes xyzzy do frotz" or "Changed xyzzy to do frotz", as if you are giving orders to the codebase to change its behavior. Try to make sure your explanation can be understood without external resources. Instead of providing a URL to an issue, summarize the relevant points of the discussion.
Please make sure your commit does not add commented-out debugging code or include any extra files which do not relate to what your commit is trying to achieve. Make sure to review your commit after generating it to ensure accuracy. Before sending it out, please make sure it cleanly applies to the master
branch head. If you are preparing work based on the dev
branch, that is fine, but please mark it as such.
An ideal commit flow
Here is an ideal commit flow for this project the current maintainer suggests to the contributors:
- You come up with an itch. You code it up.
- A topic branch is created with the commit, creates a pull request, and assigns people who may need to know about the change.
The people who may need to know are the ones whose code you are butchering. These people happen to be the ones who are most likely to be knowledgeable enough to help you, but they have no obligation to help you (i.e., you ask for help, don't demand).
-
You get comments and suggestions for improvements. You may even get them in an "on top of your change" commit form.
-
Polish, refine, and re-push. Go back to step (2).
-
The pull request forms consensus that the last round of your commit is good.
-
The topic branch is merged or rebased to
dev
, cooked further, and eventually graduates tomaster
.
Know the status of your commit after submission
You can use Git itself to find out when your commit is merged in master. git pull --rebase
will automatically skip already-applied Git commits and let you know. This works only if you rebase on top of the branch in which your commit has been merged (i.e., it will not tell you if your Git commit is merged in dev
if you rebase on top of master).
With an account at GitHub, you can use GitHub CI to test your changes on Linux, Mac, and Windows. See https://github.com/calcitem/Sanmill/actions for examples of recent CI runs.
Follow these steps for the initial setup:
- Fork https://github.com/calcitem/Sanmill to your GitHub account. You can find detailed instructions on how to fork here: https://help.github.com/articles/fork-a-repo/.
CI will run after the initial setup whenever you push new changes to your fork of Git on GitHub. You can monitor the test state of all your branches here: https://github.com/<Your GitHub handle>/Sanmill/actions/
.
If a branch did not pass all test cases, then it is marked with a red cross. In that case, you can click on the failing job. You can also download "Artifacts" which are tarred (or zipped) archives with test data relevant for debugging.
Then fix the problem and push your fix to your GitHub fork. This will trigger a new CI build to ensure all tests pass.