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