Skip to content

Commit 87c1410

Browse files
Fix readme markdown
1 parent 8515d8d commit 87c1410

File tree

1 file changed

+64
-48
lines changed

1 file changed

+64
-48
lines changed

README.md

+64-48
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@
77
1. `bazel-diff` is designed for very large Bazel projects. We use Java Protobuf's `parseDelimitedFrom` method alongside Bazel Query's `streamed_proto` output option. These two together allow you to parse Gigabyte or larger protobuf messages. We have tested it with projects containing tens of thousands of targets.
88
2. We avoid usage of large command line query lists when interacting with Bazel, [issue here](https://github.com/bazelbuild/bazel/issues/8609). When you interact with Bazel with thousands of query parameters you can reach an upper maximum limit, seeing this error:
99

10-
bash: /usr/local/bin/bazel: Argument list too long
10+
```terminal
11+
bash: /usr/local/bin/bazel: Argument list too long
12+
```
1113

12-
`bazel-diff` is smart enough to prevent these errors
14+
`bazel-diff` is smart enough to prevent these errors
1315
3. `bazel-diff` has been tested with file renames, deletions, and modifications. Works on `bzl` files, `WORKSPACE` files, `BUILD` files and regular files
1416

1517
Track the feature request for target diffing in Bazel [here](https://github.com/bazelbuild/bazel/issues/7962)
1618

1719
This approach was inspired by the [following BazelConf talk](https://www.youtube.com/watch?v=9Dk7mtIm7_A) by Benjamin Peterson.
1820

19-
### Prerequisites
21+
## Prerequisites
2022

2123
* Git
2224
* Bazel 3.3.0 or higher
@@ -26,13 +28,16 @@ This approach was inspired by the [following BazelConf talk](https://www.youtube
2628

2729
To start using `bazel-diff` immediately, simply clone down the repo and then run the example shell script:
2830

29-
git clone https://github.com/Tinder/bazel-diff.git
30-
cd bazel-diff
31-
./bazel-diff-example.sh WORKSPACE_PATH BAZEL_PATH START_GIT_REVISION END_GIT_REVISION
31+
```terminal
32+
git clone https://github.com/Tinder/bazel-diff.git
33+
cd bazel-diff
34+
./bazel-diff-example.sh WORKSPACE_PATH BAZEL_PATH START_GIT_REVISION END_GIT_REVISION
35+
```
3236

3337
Here is a breakdown of those arguments:
38+
3439
* `WORKSPACE_PATH`: Path to directory containing your `WORKSPACE` file in your Bazel project.
35-
* Note: Your project must use Git for `bazel-diff` to work!
40+
* Note: Your project must use Git for `bazel-diff` to work!
3641
* `BAZEL_PATH`: Path to your Bazel executable
3742
* `START_GIT_REVISION`: Starting Git Branch or SHA for your desired commit range
3843
* `END_GIT_REVISION`: Final Git Branch or SHA for your desired commit range
@@ -46,6 +51,7 @@ Open `bazel-diff-example.sh` to see how this is implemented. This is purely an e
4651
## How it works
4752

4853
`bazel-diff` works as follows
54+
4955
* The `modified-filepaths` command is used to fetch the modified filepaths between two Git revisions, we write this list of modified filepaths to a file.
5056

5157
* The previous revision is checked out, then we run `generate-hashes`. This gives us the hashmap representation for the entire Bazel graph, then we write this JSON to a file. We do not pass `modified-filepaths` here since it is the starting revision.
@@ -57,7 +63,8 @@ Open `bazel-diff-example.sh` to see how this is implemented. This is purely an e
5763
## CLI Interface
5864

5965
`bazel-diff` Command
60-
~~~
66+
67+
```terminal
6168
Usage: bazel-diff [-htV] -b=<bazelPath> [-co=<bazelCommandOptions>]
6269
[-fh=<finalHashesJSONPath>] [-o=<outputPath>]
6370
[-sh=<startingHashesJSONPath>] [-so=<bazelStartupOptions>]
@@ -81,14 +88,15 @@ Writes to a file the impacted targets between two Bazel graph JSON files
8188
-so, --bazelStartupOptions=<bazelStartupOptions>
8289
Additional space separated Bazel client startup options used
8390
when invoking Bazel
84-
-t, --tests Return only targets of kind 'test')
91+
-t, --tests Return only targets of kind 'test'
8592
-V, --version Print version information and exit.
8693
-w, --workspacePath=<workspacePath>
8794
Path to Bazel workspace directory.
88-
~~~
95+
```
8996

9097
`modified-filepaths` Command
91-
~~~
98+
99+
```terminal
92100
Usage: bazel-diff modified-filepaths [-hV] -b=<bazelPath>
93101
[-co=<bazelCommandOptions>]
94102
[-so=<bazelStartupOptions>]
@@ -111,10 +119,11 @@ Writes to the file the modified filepaths between two revisions.
111119
-V, --version Print version information and exit.
112120
-w, --workspacePath=<workspacePath>
113121
Path to Bazel workspace directory.
114-
~~~
122+
```
115123

116124
`generate-hashes` Command
117-
~~~
125+
126+
```terminal
118127
Usage: bazel-diff generate-hashes [-hV] -b=<bazelPath>
119128
[-co=<bazelCommandOptions>]
120129
[-m=<modifiedFilepaths>]
@@ -140,7 +149,7 @@ workspace.
140149
-V, --version Print version information and exit.
141150
-w, --workspacePath=<workspacePath>
142151
Path to Bazel workspace directory.
143-
~~~
152+
```
144153

145154
## Installing
146155

@@ -150,18 +159,20 @@ After cloning down the repo, you are good to go, Bazel will handle the rest
150159

151160
To run the project
152161

153-
```
162+
```terminal
154163
bazel run :bazel-diff -- bazel-diff -h
155164
```
156165

157166
### Run Via JAR Release
158167

159-
curl -LO bazel-diff.jar GITHUB_RELEASE_JAR_URL
160-
java -jar bazel-diff.jar -h
168+
```terminal
169+
curl -LO bazel-diff.jar GITHUB_RELEASE_JAR_URL
170+
java -jar bazel-diff.jar -h
171+
```
161172

162173
### Build your own deployable JAR
163174

164-
```
175+
```terminal
165176
bazel build //src/main/java/com/bazel_diff:bazel-diff_deploy.jar
166177
java -jar bazel-bin/src/main/java/com/bazel_diff/bazel-diff_deploy.jar # This JAR can be run anywhere
167178
```
@@ -170,44 +181,46 @@ java -jar bazel-bin/src/main/java/com/bazel_diff/bazel-diff_deploy.jar # This JA
170181

171182
Add the following to your `WORKSPACE` file to add the external repositories, replacing the `RELEASE_ARCHIVE_URL` with the archive url of the bazel-diff release you wish to depend on:
172183

173-
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
174-
175-
http_archive(
176-
name = "bazel_diff",
177-
urls = [
178-
"RELEASE_ARCHIVE_URL",
179-
],
180-
sha256 = "UPDATE_ME",
181-
strip_prefix = "UPDATE_ME"
182-
)
183-
184-
load("@bazel_diff//:repositories.bzl", "bazel_diff_dependencies")
185-
186-
bazel_diff_dependencies()
187-
188-
load("@rules_jvm_external//:defs.bzl", "maven_install")
189-
load("@bazel_diff//:artifacts.bzl", "BAZEL_DIFF_MAVEN_ARTIFACTS")
190-
191-
maven_install(
192-
name = "bazel_diff_maven",
193-
artifacts = BAZEL_DIFF_MAVEN_ARTIFACTS,
194-
repositories = [
195-
"http://uk.maven.org/maven2",
196-
"https://jcenter.bintray.com/",
197-
],
198-
)
184+
```bazel
185+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
186+
187+
http_archive(
188+
name = "bazel_diff",
189+
urls = [
190+
"RELEASE_ARCHIVE_URL",
191+
],
192+
sha256 = "UPDATE_ME",
193+
strip_prefix = "UPDATE_ME"
194+
)
195+
196+
load("@bazel_diff//:repositories.bzl", "bazel_diff_dependencies")
197+
198+
bazel_diff_dependencies()
199+
200+
load("@rules_jvm_external//:defs.bzl", "maven_install")
201+
load("@bazel_diff//:artifacts.bzl", "BAZEL_DIFF_MAVEN_ARTIFACTS")
202+
203+
maven_install(
204+
name = "bazel_diff_maven",
205+
artifacts = BAZEL_DIFF_MAVEN_ARTIFACTS,
206+
repositories = [
207+
"http://uk.maven.org/maven2",
208+
"https://jcenter.bintray.com/",
209+
],
210+
)
211+
```
199212

200213
Now you can simply run `bazel-diff` from your project:
201214

202-
```
215+
```terminal
203216
bazel run @bazel_diff//:bazel-diff -- bazel-diff -h
204217
```
205218

206219
## Running the tests
207220

208221
To run the tests simply run
209222

210-
```
223+
```terminal
211224
bazel test //test/...
212225
```
213226

@@ -216,9 +229,11 @@ bazel test //test/...
216229
We use [SemVer](http://semver.org/) for versioning. For the versions available,
217230
see the [tags on this repository](https://github.com/Tinder/bazel-diff/tags).
218231

219-
License
232+
## License
233+
220234
---
221-
~~~
235+
236+
```text
222237
Copyright (c) 2020, Match Group, LLC
223238
All rights reserved.
224239
@@ -243,3 +258,4 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
243258
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
244259
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
245260
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
261+
```

0 commit comments

Comments
 (0)