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