David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame^] | 1 | # Developer Guide |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Building |
| 6 | |
| 7 | Gitiles requires [Buck](http://facebook.github.io/buck/) to build. |
| 8 | |
| 9 | ``` |
| 10 | sudo apt-get install ant |
| 11 | cd ${HOME} |
| 12 | git clone https://github.com/facebook/buck.git |
| 13 | cd buck |
| 14 | ant |
| 15 | sudo ln -s ${PWD}/bin/buck /usr/bin/buck |
| 16 | cd /path/to/gitiles |
| 17 | git submodule update --init |
| 18 | buck build all |
| 19 | buck test |
| 20 | ``` |
| 21 | |
| 22 | |
| 23 | ## Testing |
| 24 | |
| 25 | ``` |
| 26 | cd /path/to/repositories # Don't run from the gitiles repo. |
| 27 | /path/to/gitiles/tools/run_dev.sh |
| 28 | ``` |
| 29 | |
| 30 | This will recompile and start a development server. Open |
| 31 | http://localhost:8080/ to view your local copy of gitiles, which |
| 32 | will serve any repositories under `/path/to/repositories`. |
| 33 | |
| 34 | To run unit tests, run `buck test`. |
| 35 | |
| 36 | |
| 37 | ## Eclipse IDE |
| 38 | |
| 39 | If you'd like to use Eclipse to edit Gitiles, first generate a project file: |
| 40 | |
| 41 | ``` |
| 42 | ./bucklets/tools/eclipse.py --src |
| 43 | ``` |
| 44 | |
| 45 | Import the project in Eclipse: |
| 46 | |
| 47 | ``` |
| 48 | File -> Import -> Existing Projects into Workpace |
| 49 | ``` |
| 50 | |
| 51 | The project only needs to be rebuilt if the source roots or third-party |
| 52 | libraries have changed. For best results, ensure the project is closed in |
| 53 | Eclipse before rebuilding. |
| 54 | |
| 55 | |
| 56 | ## Code Style |
| 57 | |
| 58 | Java code in Gitiles follows the [Google Java Style Guide][java-style] |
| 59 | with a 100-column limit. |
| 60 | |
| 61 | Code should be automatically formatted using [google-java-format][fmt] |
| 62 | prior to sending a code review. There is currently no Eclipse |
| 63 | formatter, but the tool can be run from the command line: |
| 64 | |
| 65 | ``` |
| 66 | java -jar /path/to/google-java-format-1.0-all-deps.jar -i path/to/java/File.java |
| 67 | ``` |
| 68 | |
| 69 | CSS in Gitiles follows the [SUIT CSS naming conventions][suit]. |
| 70 | |
| 71 | [java-style]: https://google.github.io/styleguide/javaguide.html |
| 72 | [fmt]: https://github.com/google/google-java-format |
| 73 | [suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md |
| 74 | |
| 75 | ## Code Review |
| 76 | |
| 77 | Gitiles uses Gerrit for code review: |
| 78 | https://gerrit-review.googlesource.com/ |
| 79 | |
| 80 | Gitiles uses the ["git push" workflow][1] with server |
| 81 | https://gerrit.googlesource.com/gitiles. You will need a |
| 82 | [generated cookie][2]. |
| 83 | |
| 84 | [1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push |
| 85 | [2]: https://gerrit.googlesource.com/new-password |
| 86 | |
| 87 | Gerrit depends on "Change-Id" annotations in your commit message. |
| 88 | If you try to push a commit without one, it will explain how to |
| 89 | install the proper git-hook: |
| 90 | |
| 91 | ``` |
| 92 | curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \ |
| 93 | https://gerrit-review.googlesource.com/tools/hooks/commit-msg |
| 94 | chmod +x `git rev-parse --git-dir`/hooks/commit-msg |
| 95 | ``` |
| 96 | |
| 97 | Before you create your local commit (which you'll push to Gerrit) |
| 98 | you will need to set your email to match your Gerrit account: |
| 99 | |
| 100 | ``` |
| 101 | git config --local --add user.email [email protected] |
| 102 | ``` |
| 103 | |
| 104 | Normally you will create code reviews by pushing for master: |
| 105 | |
| 106 | ``` |
| 107 | git push origin HEAD:refs/for/master |
| 108 | ``` |