Please keep your code clean: one feature or bug-fix per branch. If you find another bug, you want to fix while being in a new branch, please fix it in a separated branch instead. **3) Code** * Adhere to common conventions you see in the existing code * Include tests, and ensure they pass * Search to see if your new functionality has been discussed on [the Discourse meta forum](http://meta.discourse.org), and include updates as appropriate. **4) Follow the Coding Conventions** * two spaces, no tabs * no trailing whitespaces, blank lines should have no spaces * use spaces around operators, after commas, colons, semicolons, around `{` and before `}` * no space after `(`, `[` or before `]`, `)` * use Ruby 1.9 hash syntax: prefer `{ a: 1 }` over `{ :a => 1 }` * prefer `class Remember: We don't accept pull requests consisting entirely of style changes. Style changes in the context of pull requests that also refactor code, fix bugs, improve functionality *are* welcome. **5) Commit** For every commit please write a short (max 72 characters) summary in the first line followed with a blank line and then more detailed descriptions of the change. Use markdown syntax for simple styling. > **Don't forget a prefix!** Be sure to follow the https://meta.discourse.org/t/github-checkin-prefix-convention/19392?u=jomaxro for your commit title. > **NEVER leave the commit message blank!** Provide a detailed, clear, and complete description of your commit! See "[How to write a Git commit message][5]" for great pointers. **5a) Linting** We lint our JavaScript code with [eslint](https://eslint.org/) as well as following the formatting conventions of [prettier](https://prettier.io/), and we lint our ruby code with [rubocop](https://github.com/rubocop/rubocop). All of these checks are run automatically in GitHub actions whenever you create a pull request for Discourse. It is strongly recommended that you install our pre-commit git hooks using `lefthook`. This will run automatically every time you make a commit in Discourse core, and raise issues with the various languages and templates before you push them up and have to wait for GitHub CI to run. From project root: ``` mkdir .git/hooks npx lefthook install ``` Depending on your code editor, there should be various tools that can run our linters and display the results inline based on the configurations we have specified in the Discourse project. **6) Update your branch** git fetch origin git rebase origin/main **7) Fork** git remote add mine git@github.com:/discourse.git **8) Push to your remote** git push mine new_discourse_branch **9) Issue a [Pull Request](https://help.github.com/articles/proposing-changes-to-a-project-with-pull-requests/)** Before submitting a pull-request, clean up the history, go over your commits and squash together minor changes and fixes into the corresponding commits. You can squash commits with the interactive rebase command: ``` git fetch origin git checkout new_discourse_branch git rebase origin/main git rebase -i git push -f mine new_discourse_branch ``` In order to make a pull request, * Navigate to the Discourse repository you just pushed to (e.g. https://github.com/your-user-name/discourse) * Click "Pull Request". * Write your branch name in the branch field (this is filled with "main" by default) * Click "Update Commit Range". * Ensure the changesets you introduced are included in the "Commits" tab. * Ensure that the "Files Changed" incorporate all of your changes. * Fill in some details about your potential patch including a meaningful title. Be sure to follow the https://meta.discourse.org/t/github-checkin-prefix-convention/19392?u=jomaxro. * Click "Send pull request". Thanks for that -- we'll get to your pull request ASAP, we love pull requests! **10) Responding to Feedback** The Discourse team may recommend adjustments to your code. Part of interacting with a healthy open-source community requires you to be open to learning new techniques and strategies; *don't get discouraged!* Remember: if the Discourse team suggest changes to your code, **they care enough about your work that they want to include it**, and hope that you can assist by implementing those revisions on your own. > Though we ask you to clean your history and squash commit before submitting a pull-request, please do not change any commits you've submitted already (as other work might be build on top). *Thank you for contributing to the Discourse open source project!* [2]: https://meta.discourse.org/search?q=%22pr%20welcome%22 [3]: http://en.wikipedia.org/wiki/Contributor_License_Agreement [4]: https://codeclimate.com/github/discourse/discourse [5]: http://chris.beams.io/posts/git-commit/ --- *Last Reviewed by @SaraDev on [date=2022-06-01 time=18:00:00 timezone="America/Los_Angeles"]*" />