David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 1 | # Developer Guide |
| 2 | |
| 3 | [TOC] |
| 4 | |
| 5 | ## Building |
| 6 | |
David Ostrovsky | bf2c391 | 2016-11-21 01:37:28 +0100 | [diff] [blame] | 7 | Gitiles requires [Bazel](https://bazel.build/) to build. |
| 8 | |
Ian McKellar | 1bda1c2 | 2017-07-24 15:23:40 -0700 | [diff] [blame] | 9 | You need to use Java for building Gitiles. You can install Bazel from |
| 10 | bazel.build: https://bazel.build/versions/master/docs/install.html |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 11 | |
| 12 | ``` |
ev1stensberg | 966c93a | 2018-09-26 10:56:49 +0200 | [diff] [blame] | 13 | bazel build //:gitiles |
David Ostrovsky | bf2c391 | 2016-11-21 01:37:28 +0100 | [diff] [blame] | 14 | bazel test //... |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 15 | ``` |
| 16 | |
| 17 | |
ev1stensberg | 966c93a | 2018-09-26 10:56:49 +0200 | [diff] [blame] | 18 | ## Running Locally and Testing |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 19 | |
| 20 | ``` |
| 21 | cd /path/to/repositories # Don't run from the gitiles repo. |
| 22 | /path/to/gitiles/tools/run_dev.sh |
| 23 | ``` |
| 24 | |
| 25 | This will recompile and start a development server. Open |
| 26 | http://localhost:8080/ to view your local copy of gitiles, which |
| 27 | will serve any repositories under `/path/to/repositories`. |
| 28 | |
David Ostrovsky | bf2c391 | 2016-11-21 01:37:28 +0100 | [diff] [blame] | 29 | To run unit tests, run `bazel test ...`. |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 30 | |
| 31 | |
| 32 | ## Eclipse IDE |
| 33 | |
| 34 | If you'd like to use Eclipse to edit Gitiles, first generate a project file: |
| 35 | |
| 36 | ``` |
David Ostrovsky | bf2c391 | 2016-11-21 01:37:28 +0100 | [diff] [blame] | 37 | tools/eclipse/project.sh |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 38 | ``` |
| 39 | |
| 40 | Import the project in Eclipse: |
| 41 | |
| 42 | ``` |
| 43 | File -> Import -> Existing Projects into Workpace |
| 44 | ``` |
| 45 | |
| 46 | The project only needs to be rebuilt if the source roots or third-party |
| 47 | libraries have changed. For best results, ensure the project is closed in |
| 48 | Eclipse before rebuilding. |
| 49 | |
Saša Živkov | 83d066f | 2016-10-05 16:00:32 +0200 | [diff] [blame] | 50 | ## Running/Debugging from Eclipse IDE |
| 51 | |
| 52 | Running Gitiles from Eclipse requires setting the |
| 53 | `com.google.gitiles.sourcePath` system property. The property value has to be |
| 54 | the root folder of the Gitiles source code, for example: |
| 55 | |
| 56 | ```` |
| 57 | -Dcom.google.gitiles.sourcePath=/home/johndoe/git/gitiles |
| 58 | ```` |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 59 | |
| 60 | ## Code Style |
| 61 | |
| 62 | Java code in Gitiles follows the [Google Java Style Guide][java-style] |
| 63 | with a 100-column limit. |
| 64 | |
| 65 | Code should be automatically formatted using [google-java-format][fmt] |
| 66 | prior to sending a code review. There is currently no Eclipse |
| 67 | formatter, but the tool can be run from the command line: |
| 68 | |
| 69 | ``` |
David Pursehouse | f35521a | 2018-09-27 17:05:08 +0900 | [diff] [blame^] | 70 | java -jar /path/to/google-java-format.jar -i path/to/java/File.java |
David Pursehouse | d45b0f8 | 2016-08-25 09:37:29 +0900 | [diff] [blame] | 71 | ``` |
| 72 | |
| 73 | CSS in Gitiles follows the [SUIT CSS naming conventions][suit]. |
| 74 | |
| 75 | [java-style]: https://google.github.io/styleguide/javaguide.html |
| 76 | [fmt]: https://github.com/google/google-java-format |
| 77 | [suit]: https://github.com/suitcss/suit/blob/master/doc/naming-conventions.md |
| 78 | |
| 79 | ## Code Review |
| 80 | |
| 81 | Gitiles uses Gerrit for code review: |
| 82 | https://gerrit-review.googlesource.com/ |
| 83 | |
| 84 | Gitiles uses the ["git push" workflow][1] with server |
| 85 | https://gerrit.googlesource.com/gitiles. You will need a |
| 86 | [generated cookie][2]. |
| 87 | |
| 88 | [1]: https://gerrit-review.googlesource.com/Documentation/user-upload.html#_git_push |
| 89 | [2]: https://gerrit.googlesource.com/new-password |
| 90 | |
| 91 | Gerrit depends on "Change-Id" annotations in your commit message. |
| 92 | If you try to push a commit without one, it will explain how to |
| 93 | install the proper git-hook: |
| 94 | |
| 95 | ``` |
| 96 | curl -Lo `git rev-parse --git-dir`/hooks/commit-msg \ |
| 97 | https://gerrit-review.googlesource.com/tools/hooks/commit-msg |
| 98 | chmod +x `git rev-parse --git-dir`/hooks/commit-msg |
| 99 | ``` |
| 100 | |
| 101 | Before you create your local commit (which you'll push to Gerrit) |
| 102 | you will need to set your email to match your Gerrit account: |
| 103 | |
| 104 | ``` |
| 105 | git config --local --add user.email [email protected] |
| 106 | ``` |
| 107 | |
| 108 | Normally you will create code reviews by pushing for master: |
| 109 | |
| 110 | ``` |
| 111 | git push origin HEAD:refs/for/master |
| 112 | ``` |
Dave Borowitz | 004c6c0 | 2017-08-28 14:36:28 -0400 | [diff] [blame] | 113 | |
| 114 | ## Releases |
| 115 | |
| 116 | Gitiles artifacts are published to the [gerrit-maven |
| 117 | bucket](http://gerrit-maven.storage.googleapis.com/). To release a new version, |
| 118 | you must have write access to this bucket. |
| 119 | |
| 120 | First, increment `GITILES_VERSION` in `version.bzl`. Technically, Gitiles uses |
| 121 | the |
| 122 | ["build number" scheme](http://mojo.codehaus.org/versions-maven-plugin/version-rules.html), |
| 123 | which in practice just means incrementing the last component (after the `-`) by |
| 124 | one. Get your change reviewed and submitted. |
| 125 | |
| 126 | Then, run: |
| 127 | |
| 128 | ``` |
| 129 | ./tools/maven/mvn.sh deploy |
| 130 | ``` |
| 131 | |
David Pursehouse | e34a28c | 2017-08-29 08:47:11 +0900 | [diff] [blame] | 132 | Tag the release with an annotated tag matching the version number. |
| 133 | |
Dave Borowitz | 004c6c0 | 2017-08-28 14:36:28 -0400 | [diff] [blame] | 134 | Once released, Maven projects can consume the new version as long as they point |
| 135 | at the proper repository URL. Similarly, Bazel projects using the `maven_jar` |
| 136 | bazlet can use the new version with `repository = GERRIT`. |