CONTRIBUTING.asciidoc 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. Contributing
  2. ============
  3. Introduction
  4. ------------
  5. This document describes the usages and rules to follow when contributing
  6. to this project.
  7. It uses the uppercase keywords SHOULD for optional but highly recommended
  8. conditions and MUST for required conditions.
  9. `git` is a distributed source code versioning system. This document refers
  10. to three different repositories hosting the source code of the project.
  11. `Your local copy` refers to the copy of the repository that you have on
  12. your computer. The remote repository `origin` refers to your fork of the
  13. project's repository that you can find in your GitHub account. The remote
  14. repository `upstream` refers to the official repository for this project.
  15. Following this document will ensure prompt merging of your work in the
  16. `master` branch of the project.
  17. Reporting bugs
  18. --------------
  19. Upon identifying a bug or a DoS vulnerability, you SHOULD submit a ticket,
  20. regardless of your plans for fixing it. If you plan to fix the bug, you
  21. SHOULD discuss your plans to avoid having your work rejected.
  22. Upon identifying a security vulnerability in Erlang/OTP that leaves Cowboy
  23. vulnerable to attack, you SHOULD consult privately with the Erlang/OTP team
  24. to get the issue resolved.
  25. Upon identifying a security vulnerability in Cowboy's `cowboy_static` module,
  26. you SHOULD submit a ticket, regardless of your plans for fixing it. Please
  27. ensure that all necessary details to reproduce are listed. You then SHOULD
  28. inform users on the mailing list about the issue, advising that they use
  29. another means for sending static files until the issue is resolved.
  30. Upon identifying a security vulnerability in any other part of Cowboy, you
  31. SHOULD contact us directly by email. Please ensure that all necessary details
  32. to reproduce are listed.
  33. Before implementing a new feature, you SHOULD submit a ticket for discussion
  34. on your plans. The feature might have been rejected already, or the
  35. implementation might already be decided.
  36. Cloning
  37. -------
  38. You MUST fork the project's repository to your GitHub account by clicking
  39. on the `Fork` button.
  40. Then, from your fork's page, copy the `Git Read-Only` URL to your clipboard.
  41. You MUST perform the following commands in the folder you choose, replacing
  42. `$URL` by the URL you just copied, `$UPSTREAM_URL` by the `Git Read-Only`
  43. project of the official repository, and `$PROJECT` by the name of this project.
  44. ``` bash
  45. $ git clone "$URL"
  46. $ cd $PROJECT
  47. $ git remote add upstream $UPSTREAM_URL
  48. ```
  49. Branching
  50. ---------
  51. Before starting working on the code, you MUST update to `upstream`. The
  52. project is always evolving, and as such you SHOULD always strive to keep
  53. up to date when submitting patches to make sure they can be merged without
  54. conflicts.
  55. To update the current branch to `upstream`, you can use the following commands.
  56. ``` bash
  57. $ git fetch upstream
  58. $ git rebase upstream/master
  59. ```
  60. It may ask you to stash your changes, in which case you stash with:
  61. ``` bash
  62. $ git stash
  63. ```
  64. And put your changes back in with:
  65. ``` bash
  66. $ git stash pop
  67. ```
  68. You SHOULD use these commands both before working on your patch and before
  69. submitting the pull request. If conflicts arise it is your responsability
  70. to deal with them.
  71. You MUST create a new branch for your work. First, ensure you are on `master`.
  72. You MUST update `master` to `upstream` before doing anything. Then create a
  73. new branch `$BRANCH` and switch to it.
  74. ``` bash
  75. $ git checkout -b $BRANCH
  76. ```
  77. You MUST use a an insightful branch name.
  78. If you later need to switch back to an existing branch `$BRANCH`, you can use:
  79. ``` bash
  80. $ git checkout $BRANCH
  81. ```
  82. Source editing
  83. --------------
  84. The following rules MUST be followed:
  85. * Indentation uses horizontal tabs (1 tab = 4 columns)
  86. * Do NOT align code; only indentation is allowed
  87. * Lines MUST NOT span more than 80 columns
  88. The following rules SHOULD be followed:
  89. * Write small functions whenever possible
  90. * Avoid having too many clauses containing clauses containing clauses
  91. Committing
  92. ----------
  93. You MUST ensure that all commits pass all tests and do not have extra
  94. Dialyzer warnings.
  95. Running tests is fairly straightforward. Note that you need at least
  96. Erlang/OTP R16B01 for the SSL tests to run.
  97. ``` bash
  98. make tests
  99. ```
  100. Running Dialyzer requires some initial setup. You need to build the PLT
  101. file that Dialyzer will use for its analysis. This is a one-time operation.
  102. Dialyzer will take care of updating that file when needed.
  103. ``` bash
  104. make build-plt
  105. ```
  106. Once that is done, you can run Dialyzer.
  107. ``` bash
  108. make dialyze
  109. ```
  110. You MUST put all the related work in a single commit. Fixing a bug is one
  111. commit, adding a feature is one commit, adding two features is two commits.
  112. You MUST write a proper commit title and message. The commit title MUST be
  113. at most 72 characters; it is the first line of the commit text. The second
  114. line of the commit text MUST be left blank. The third line and beyond is the
  115. commit message. You SHOULD write a commit message. If you do, you MUST make
  116. all lines smaller than 80 characters. You SHOULD explain what the commit
  117. does, what references you used and any other information that helps
  118. understanding your work.
  119. Submitting the pull request
  120. ---------------------------
  121. You MUST push your branch `$BRANCH` to GitHub, using the following command:
  122. ``` bash
  123. $ git push origin $BRANCH
  124. ```
  125. You MUST then submit the pull request by using the GitHub interface.
  126. You SHOULD provide an explanatory message and refer to any previous ticket
  127. related to this patch.