11cb0ef41Sopenharmony_ci# CONTRIBUTING
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_ciThe libuv project welcomes new contributors. This document will guide you
41cb0ef41Sopenharmony_cithrough the process.
51cb0ef41Sopenharmony_ci
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ci### FORK
81cb0ef41Sopenharmony_ci
91cb0ef41Sopenharmony_ciFork the project [on GitHub](https://github.com/libuv/libuv) and check out
101cb0ef41Sopenharmony_ciyour copy.
111cb0ef41Sopenharmony_ci
121cb0ef41Sopenharmony_ci```
131cb0ef41Sopenharmony_ci$ git clone https://github.com/username/libuv.git
141cb0ef41Sopenharmony_ci$ cd libuv
151cb0ef41Sopenharmony_ci$ git remote add upstream https://github.com/libuv/libuv.git
161cb0ef41Sopenharmony_ci```
171cb0ef41Sopenharmony_ci
181cb0ef41Sopenharmony_ciNow decide if you want your feature or bug fix to go into the master branch
191cb0ef41Sopenharmony_cior the stable branch.  As a rule of thumb, bug fixes go into the stable branch
201cb0ef41Sopenharmony_ciwhile new features go into the master branch.
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciThe stable branch is effectively frozen; patches that change the libuv
231cb0ef41Sopenharmony_ciAPI/ABI or affect the run-time behavior of applications get rejected.
241cb0ef41Sopenharmony_ci
251cb0ef41Sopenharmony_ciIn case of doubt, open an issue in the [issue tracker][], post your question
261cb0ef41Sopenharmony_cito the [libuv discussions forum], or message the [libuv mailing list].
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ciEspecially do so if you plan to work on something big. Nothing is more
291cb0ef41Sopenharmony_cifrustrating than seeing your hard work go to waste because your vision does not
301cb0ef41Sopenharmony_cialign with that of the [project maintainers].
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci
331cb0ef41Sopenharmony_ci### BRANCH
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ciOkay, so you have decided on the proper branch.  Create a feature branch
361cb0ef41Sopenharmony_ciand start hacking:
371cb0ef41Sopenharmony_ci
381cb0ef41Sopenharmony_ci```
391cb0ef41Sopenharmony_ci$ git checkout -b my-feature-branch -t origin/v1.x
401cb0ef41Sopenharmony_ci```
411cb0ef41Sopenharmony_ci
421cb0ef41Sopenharmony_ci(Where v1.x is the latest stable branch as of this writing.)
431cb0ef41Sopenharmony_ci
441cb0ef41Sopenharmony_ci### CODE
451cb0ef41Sopenharmony_ci
461cb0ef41Sopenharmony_ciPlease adhere to libuv's code style. In general it follows the conventions from
471cb0ef41Sopenharmony_cithe [Google C/C++ style guide]. Some of the key points, as well as some
481cb0ef41Sopenharmony_ciadditional guidelines, are enumerated below.
491cb0ef41Sopenharmony_ci
501cb0ef41Sopenharmony_ci* Code that is specific to unix-y platforms should be placed in `src/unix`, and
511cb0ef41Sopenharmony_ci  declarations go into `include/uv/unix.h`.
521cb0ef41Sopenharmony_ci
531cb0ef41Sopenharmony_ci* Source code that is Windows-specific goes into `src/win`, and related
541cb0ef41Sopenharmony_ci  publicly exported types, functions and macro declarations should generally
551cb0ef41Sopenharmony_ci  be declared in `include/uv/win.h`.
561cb0ef41Sopenharmony_ci
571cb0ef41Sopenharmony_ci* Names should be descriptive and concise.
581cb0ef41Sopenharmony_ci
591cb0ef41Sopenharmony_ci* All the symbols and types that libuv makes available publicly should be
601cb0ef41Sopenharmony_ci  prefixed with `uv_` (or `UV_` in case of macros).
611cb0ef41Sopenharmony_ci
621cb0ef41Sopenharmony_ci* Internal, non-static functions should be prefixed with `uv__`.
631cb0ef41Sopenharmony_ci
641cb0ef41Sopenharmony_ci* Use two spaces and no tabs.
651cb0ef41Sopenharmony_ci
661cb0ef41Sopenharmony_ci* Lines should be wrapped at 80 characters.
671cb0ef41Sopenharmony_ci
681cb0ef41Sopenharmony_ci* Ensure that lines have no trailing whitespace, and use unix-style (LF) line
691cb0ef41Sopenharmony_ci  endings.
701cb0ef41Sopenharmony_ci
711cb0ef41Sopenharmony_ci* Use C89-compliant syntax. In other words, variables can only be declared at
721cb0ef41Sopenharmony_ci  the top of a scope (function, if/for/while-block).
731cb0ef41Sopenharmony_ci
741cb0ef41Sopenharmony_ci* When writing comments, use properly constructed sentences, including
751cb0ef41Sopenharmony_ci  punctuation.
761cb0ef41Sopenharmony_ci
771cb0ef41Sopenharmony_ci* When documenting APIs and/or source code, don't make assumptions or make
781cb0ef41Sopenharmony_ci  implications about race, gender, religion, political orientation or anything
791cb0ef41Sopenharmony_ci  else that isn't relevant to the project.
801cb0ef41Sopenharmony_ci
811cb0ef41Sopenharmony_ci* Remember that source code usually gets written once and read often: ensure
821cb0ef41Sopenharmony_ci  the reader doesn't have to make guesses. Make sure that the purpose and inner
831cb0ef41Sopenharmony_ci  logic are either obvious to a reasonably skilled professional, or add a
841cb0ef41Sopenharmony_ci  comment that explains it.
851cb0ef41Sopenharmony_ci
861cb0ef41Sopenharmony_ci
871cb0ef41Sopenharmony_ci### COMMIT
881cb0ef41Sopenharmony_ci
891cb0ef41Sopenharmony_ciMake sure git knows your name and email address:
901cb0ef41Sopenharmony_ci
911cb0ef41Sopenharmony_ci```
921cb0ef41Sopenharmony_ci$ git config --global user.name "J. Random User"
931cb0ef41Sopenharmony_ci$ git config --global user.email "j.random.user@example.com"
941cb0ef41Sopenharmony_ci```
951cb0ef41Sopenharmony_ci
961cb0ef41Sopenharmony_ciWriting good commit logs is important.  A commit log should describe what
971cb0ef41Sopenharmony_cichanged and why.  Follow these guidelines when writing one:
981cb0ef41Sopenharmony_ci
991cb0ef41Sopenharmony_ci1. The first line should be 50 characters or less and contain a short
1001cb0ef41Sopenharmony_ci   description of the change prefixed with the name of the changed
1011cb0ef41Sopenharmony_ci   subsystem (e.g. "net: add localAddress and localPort to Socket").
1021cb0ef41Sopenharmony_ci2. Keep the second line blank.
1031cb0ef41Sopenharmony_ci3. Wrap all other lines at 72 columns.
1041cb0ef41Sopenharmony_ci
1051cb0ef41Sopenharmony_ciA good commit log looks like this:
1061cb0ef41Sopenharmony_ci
1071cb0ef41Sopenharmony_ci```
1081cb0ef41Sopenharmony_cisubsystem: explaining the commit in one line
1091cb0ef41Sopenharmony_ci
1101cb0ef41Sopenharmony_ciBody of commit message is a few lines of text, explaining things
1111cb0ef41Sopenharmony_ciin more detail, possibly giving some background about the issue
1121cb0ef41Sopenharmony_cibeing fixed, etc etc.
1131cb0ef41Sopenharmony_ci
1141cb0ef41Sopenharmony_ciThe body of the commit message can be several paragraphs, and
1151cb0ef41Sopenharmony_ciplease do proper word-wrap and keep columns shorter than about
1161cb0ef41Sopenharmony_ci72 characters or so. That way `git log` will show things
1171cb0ef41Sopenharmony_cinicely even when it is indented.
1181cb0ef41Sopenharmony_ci```
1191cb0ef41Sopenharmony_ci
1201cb0ef41Sopenharmony_ciThe header line should be meaningful; it is what other people see when they
1211cb0ef41Sopenharmony_cirun `git shortlog` or `git log --oneline`.
1221cb0ef41Sopenharmony_ci
1231cb0ef41Sopenharmony_ciCheck the output of `git log --oneline files_that_you_changed` to find out
1241cb0ef41Sopenharmony_ciwhat subsystem (or subsystems) your changes touch.
1251cb0ef41Sopenharmony_ci
1261cb0ef41Sopenharmony_ci
1271cb0ef41Sopenharmony_ci### REBASE
1281cb0ef41Sopenharmony_ci
1291cb0ef41Sopenharmony_ciUse `git rebase` (not `git merge`) to sync your work from time to time.
1301cb0ef41Sopenharmony_ci
1311cb0ef41Sopenharmony_ci```
1321cb0ef41Sopenharmony_ci$ git fetch upstream
1331cb0ef41Sopenharmony_ci$ git rebase upstream/v1.x  # or upstream/master
1341cb0ef41Sopenharmony_ci```
1351cb0ef41Sopenharmony_ci
1361cb0ef41Sopenharmony_ci
1371cb0ef41Sopenharmony_ci### TEST
1381cb0ef41Sopenharmony_ci
1391cb0ef41Sopenharmony_ciBug fixes and features should come with tests.  Add your tests in the
1401cb0ef41Sopenharmony_ci`test/` directory. Each new test needs to be registered in `test/test-list.h`.
1411cb0ef41Sopenharmony_ci
1421cb0ef41Sopenharmony_ciIf you add a new test file, it needs to be registered in three places:
1431cb0ef41Sopenharmony_ci- `CMakeLists.txt`: add the file's name to the `uv_test_sources` list.
1441cb0ef41Sopenharmony_ci- `Makefile.am`: add the file's name to the `test_run_tests_SOURCES` list.
1451cb0ef41Sopenharmony_ci
1461cb0ef41Sopenharmony_ciLook at other tests to see how they should be structured (license boilerplate,
1471cb0ef41Sopenharmony_cithe way entry points are declared, etc.).
1481cb0ef41Sopenharmony_ci
1491cb0ef41Sopenharmony_ciCheck README.md file to find out how to run the test suite and make sure that
1501cb0ef41Sopenharmony_cithere are no test regressions.
1511cb0ef41Sopenharmony_ci
1521cb0ef41Sopenharmony_ci### PUSH
1531cb0ef41Sopenharmony_ci
1541cb0ef41Sopenharmony_ci```
1551cb0ef41Sopenharmony_ci$ git push origin my-feature-branch
1561cb0ef41Sopenharmony_ci```
1571cb0ef41Sopenharmony_ci
1581cb0ef41Sopenharmony_ciGo to https://github.com/username/libuv and select your feature branch.  Click
1591cb0ef41Sopenharmony_cithe 'Pull Request' button and fill out the form.
1601cb0ef41Sopenharmony_ci
1611cb0ef41Sopenharmony_ciPull requests are usually reviewed within a few days.  If there are comments
1621cb0ef41Sopenharmony_cito address, apply your changes in a separate commit and push that to your
1631cb0ef41Sopenharmony_cifeature branch.  Post a comment in the pull request afterwards; GitHub does
1641cb0ef41Sopenharmony_cinot send out notifications when you add commits.
1651cb0ef41Sopenharmony_ci
1661cb0ef41Sopenharmony_ci
1671cb0ef41Sopenharmony_ci[issue tracker]: https://github.com/libuv/libuv/issues
1681cb0ef41Sopenharmony_ci[libuv mailing list]: http://groups.google.com/group/libuv
1691cb0ef41Sopenharmony_ci[libuv discussions forum]: https://github.com/libuv/libuv/discussions
1701cb0ef41Sopenharmony_ci[Google C/C++ style guide]: https://google.github.io/styleguide/cppguide.html
1711cb0ef41Sopenharmony_ci[project maintainers]: https://github.com/libuv/libuv/blob/master/MAINTAINERS.md
172