blob: 82fedb09d964b0368dc61d26df3d8713352a9379 [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
Ian McKellar1bda1c22017-07-24 15:23:40 -07009You need to use Java for building Gitiles. You can install Bazel from
Fabien Sanglard8cc50222022-09-01 11:09:41 -070010bazel.build: https://bazel.build/versions/master/docs/install.html .
11Alternatively, you can use `apt-get`.
David Pursehoused45b0f82016-08-25 09:37:29 +090012
13```
Fabien Sanglard8cc50222022-09-01 11:09:41 -070014$ sudo apt-get update
15$ sudo apt-get install bazel
David Pursehoused45b0f82016-08-25 09:37:29 +090016```
17
Fabien Sanglard8cc50222022-09-01 11:09:41 -070018The best way to build and run gitiles is to use bazelisk.
19
20```
21$ go install github.com/bazelbuild/bazelisk@latest
22$ export PATH=$PATH:$(go env GOPATH)/bin
23```
24You are now ready to build and test.
25
26```
27$ bazelisk build //:gitiles
28$ bazelisk test //...
29```
30
31## Troubleshooting
32
33If you encounter build errors such as:
34
35```
36Error in execute: Argument 0 of execute is neither a path, label, nor string.
37```
38
39Make sure you are using python2. For debian users, the command
40is:
41
42```
43sudo apt-get install python-is-python2
44```
45
46Upon uploading your new CL, if you encounter a message related to a
47missing `Change-Id`, you are missing the commit hook. Likely the command
48to download it should appear in the Hint section of the message. If it
49does not, use the following command:
50
51```
52f=`git rev-parse --git-dir`/hooks/commit-msg ; mkdir -p $(dirname $f) ; curl -Lo $f https://gerrit-review.googlesource.com/tools/hooks/commit-msg ; chmod +x $f
53```
David Pursehoused45b0f82016-08-25 09:37:29 +090054
ev1stensberg966c93a2018-09-26 10:56:49 +020055## Running Locally and Testing
David Pursehoused45b0f82016-08-25 09:37:29 +090056
57```
58cd /path/to/repositories # Don't run from the gitiles repo.
59/path/to/gitiles/tools/run_dev.sh
60```
61
62This will recompile and start a development server. Open
63http://localhost:8080/ to view your local copy of gitiles, which
64will serve any repositories under `/path/to/repositories`.
65
Marco Miller54dad4e2020-01-06 18:15:22 -050066To run unit tests, refer to the aforementioned bazel test command.
David Pursehoused45b0f82016-08-25 09:37:29 +090067
Fabien Sanglard8cc50222022-09-01 11:09:41 -070068## Pushing your changes
69This repository does not work with `repo` tool. To push your CL to
70staging, use the following command.
71
72```
73git push origin HEAD:refs/for/master
74```
75
David Pursehoused45b0f82016-08-25 09:37:29 +090076
77## Eclipse IDE
78
79If you'd like to use Eclipse to edit Gitiles, first generate a project file:
80
81```
David Ostrovskybf2c3912016-11-21 01:37:28 +010082tools/eclipse/project.sh
David Pursehoused45b0f82016-08-25 09:37:29 +090083```
84
85Import the project in Eclipse:
86
87```
88File -> Import -> Existing Projects into Workpace
89```
90
91The project only needs to be rebuilt if the source roots or third-party
92libraries have changed. For best results, ensure the project is closed in
93Eclipse before rebuilding.
94
Saša Živkov83d066f2016-10-05 16:00:32 +020095## Running/Debugging from Eclipse IDE
96
97Running Gitiles from Eclipse requires setting the
98`com.google.gitiles.sourcePath` system property. The property value has to be
99the root folder of the Gitiles source code, for example:
100
101````
102-Dcom.google.gitiles.sourcePath=/home/johndoe/git/gitiles
103````
David Pursehoused45b0f82016-08-25 09:37:29 +0900104
105## Code Style
106
107Java code in Gitiles follows the [Google Java Style Guide][java-style]
108with a 100-column limit.
109
110Code should be automatically formatted using [google-java-format][fmt]
111prior to sending a code review. There is currently no Eclipse
112formatter, but the tool can be run from the command line:
113
114```
David Pursehousef35521a2018-09-27 17:05:08 +0900115java -jar /path/to/google-java-format.jar -i path/to/java/File.java
David Pursehoused45b0f82016-08-25 09:37:29 +0900116```
117
118CSS in Gitiles follows the [SUIT CSS naming conventions][suit].
119
120[java-style]: https://google.github.io/styleguide/javaguide.html
121[fmt]: https://github.com/google/google-java-format
122[suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md
123
124## Code Review
125
126Gitiles uses Gerrit for code review:
127https://gerrit-review.googlesource.com/
128
129Gitiles uses the ["git push" workflow][1] with server
130https://gerrit.googlesource.com/gitiles. You will need a
131[generated cookie][2].
132
133[1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push
134[2]: https://gerrit.googlesource.com/new-password
135
136Gerrit depends on "Change-Id" annotations in your commit message.
137If you try to push a commit without one, it will explain how to
138install the proper git-hook:
139
140```
141curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
142 https://gerrit-review.googlesource.com/tools/hooks/commit-msg
143chmod +x `git rev-parse --git-dir`/hooks/commit-msg
144```
145
146Before you create your local commit (which you'll push to Gerrit)
147you will need to set your email to match your Gerrit account:
148
149```
150git config --local --add user.email [email protected]
151```
152
153Normally you will create code reviews by pushing for master:
154
155```
156git push origin HEAD:refs/for/master
157```
Dave Borowitz004c6c02017-08-28 14:36:28 -0400158
159## Releases
160
161Gitiles artifacts are published to the [gerrit-maven
162bucket](http://gerrit-maven.storage.googleapis.com/). To release a new version,
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600163you must have write access to this bucket. See
164[Deploy Gerrit
165Artifacts](https://gerrit-review.googlesource.com/Documentation/dev-release-deploy-config.html)
166for PGP key setup and Google Cloud Storage access setup.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400167
Sven Selbergbc3830e2022-02-10 09:13:06 +0100168First, increment `GITILES_VERSION` in `version.bzl`, Gitiles uses
169[Semantic Versioning](https://semver.org).
170Get your change reviewed and submitted.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400171
172Then, run:
173
174```
175./tools/maven/mvn.sh deploy
176```
177
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600178Tag the release with a signed, annotated tag matching the version number, for
179example "v0.4-1".
David Pursehousee34a28c2017-08-29 08:47:11 +0900180
Dave Borowitz004c6c02017-08-28 14:36:28 -0400181Once released, Maven projects can consume the new version as long as they point
182at the proper repository URL. Similarly, Bazel projects using the `maven_jar`
183bazlet can use the new version with `repository = GERRIT`.