Skip to content
This repository was archived by the owner on Jan 25, 2021. It is now read-only.

Commit 6a790ab

Browse files
committed
Extend CONTRIBUTING guide
Explain the branching model, and how to keep topic branches tidy. Also adds a Code of Conduct
1 parent a8e6d46 commit 6a790ab

File tree

1 file changed

+124
-77
lines changed

1 file changed

+124
-77
lines changed

CONTRIBUTING.rst

+124-77
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ Contributing
77
Contributions are welcome, and they are greatly appreciated! Every little bit
88
helps, and credit will always be given.
99

10+
11+
Code of Conduct
12+
---------------
13+
14+
Everyone interacting in the QDYN-pylib project's code base,
15+
issue tracker, and any communication channels is expected to follow the
16+
`PyPA Code of Conduct`_.
17+
18+
.. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/
19+
20+
1021
Report Bugs
1122
-----------
1223

@@ -32,12 +43,6 @@ If you are proposing a feature:
3243
are welcome :)
3344

3445

35-
Fix Bugs / Implement Features
36-
-----------------------------
37-
38-
Look through the GitHub issues for bugs or feature requests. Anybody is welcome to submit a pull request for open issues.
39-
40-
4146
Pull Request Guidelines
4247
-----------------------
4348

@@ -99,6 +104,119 @@ You still can (and should) look at https://travis-ci.org/qucontrol/qdynpylib/ to
99104
.. _qucontrol organization: https://github.com/qucontrol
100105

101106

107+
Branching Model
108+
---------------
109+
110+
For developers with direct access to the repository,
111+
QDYN-pylib uses a simple branching model where all
112+
developments happens directly on the ``master`` branch. Releases are tags on
113+
``master``. All commits on ``master`` *should* pass all tests and be
114+
well-documented. This is so that ``git bisect`` can be effective. For any
115+
non-trivial issue, it is recommended to create a topic branch, instead of
116+
working on ``master``. There are no restrictions on commits on topic branches,
117+
they do not need to contain complete documentation, pass any tests, or even be
118+
able to run.
119+
120+
To create a topic-branch named ``issue1``::
121+
122+
$ git branch issue1
123+
$ git checkout issue1
124+
125+
You can then make commits, and push them to Github to trigger Continuous
126+
Integration testing::
127+
128+
$ git push -u origin issue1
129+
130+
Commit early and often! At the same time, try to keep your topic branch
131+
as clean and organized as possible. If you have not yet pushed your topic
132+
branch to the "origin" remote:
133+
134+
* Avoid having a series of meaningless granular commits like "start bugfix",
135+
"continue development", "add more work on bugfix", "fix typos", and so forth.
136+
Instead, use ``git commit --amend`` to add to your previous commit. This is
137+
the ideal way to "commit early and often". You do not have to wait until a
138+
commit is "perfect"; it is a good idea to make hourly/daily "snapshots" of
139+
work in progress. Amending a commit also allows you to change the commit
140+
message of your last commit.
141+
* You can combine multiple existing commits by "squashing" them. For example,
142+
use ``git rebase -i HEAD~4`` to combined the previous four commits into one.
143+
See the `"Rewriting History" section of Pro Git book`_ for details (if you
144+
feel this is too far outside of your git comfort zone, just skip it).
145+
* If you work on a topic branch for a long time, and there is significant work
146+
on ``master`` in the meantime, periodically rebase your topic branch on the
147+
current master (``git rebase master``). Avoid merging ``master`` into your
148+
topic branch. See `Merging vs. Rebasing`_.
149+
150+
If you have already pushed your topic branch to the remote origin, you have to
151+
be a bit more careful. If you are sure that you are the only one working on
152+
that topic branch, you can still follow the above guidelines, and force-push
153+
the issue branch (``git push --force``). This also applies if you are an
154+
external contributor preparing a pull request in your own clone of the project.
155+
If you are collaborating with others on the topic branch, coordinate with them
156+
whether they are OK with rewriting the history. If not, merge instead of
157+
rebasing. You must never rewrite history on the ``master`` branch (nor will you
158+
be able to, as the ``master`` branch is "protected" and can only be force-pushed to
159+
in coordination with the project maintainer). If something goes wrong with any
160+
advanced "history rewriting", there is always `"git reflog"`_ as a safety net
161+
-- you will never lose work that was committed before.
162+
163+
When you are done with a topic branch (the issue has been fixed), finish up by
164+
merging the topic branch back into ``master``::
165+
166+
$ git checkout master
167+
$ git merge --no-ff issue1
168+
169+
The ``--no-ff`` option is critical, so that an explicit merge commit is created
170+
(especially if you rebased). Summarize the changes of the branch relative to
171+
``master`` in the commit message.
172+
173+
Then, you can push master and delete the topic branch both locally and on Github::
174+
175+
$ git push origin master
176+
$ git push --delete origin issue1
177+
$ git branch -D issue1
178+
179+
.. _"Rewriting History" section of Pro Git book: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
180+
.. _Merging vs. Rebasing: https://www.atlassian.com/git/tutorials/merging-vs-rebasing
181+
.. _"git reflog": https://www.atlassian.com/git/tutorials/rewriting-history/git-reflog
182+
183+
184+
Commit Message Guidelines
185+
-------------------------
186+
187+
Write commit messages according to this template:
188+
189+
.. code-block:: none
190+
191+
Short (50 chars or less) summary ("subject line")
192+
193+
More detailed explanatory text. Wrap it to 72 characters. The blank
194+
line separating the summary from the body is critical (unless you omit
195+
the body entirely).
196+
197+
Write your subject line in the imperative: "Fix bug" and not "Fixed
198+
bug" or "Fixes bug." This convention matches up with commit messages
199+
generated by commands like git merge and git revert. A properly formed
200+
git commit subject line should always be able to complete the sentence
201+
"If applied, this commit will <your subject line here>".
202+
203+
Further paragraphs come after blank lines.
204+
205+
- Bullet points are okay, too.
206+
- Typically a hyphen or asterisk is used for the bullet, followed by a
207+
single space. Use a hanging indent.
208+
209+
You should reference any issue that is being addressed in the commit, as
210+
e.g. "#1" for issue #1. If the commit closes an issue, state this on the
211+
last line of the message (see below). This will automatically close the
212+
issue on Github as soon as the commit is pushed there.
213+
214+
Closes #1
215+
216+
See `Closing issues using keywords`_ for details on references to issues that
217+
Github will understand.
218+
219+
102220
Testing
103221
-------
104222

@@ -235,77 +353,6 @@ some local virtual environments that development relies on).
235353

236354
.. _how-to-work-on-a-topic-branch:
237355

238-
How to work on a topic branch
239-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240-
241-
When working on an non-trivial issue, it is recommended to create a topic
242-
branch, instead of pushing to ``master``.
243-
244-
To create a branch named ``issue18``::
245-
246-
$ git branch issue18
247-
$ git checkout issue18
248-
249-
You can then make commits, and push them to Github to trigger Continuous Integration testing::
250-
251-
$ git push origin issue18
252-
253-
It is ok to force-push on an issue branch
254-
255-
When you are done (the issue has been fixed), finish up by merging the topic
256-
branch back into ``master``::
257-
258-
$ git checkout master
259-
$ git merge --no-ff issue18
260-
261-
The ``--no-ff`` option is critical, so that an explicit merge commit is created.
262-
Summarize the changes of the branch relative to ``master`` in the commit
263-
message.
264-
265-
Then, you can push master and delete the topic branch both locally and on Github::
266-
267-
$ git push origin master
268-
$ git push --delete origin issue18
269-
$ git branch -D issue18
270-
271-
272-
Commit Message Guidelines
273-
~~~~~~~~~~~~~~~~~~~~~~~~~
274-
275-
Write commit messages according to this template:
276-
277-
.. code-block:: none
278-
279-
Short (50 chars or less) summary
280-
281-
More detailed explanatory text. Wrap it to 72 characters. The blank
282-
line separating the summary from the body is critical (unless you omit
283-
the body entirely).
284-
285-
Write your commit message in the imperative: "Fix bug" and not "Fixed
286-
bug" or "Fixes bug." This convention matches up with commit messages
287-
generated by commands like git merge and git revert.
288-
289-
Further paragraphs come after blank lines.
290-
291-
- Bullet points are okay, too.
292-
- Typically a hyphen or asterisk is used for the bullet, followed by a
293-
single space. Use a hanging indent.
294-
295-
A properly formed git commit subject line should always be able to complete the
296-
sentence "If applied, this commit will <your subject line here>".
297-
298-
299-
How to reference a Github issue in a commit message
300-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
301-
302-
Simply put e.g. ``#14`` anywhere in your commit message, and Github will
303-
automatically link to your commit on the page for issue number 14.
304-
305-
You may also use something like ``Closes #14`` as the last line of your
306-
commit message to automatically close the issue.
307-
See `Closing issues using keywords`_ for details.
308-
309356

310357
How to install QuTiP from source ("illegal instruction" in QuTiP conda install)
311358
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)