blob: 2d4af0f090bbe94cc63f98b115186ec66b267599 [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```
42./bucklets/tools/eclipse.py --src
43```
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
55
56## Code Style
57
58Java code in Gitiles follows the [Google Java Style Guide][java-style]
59with a 100-column limit.
60
61Code should be automatically formatted using [google-java-format][fmt]
62prior to sending a code review. There is currently no Eclipse
63formatter, but the tool can be run from the command line:
64
65```
66java -jar /path/to/google-java-format-1.0-all-deps.jar -i path/to/java/File.java
67```
68
69CSS 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
77Gitiles uses Gerrit for code review:
78https://gerrit-review.googlesource.com/
79
80Gitiles uses the ["git push" workflow][1] with server
81https://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
87Gerrit depends on "Change-Id" annotations in your commit message.
88If you try to push a commit without one, it will explain how to
89install the proper git-hook:
90
91```
92curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
93 https://gerrit-review.googlesource.com/tools/hooks/commit-msg
94chmod +x `git rev-parse --git-dir`/hooks/commit-msg
95```
96
97Before you create your local commit (which you'll push to Gerrit)
98you will need to set your email to match your Gerrit account:
99
100```
101git config --local --add user.email [email protected]
102```
103
104Normally you will create code reviews by pushing for master:
105
106```
107git push origin HEAD:refs/for/master
108```