blob: 6f809fd1f3b8dbc239b4ecb7fd3d9c2f43fbe684 [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```
Antoine Musso890cc122022-05-21 10:27:58 +020024
25Make sure to initialize and update the git submodules:
26```
27git submodule update --init
28```
29
Fabien Sanglard8cc50222022-09-01 11:09:41 -070030You are now ready to build and test.
31
32```
33$ bazelisk build //:gitiles
34$ bazelisk test //...
35```
36
37## Troubleshooting
38
39If you encounter build errors such as:
40
41```
42Error in execute: Argument 0 of execute is neither a path, label, nor string.
43```
44
Antoine Mussodaac5902022-09-08 15:56:06 +020045Make sure you have `python` available in your PATH. Since Debian 11 and Ubuntu
4620.04 LTS (focal), there is no `/usr/bin/python` provided by default. You can
47install a package to provide a link to Python 3:
Fabien Sanglard8cc50222022-09-01 11:09:41 -070048
49```
Antoine Mussodaac5902022-09-08 15:56:06 +020050sudo apt-get install python-is-python3
Fabien Sanglard8cc50222022-09-01 11:09:41 -070051```
52
53Upon uploading your new CL, if you encounter a message related to a
54missing `Change-Id`, you are missing the commit hook. Likely the command
55to download it should appear in the Hint section of the message. If it
56does not, use the following command:
57
58```
59f=`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
60```
David Pursehoused45b0f82016-08-25 09:37:29 +090061
ev1stensberg966c93a2018-09-26 10:56:49 +020062## Running Locally and Testing
David Pursehoused45b0f82016-08-25 09:37:29 +090063
64```
65cd /path/to/repositories # Don't run from the gitiles repo.
66/path/to/gitiles/tools/run_dev.sh
67```
68
69This will recompile and start a development server. Open
70http://localhost:8080/ to view your local copy of gitiles, which
71will serve any repositories under `/path/to/repositories`.
72
Marco Miller54dad4e2020-01-06 18:15:22 -050073To run unit tests, refer to the aforementioned bazel test command.
David Pursehoused45b0f82016-08-25 09:37:29 +090074
Fabien Sanglard8cc50222022-09-01 11:09:41 -070075## Pushing your changes
76This repository does not work with `repo` tool. To push your CL to
77staging, use the following command.
78
79```
80git push origin HEAD:refs/for/master
81```
82
David Pursehoused45b0f82016-08-25 09:37:29 +090083
84## Eclipse IDE
85
86If you'd like to use Eclipse to edit Gitiles, first generate a project file:
87
88```
David Ostrovskybf2c3912016-11-21 01:37:28 +010089tools/eclipse/project.sh
David Pursehoused45b0f82016-08-25 09:37:29 +090090```
91
92Import the project in Eclipse:
93
94```
95File -> Import -> Existing Projects into Workpace
96```
97
98The project only needs to be rebuilt if the source roots or third-party
99libraries have changed. For best results, ensure the project is closed in
100Eclipse before rebuilding.
101
Saša Živkov83d066f2016-10-05 16:00:32 +0200102## Running/Debugging from Eclipse IDE
103
104Running Gitiles from Eclipse requires setting the
105`com.google.gitiles.sourcePath` system property. The property value has to be
106the root folder of the Gitiles source code, for example:
107
108````
109-Dcom.google.gitiles.sourcePath=/home/johndoe/git/gitiles
110````
David Pursehoused45b0f82016-08-25 09:37:29 +0900111
112## Code Style
113
114Java code in Gitiles follows the [Google Java Style Guide][java-style]
115with a 100-column limit.
116
117Code should be automatically formatted using [google-java-format][fmt]
118prior to sending a code review. There is currently no Eclipse
119formatter, but the tool can be run from the command line:
120
121```
David Pursehousef35521a2018-09-27 17:05:08 +0900122java -jar /path/to/google-java-format.jar -i path/to/java/File.java
David Pursehoused45b0f82016-08-25 09:37:29 +0900123```
124
125CSS in Gitiles follows the [SUIT CSS naming conventions][suit].
126
127[java-style]: https://google.github.io/styleguide/javaguide.html
128[fmt]: https://github.com/google/google-java-format
129[suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md
130
131## Code Review
132
133Gitiles uses Gerrit for code review:
134https://gerrit-review.googlesource.com/
135
136Gitiles uses the ["git push" workflow][1] with server
137https://gerrit.googlesource.com/gitiles. You will need a
138[generated cookie][2].
139
140[1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push
141[2]: https://gerrit.googlesource.com/new-password
142
143Gerrit depends on "Change-Id" annotations in your commit message.
144If you try to push a commit without one, it will explain how to
145install the proper git-hook:
146
147```
148curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
149 https://gerrit-review.googlesource.com/tools/hooks/commit-msg
150chmod +x `git rev-parse --git-dir`/hooks/commit-msg
151```
152
153Before you create your local commit (which you'll push to Gerrit)
154you will need to set your email to match your Gerrit account:
155
156```
157git config --local --add user.email [email protected]
158```
159
160Normally you will create code reviews by pushing for master:
161
162```
163git push origin HEAD:refs/for/master
164```
Dave Borowitz004c6c02017-08-28 14:36:28 -0400165
166## Releases
167
168Gitiles artifacts are published to the [gerrit-maven
169bucket](http://gerrit-maven.storage.googleapis.com/). To release a new version,
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600170you must have write access to this bucket. See
171[Deploy Gerrit
172Artifacts](https://gerrit-review.googlesource.com/Documentation/dev-release-deploy-config.html)
173for PGP key setup and Google Cloud Storage access setup.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400174
Sven Selbergbc3830e2022-02-10 09:13:06 +0100175First, increment `GITILES_VERSION` in `version.bzl`, Gitiles uses
176[Semantic Versioning](https://semver.org).
177Get your change reviewed and submitted.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400178
179Then, run:
180
181```
182./tools/maven/mvn.sh deploy
183```
184
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600185Tag the release with a signed, annotated tag matching the version number, for
186example "v0.4-1".
David Pursehousee34a28c2017-08-29 08:47:11 +0900187
Dave Borowitz004c6c02017-08-28 14:36:28 -0400188Once released, Maven projects can consume the new version as long as they point
189at the proper repository URL. Similarly, Bazel projects using the `maven_jar`
190bazlet can use the new version with `repository = GERRIT`.