1425bb815Sopenharmony_ci# Contribution Guidelines 2425bb815Sopenharmony_ci## Patch Submission Process 3425bb815Sopenharmony_ci 4425bb815Sopenharmony_ciThe following guidelines on the submission process are provided to help you be more effective when submitting code to the JerryScript project. 5425bb815Sopenharmony_ci 6425bb815Sopenharmony_ciWhen development is complete, a patch set should be submitted via GitHub pull requests. A review of the patch set will take place. When accepted, the patch set will be integrated into the master branch, verified, and tested. It is then the responsibility of the authoring developer to maintain the code throughout its lifecycle. 7425bb815Sopenharmony_ci 8425bb815Sopenharmony_ciPlease submit all patches in public by opening a pull request. Patches sent privately to Maintainers and Committers will not be considered. Because the JerryScript Project is an Open Source project, be prepared for feedback and criticism-it happens to everyone-. If asked to rework your code, be persistent and resubmit after making changes. 9425bb815Sopenharmony_ci 10425bb815Sopenharmony_ci### 1. Scope the patch 11425bb815Sopenharmony_ci 12425bb815Sopenharmony_ciSmaller patches are generally easier to understand and test, so please submit changes in the smallest increments possible, within reason. Smaller patches are less likely to have unintended consequences, and if they do, getting to the root cause is much easier for you and the Maintainers and Committers. Additionally, smaller patches are much more likely to be accepted. 13425bb815Sopenharmony_ci 14425bb815Sopenharmony_ci### 2. Ensure all files have a proper license header and copyright notice 15425bb815Sopenharmony_ci 16425bb815Sopenharmony_ciAny code that you want to contribute to the project must be licensed under the [Apache License 2.0](LICENSE). Contributions under a different license can not be accepted. Each file should start with the following header: 17425bb815Sopenharmony_ci 18425bb815Sopenharmony_ci```c 19425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation 20425bb815Sopenharmony_ci * 21425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 22425bb815Sopenharmony_ci * you may not use this file except in compliance with the License. 23425bb815Sopenharmony_ci * You may obtain a copy of the License at 24425bb815Sopenharmony_ci * 25425bb815Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 26425bb815Sopenharmony_ci * 27425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 28425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS 29425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 30425bb815Sopenharmony_ci * See the License for the specific language governing permissions and 31425bb815Sopenharmony_ci * limitations under the License. 32425bb815Sopenharmony_ci */ 33425bb815Sopenharmony_ci``` 34425bb815Sopenharmony_ci 35425bb815Sopenharmony_ciAdding copyright notices other than the project-wide notice ("Copyright JS Foundation and other contributors, http://js.foundation") is not permitted. The only exception is adding third-party code which requires copyright notices to be preserved. Adding third-party code to the project generally requires a strong justification. 36425bb815Sopenharmony_ci 37425bb815Sopenharmony_ci### 3. Sign your work with the JerryScript [Developer's Certificate of Origin](DCO.md) 38425bb815Sopenharmony_ci 39425bb815Sopenharmony_ciThe sign-off is a simple line at the end of the commit message of the patch, which certifies that you wrote it or otherwise have the right to pass it on as an Open Source patch. The sign-off is required for a patch to be accepted. 40425bb815Sopenharmony_ci 41425bb815Sopenharmony_ciWe have the same requirements for using the signed-off-by process as the Linux kernel. 42425bb815Sopenharmony_ciIn short, you need to include a signed-off-by tag in every patch. 43425bb815Sopenharmony_ci 44425bb815Sopenharmony_ciYou should use your real name and email address in the format below: 45425bb815Sopenharmony_ci 46425bb815Sopenharmony_ci> JerryScript-DCO-1.0-Signed-off-by: Random J Developer random@developer.example.org 47425bb815Sopenharmony_ci 48425bb815Sopenharmony_ci"JerryScript-DCO-1.0-Signed-off-by:" this is a developer's certification that he or she has the right to submit the patch for inclusion into the project. It is an agreement to the JerryScript [Developer's Certificate of Origin](DCO.md). **Code without a proper signoff cannot be merged into the mainline.** 49425bb815Sopenharmony_ci 50425bb815Sopenharmony_ci### 4. Open a GitHub [pull request](https://github.com/jerryscript-project/jerryscript/pulls) 51425bb815Sopenharmony_ci 52425bb815Sopenharmony_ciYou can find instructions about opening a pull request [here](https://help.github.com/articles/creating-a-pull-request). 53425bb815Sopenharmony_ci 54425bb815Sopenharmony_ci### 5. What if my patch is rejected? 55425bb815Sopenharmony_ci 56425bb815Sopenharmony_ciIt happens all the time, for many reasons, and not necessarily because the code is bad. Take the feedback, adapt your code, and try again. Remember, the ultimate goal is to preserve the quality of the code and maintain the focus of the Project through intensive review. 57425bb815Sopenharmony_ci 58425bb815Sopenharmony_ciMaintainers and Committers typically have to process a lot of submissions, and the time for any individual response is generally limited. If the reason for rejection is unclear, please ask for more information from the Maintainers and Committers. 59425bb815Sopenharmony_ciIf you have a solid technical reason to disagree with feedback and you feel that reason has been overlooked, take the time to thoroughly explain it in your response. 60425bb815Sopenharmony_ci 61425bb815Sopenharmony_ci### 6. Code review 62425bb815Sopenharmony_ci 63425bb815Sopenharmony_ciCode review can be performed by all the members of the Project (not just Maintainers and Committers). Members can review code changes and share their opinion through comments guided by the following principles: 64425bb815Sopenharmony_ci* Discuss code; never discuss the code's author 65425bb815Sopenharmony_ci* Respect and acknowledge contributions, suggestions, and comments 66425bb815Sopenharmony_ci* Listen and be open to all different opinions 67425bb815Sopenharmony_ci* Help each other 68425bb815Sopenharmony_ci 69425bb815Sopenharmony_ciChanges are submitted via pull requests and only the Maintainers and Committers should approve or reject the pull request (note that only Maintainers can give binding review scores). 70425bb815Sopenharmony_ciChanges should be reviewed in reasonable amount of time. Maintainers and Committers should leave changes open for some time (at least 1 full business day) so others can offer feedback. Review times increase with the complexity of the review. 71425bb815Sopenharmony_ci 72425bb815Sopenharmony_ci## Tips on GitHub Pull Requests 73425bb815Sopenharmony_ci 74425bb815Sopenharmony_ci* [Fork](https://guides.github.com/activities/forking) the GitHub repository and clone it locally 75425bb815Sopenharmony_ci* Connect your local repository to the original upstream repository by adding it as a remote 76425bb815Sopenharmony_ci* Create a [branch](https://guides.github.com/introduction/flow) for your edits 77425bb815Sopenharmony_ci* Pull in upstream changes often to stay up-to-date so that when you submit your pull request, merge conflicts will be less likely 78425bb815Sopenharmony_ci 79425bb815Sopenharmony_ciFor more details, see the GitHub [fork syncing](https://help.github.com/articles/syncing-a-fork) guidelines. 80425bb815Sopenharmony_ci 81425bb815Sopenharmony_ci## How to add the DCO line to every single commit automatically 82425bb815Sopenharmony_ci 83425bb815Sopenharmony_ciIt is easy to forget adding the DCO line to the end of every commit message. Fortunately there is a nice way to do it automatically. Once you've cloned the repository into your local machine, you can add `prepare commit message hook` in `.git/hooks` directory like this: 84425bb815Sopenharmony_ci 85425bb815Sopenharmony_ci``` 86425bb815Sopenharmony_ci#!/usr/bin/env python 87425bb815Sopenharmony_ci 88425bb815Sopenharmony_ciimport sys 89425bb815Sopenharmony_ci 90425bb815Sopenharmony_cicommit_msg_filepath = sys.argv[1] 91425bb815Sopenharmony_ci 92425bb815Sopenharmony_ciwith open(commit_msg_filepath, "r+") as f: 93425bb815Sopenharmony_ci content = f.read() 94425bb815Sopenharmony_ci f.seek(0, 0) 95425bb815Sopenharmony_ci if "Signed-off-by" not in content: 96425bb815Sopenharmony_ci f.write("\n\nJerryScript-DCO-1.0-Signed-off-by: <Your Name> <Your Email>\n%s" % content) 97425bb815Sopenharmony_ci else: 98425bb815Sopenharmony_ci f.write(content) 99425bb815Sopenharmony_ci``` 100425bb815Sopenharmony_ci 101425bb815Sopenharmony_ciPlease refer [Git Hooks](http://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) for more information. 102