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