You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CONTRIBUTING.md 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. # Contribution Guidelines
  2. ## Table of Contents
  3. - [Contribution Guidelines](#contribution-guidelines)
  4. - [Introduction](#introduction)
  5. - [Bug reports](#bug-reports)
  6. - [Discuss your design](#discuss-your-design)
  7. - [Testing redux](#testing-redux)
  8. - [Vendoring](#vendoring)
  9. - [Translation](#translation)
  10. - [Code review](#code-review)
  11. - [Styleguide](#styleguide)
  12. - [Sign-off your work](#sign-off-your-work)
  13. - [Release Cycle](#release-cycle)
  14. - [Maintainers](#maintainers)
  15. - [Owners](#owners)
  16. - [Versions](#versions)
  17. - [Releasing Gitea](#releasing-gitea)
  18. - [Copyright](#copyright)
  19. ## Introduction
  20. This document explains how to contribute changes to the Gitea project.
  21. It assumes you have followed the
  22. [installation instructions](https://docs.gitea.io/en-us/).
  23. Sensitive security-related issues should be reported to
  24. [security@gitea.io](mailto:security@gitea.io).
  25. For configuring IDE or code editor to develop Gitea see [IDE and code editor configuration](contrib/ide/)
  26. ## Bug reports
  27. Please search the issues on the issue tracker with a variety of keywords
  28. to ensure your bug is not already reported.
  29. If unique, [open an issue](https://github.com/go-gitea/gitea/issues/new)
  30. and answer the questions so we can understand and reproduce the
  31. problematic behavior.
  32. To show us that the issue you are having is in Gitea itself, please
  33. write clear, concise instructions so we can reproduce the behavior—
  34. even if it seems obvious. The more detailed and specific you are,
  35. the faster we can fix the issue. Check out [How to Report Bugs
  36. Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html).
  37. Please be kind, remember that Gitea comes at no cost to you, and you're
  38. getting free help.
  39. ## Discuss your design
  40. The project welcomes submissions. If you want to change or add something,
  41. please let everyone know what you're working on—[file an issue](https://github.com/go-gitea/gitea/issues/new)!
  42. Significant changes must go through the change proposal process
  43. before they can be accepted. To create a proposal, file an issue with
  44. your proposed changes documented, and make sure to note in the title
  45. of the issue that it is a proposal.
  46. This process gives everyone a chance to validate the design, helps
  47. prevent duplication of effort, and ensures that the idea fits inside
  48. the goals for the project and tools. It also checks that the design is
  49. sound before code is written; the code review tool is not the place for
  50. high-level discussions.
  51. ## Testing redux
  52. Before sending code out for review, run all the tests for the
  53. whole tree to make sure the changes don't break other usage
  54. and keep the compatibility on upgrade. To make sure you are
  55. running the test suite exactly like we do, you should install
  56. the CLI for [Drone CI](https://github.com/drone/drone), as
  57. we are using the server for continuous testing, following [these
  58. instructions](http://docs.drone.io/cli-installation/). After that,
  59. you can simply call `drone exec --local --build-event "pull_request"` within
  60. your working directory and it will try to run the test suite locally.
  61. ## Vendoring
  62. We keep a cached copy of dependencies within the `vendor/` directory,
  63. managing updates via [dep](https://github.com/golang/dep).
  64. Pull requests should only include `vendor/` updates if they are part of
  65. the same change, be it a bugfix or a feature addition.
  66. The `vendor/` update needs to be justified as part of the PR description,
  67. and must be verified by the reviewers and/or merger to always reference
  68. an existing upstream commit.
  69. You can find more information on how to get started with it on the [dep project website](https://golang.github.io/dep/docs/introduction.html).
  70. ## Translation
  71. We do all translation work inside [Crowdin](https://crowdin.com/project/gitea).
  72. The only translation that is maintained in this git repository is
  73. [`en_US.ini`](https://github.com/go-gitea/gitea/blob/master/options/locale/locale_en-US.ini)
  74. and is synced regularly to Crowdin. Once a translation has reached
  75. A SATISFACTORY PERCENTAGE it will be synced back into this repo and
  76. included in the next released version.
  77. ## Building Gitea
  78. Generally, the go build tools are installed as-needed in the `Makefile`.
  79. An exception are the tools to build the CSS and images.
  80. - To build CSS: Install [Node.js](https://nodejs.org/en/download/package-manager)
  81. with `npm` and then run `npm install` and `make generate-stylesheets`.
  82. - To build Images: ImageMagick, inkscape and zopflipng binaries must be
  83. available in your `PATH` to run `make generate-images`.
  84. ## Code review
  85. Changes to Gitea must be reviewed before they are accepted—no matter who
  86. makes the change, even if they are an owner or a maintainer. We use GitHub's
  87. pull request workflow to do that. And, we also use [LGTM](http://lgtm.co)
  88. to ensure every PR is reviewed by at least 2 maintainers.
  89. Please try to make your pull request easy to review for us. And, please read
  90. the *[How to get faster PR reviews](https://github.com/kubernetes/community/blob/261cb0fd089b64002c91e8eddceebf032462ccd6/contributors/guide/pull-requests.md#best-practices-for-faster-reviews)* guide;
  91. it has lots of useful tips for any project you may want to contribute.
  92. Some of the key points:
  93. * Make small pull requests. The smaller, the faster to review and the
  94. more likely it will be merged soon.
  95. * Don't make changes unrelated to your PR. Maybe there are typos on
  96. some comments, maybe refactoring would be welcome on a function... but
  97. if that is not related to your PR, please make *another* PR for that.
  98. * Split big pull requests into multiple small ones. An incremental change
  99. will be faster to review than a huge PR.
  100. ## Styleguide
  101. For imports you should use the following format (_without_ the comments)
  102. ```go
  103. import (
  104. // stdlib
  105. "encoding/json"
  106. "fmt"
  107. // local packages
  108. "code.gitea.io/gitea/models"
  109. "code.gitea.io/sdk/gitea"
  110. // external packages
  111. "github.com/foo/bar"
  112. "gopkg.io/baz.v1"
  113. )
  114. ```
  115. ## Sign-off your work
  116. The sign-off is a simple line at the end of the explanation for the
  117. patch. Your signature certifies that you wrote the patch or otherwise
  118. have the right to pass it on as an open-source patch. The rules are
  119. pretty simple: If you can certify [DCO](DCO), then you just add a line
  120. to every git commit message:
  121. ```
  122. Signed-off-by: Joe Smith <joe.smith@email.com>
  123. ```
  124. Please use your real name; we really dislike pseudonyms or anonymous
  125. contributions. We are in the open-source world without secrets. If you
  126. set your `user.name` and `user.email` git configs, you can sign-off your
  127. commit automatically with `git commit -s`.
  128. ## Release Cycle
  129. We adopted a release schedule to streamline the process of working
  130. on, finishing, and issuing releases. The overall goal is to make a
  131. minor release every two months, which breaks down into one month of
  132. general development followed by one month of testing and polishing
  133. known as the release freeze. All the feature pull requests should be
  134. merged in the first month of one release period. And, during the frozen
  135. period, a corresponding release branch is open for fixes backported from
  136. master. Release candidates are made during this period for user testing to
  137. obtain a final version that is maintained in this branch. A release is
  138. maintained by issuing patch releases to only correct critical problems
  139. such as crashes or security issues.
  140. Major release cycles are bimonthly. They always begin on the 25th and end on
  141. the 24th (i.e., the 25th of December to February 24th).
  142. During a development cycle, we may also publish any necessary minor releases
  143. for the previous version. For example, if the latest, published release is
  144. v1.2, then minor changes for the previous release—e.g., v1.1.0 -> v1.1.1—are
  145. still possible.
  146. ## Maintainers
  147. To make sure every PR is checked, we have [team
  148. maintainers](MAINTAINERS). Every PR **MUST** be reviewed by at least
  149. two maintainers (or owners) before it can get merged. A maintainer
  150. should be a contributor of Gitea (or Gogs) and contributed at least
  151. 4 accepted PRs. A contributor should apply as a maintainer in the
  152. [Discord](https://discord.gg/NsatcWJ) #develop channel. The owners
  153. or the team maintainers may invite the contributor. A maintainer
  154. should spend some time on code reviews. If a maintainer has no
  155. time to do that, they should apply to leave the maintainers team
  156. and we will give them the honor of being a member of the [advisors
  157. team](https://github.com/orgs/go-gitea/teams/advisors). Of course, if
  158. an advisor has time to code review, we will gladly welcome them back
  159. to the maintainers team. If a maintainer is inactive for more than 3
  160. months and forgets to leave the maintainers team, the owners may move
  161. him or her from the maintainers team to the advisors team.
  162. For security reasons, Maintainers should use 2FA for their accounts and
  163. if possible provide gpg signed commits.
  164. https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
  165. https://help.github.com/articles/signing-commits-with-gpg/
  166. ## Owners
  167. Since Gitea is a pure community organization without any company support,
  168. to keep the development healthy we will elect three owners every year. All
  169. contributors may vote to elect up to three candidates, one of which will
  170. be the main owner, and the other two the assistant owners. When the new
  171. owners have been elected, the old owners will give up ownership to the
  172. newly elected owners. If an owner is unable to do so, the other owners
  173. will assist in ceding ownership to the newly elected owners.
  174. For security reasons, Owners or any account with write access (like a bot)
  175. must use 2FA.
  176. https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
  177. After the election, the new owners should proactively agree
  178. with our [CONTRIBUTING](CONTRIBUTING.md) requirements in the
  179. [Discord](https://discord.gg/NsatcWJ) #general channel. Below are the
  180. words to speak:
  181. ```
  182. I'm honored to having been elected an owner of Gitea, I agree with
  183. [CONTRIBUTING](CONTRIBUTING.md). I will spend part of my time on Gitea
  184. and lead the development of Gitea.
  185. ```
  186. To honor the past owners, here's the history of the owners and the time
  187. they served:
  188. * 2016-11-04 ~ 2017-12-31
  189. * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
  190. * [Thomas Boerger](https://github.com/tboerger) <thomas@webhippie.de>
  191. * [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
  192. * 2018-01-01 ~ 2018-12-31
  193. * [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
  194. * [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
  195. * [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
  196. ## Versions
  197. Gitea has the `master` branch as a tip branch and has version branches
  198. such as `release/v0.9`. `release/v0.9` is a release branch and we will
  199. tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept
  200. pull requests on the `release/v0.9` branch and publish a `v0.9.1` tag,
  201. after bringing the bug fix also to the master branch.
  202. Since the `master` branch is a tip version, if you wish to use Gitea
  203. in production, please download the latest release tag version. All the
  204. branches will be protected via GitHub, all the PRs to every branch must
  205. be reviewed by two maintainers and must pass the automatic tests.
  206. ## Releasing Gitea
  207. * Let $vmaj, $vmin and $vpat be Major, Minor and Patch version numbers, $vpat should be rc1, rc2, 0, 1, ...... $vmaj.$vmin will be kept the same as milestones on github or gitea in future.
  208. * Before releasing, confirm all the version's milestone issues or PRs has been resolved. Then discuss the release on discord channel #maintainers and get agreed with almost all the owners and mergers. Or you can declare the version and if nobody against in about serval hours.
  209. * If this is a big version first you have to create PR for changelog on branch `master` with PRs with label `changelog` and after it has been merged do following steps:
  210. * Create `-dev` tag as `git tag -s -F release.notes v$vmaj.$vmin.0-dev` and push the tag as `git push origin v$vmaj.$vmin.0-dev`.
  211. * When CI has finished building tag then you have to create a new branch named `release/v$vmaj.$vmin`
  212. * If it is bugfix version create PR for changelog on branch `release/v$vmaj.$vmin` and wait till it is reviewed and merged.
  213. * Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
  214. * And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically created a release and upload all the compiled binary. (But currently it didn't add the release notes automatically. Maybe we should fix that.)
  215. * If needed send PR for changelog on branch `master`.
  216. * Send PR to [blog repository](https://github.com/go-gitea/blog) announcing the release.
  217. ## Copyright
  218. Code that you contribute should use the standard copyright header:
  219. ```
  220. // Copyright 2018 The Gitea Authors. All rights reserved.
  221. // Use of this source code is governed by a MIT-style
  222. // license that can be found in the LICENSE file.
  223. ```
  224. Files in the repository contain copyright from the year they are added
  225. to the year they are last changed. If the copyright author is changed,
  226. just paste the header below the old one.