9991822f8cfcef020fa7e99a6d47303bd900f721

Author
Markus Hofbauer <markus.hofbauer@tum.de>
Committer
GitHub <noreply@github.com>
Date

Message

feat(bazel): add bzlmod integrity gen function (#12797)

Co-authored-by: Carlo Sala <carlosalag@protonmail.com>

Diff

 1diff --git a/plugins/bazel/README.md b/plugins/bazel/README.md
 2index eba4175bc50fcd576cb7c9a5acd3ba936618301b..b0c34a15ffd519df6ad2f085d2bc90aa35232dbc 100644
 3--- a/plugins/bazel/README.md
 4+++ b/plugins/bazel/README.md
 5@@ -1,6 +1,7 @@
 6 # Bazel plugin
 7 
 8-This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool that scalably supports multi-language and multi-platform projects.
 9+This plugin adds completion and aliases for [bazel](https://bazel.build), an open-source build and test tool
10+that scalably supports multi-language and multi-platform projects.
11 
12 To use it, add `bazel` to the plugins array in your zshrc file:
13 
14@@ -14,9 +15,15 @@ The plugin has a copy of [the completion script from the git repository][1].
15 
16 ## Aliases
17 
18-| Alias   | Command                                | Description                                            |
19-| ------- | -------------------------------------- | ------------------------------------------------------ |
20-| bzb      | `bazel build`                          | The `bazel build` command                              |
21-| bzt      | `bazel test`                           | The `bazel test` command                               |
22-| bzr      | `bazel run`                            | The `bazel run` command                                |
23-| bzq      | `bazel query`                          | The `bazel query` command                              |
24+| Alias | Command       | Description               |
25+| ----- | ------------- | ------------------------- |
26+| bzb   | `bazel build` | The `bazel build` command |
27+| bzt   | `bazel test`  | The `bazel test` command  |
28+| bzr   | `bazel run`   | The `bazel run` command   |
29+| bzq   | `bazel query` | The `bazel query` command |
30+
31+## Functions
32+
33+| Function | Description                      |
34+| -------- | -------------------------------- |
35+| sri-hash | Generate SRI hash used by bzlmod |
36diff --git a/plugins/bazel/bazel.plugin.zsh b/plugins/bazel/bazel.plugin.zsh
37index d239a06b57e8d3cb1e1c93636f8985aeec5b2c93..818d5652ba52f309d101f1dd41dc7cb89956d78e 100644
38--- a/plugins/bazel/bazel.plugin.zsh
39+++ b/plugins/bazel/bazel.plugin.zsh
40@@ -3,3 +3,7 @@ alias bzb='bazel build'
41 alias bzt='bazel test'
42 alias bzr='bazel run'
43 alias bzq='bazel query'
44+
45+sri-hash() {
46+    openssl dgst -sha256 -binary $1 | openssl base64 -A | sed 's/^/sha256-/'
47+}