blob: 70b050ecbf11d9c7d5f0a42444f66c1f24bf84bc [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
Antoine Mussodaac5902022-09-08 15:56:06 +020039Make sure you have `python` available in your PATH. Since Debian 11 and Ubuntu
4020.04 LTS (focal), there is no `/usr/bin/python` provided by default. You can
41install a package to provide a link to Python 3:
Fabien Sanglard8cc50222022-09-01 11:09:41 -070042
43```
Antoine Mussodaac5902022-09-08 15:56:06 +020044sudo apt-get install python-is-python3
Fabien Sanglard8cc50222022-09-01 11:09:41 -070045```
46
47Upon uploading your new CL, if you encounter a message related to a
48missing `Change-Id`, you are missing the commit hook. Likely the command
49to download it should appear in the Hint section of the message. If it
50does not, use the following command:
51
52```
53f=`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
54```
David Pursehoused45b0f82016-08-25 09:37:29 +090055
ev1stensberg966c93a2018-09-26 10:56:49 +020056## Running Locally and Testing
David Pursehoused45b0f82016-08-25 09:37:29 +090057
58```
59cd /path/to/repositories # Don't run from the gitiles repo.
60/path/to/gitiles/tools/run_dev.sh
61```
62
63This will recompile and start a development server. Open
64http://localhost:8080/ to view your local copy of gitiles, which
65will serve any repositories under `/path/to/repositories`.
66
Marco Miller54dad4e2020-01-06 18:15:22 -050067To run unit tests, refer to the aforementioned bazel test command.
David Pursehoused45b0f82016-08-25 09:37:29 +090068
Fabien Sanglard8cc50222022-09-01 11:09:41 -070069## Pushing your changes
70This repository does not work with `repo` tool. To push your CL to
71staging, use the following command.
72
73```
74git push origin HEAD:refs/for/master
75```
76
David Pursehoused45b0f82016-08-25 09:37:29 +090077
78## Eclipse IDE
79
80If you'd like to use Eclipse to edit Gitiles, first generate a project file:
81
82```
David Ostrovskybf2c3912016-11-21 01:37:28 +010083tools/eclipse/project.sh
David Pursehoused45b0f82016-08-25 09:37:29 +090084```
85
86Import the project in Eclipse:
87
88```
89File -> Import -> Existing Projects into Workpace
90```
91
92The project only needs to be rebuilt if the source roots or third-party
93libraries have changed. For best results, ensure the project is closed in
94Eclipse before rebuilding.
95
Saša Živkov83d066f2016-10-05 16:00:32 +020096## Running/Debugging from Eclipse IDE
97
98Running Gitiles from Eclipse requires setting the
99`com.google.gitiles.sourcePath` system property. The property value has to be
100the root folder of the Gitiles source code, for example:
101
102````
103-Dcom.google.gitiles.sourcePath=/home/johndoe/git/gitiles
104````
David Pursehoused45b0f82016-08-25 09:37:29 +0900105
106## Code Style
107
108Java code in Gitiles follows the [Google Java Style Guide][java-style]
109with a 100-column limit.
110
111Code should be automatically formatted using [google-java-format][fmt]
112prior to sending a code review. There is currently no Eclipse
113formatter, but the tool can be run from the command line:
114
115```
David Pursehousef35521a2018-09-27 17:05:08 +0900116java -jar /path/to/google-java-format.jar -i path/to/java/File.java
David Pursehoused45b0f82016-08-25 09:37:29 +0900117```
118
119CSS in Gitiles follows the [SUIT CSS naming conventions][suit].
120
121[java-style]: https://google.github.io/styleguide/javaguide.html
122[fmt]: https://github.com/google/google-java-format
123[suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md
124
125## Code Review
126
127Gitiles uses Gerrit for code review:
128https://gerrit-review.googlesource.com/
129
130Gitiles uses the ["git push" workflow][1] with server
131https://gerrit.googlesource.com/gitiles. You will need a
132[generated cookie][2].
133
134[1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push
135[2]: https://gerrit.googlesource.com/new-password
136
137Gerrit depends on "Change-Id" annotations in your commit message.
138If you try to push a commit without one, it will explain how to
139install the proper git-hook:
140
141```
142curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \
143 https://gerrit-review.googlesource.com/tools/hooks/commit-msg
144chmod +x `git rev-parse --git-dir`/hooks/commit-msg
145```
146
147Before you create your local commit (which you'll push to Gerrit)
148you will need to set your email to match your Gerrit account:
149
150```
151git config --local --add user.email [email protected]
152```
153
154Normally you will create code reviews by pushing for master:
155
156```
157git push origin HEAD:refs/for/master
158```
Dave Borowitz004c6c02017-08-28 14:36:28 -0400159
160## Releases
161
162Gitiles artifacts are published to the [gerrit-maven
163bucket](http://gerrit-maven.storage.googleapis.com/). To release a new version,
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600164you must have write access to this bucket. See
165[Deploy Gerrit
166Artifacts](https://gerrit-review.googlesource.com/Documentation/dev-release-deploy-config.html)
167for PGP key setup and Google Cloud Storage access setup.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400168
Sven Selbergbc3830e2022-02-10 09:13:06 +0100169First, increment `GITILES_VERSION` in `version.bzl`, Gitiles uses
170[Semantic Versioning](https://semver.org).
171Get your change reviewed and submitted.
Dave Borowitz004c6c02017-08-28 14:36:28 -0400172
173Then, run:
174
175```
176./tools/maven/mvn.sh deploy
177```
178
Nasser Grainawibe3c4602021-08-17 09:16:52 -0600179Tag the release with a signed, annotated tag matching the version number, for
180example "v0.4-1".
David Pursehousee34a28c2017-08-29 08:47:11 +0900181
Dave Borowitz004c6c02017-08-28 14:36:28 -0400182Once released, Maven projects can consume the new version as long as they point
183at the proper repository URL. Similarly, Bazel projects using the `maven_jar`
184bazlet can use the new version with `repository = GERRIT`.