Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions doc/contributor/howto-guide-adding-generated-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ bazel_output_base="$(bazelisk info output_base)"

You may need to
[Send a PR to update the googleapis SHA to the latest version](../contributor/howto-guide-update-googleapis-sha.md).
Wait until that is submitted before proceeding any further for the following 2
cases:
Wait until that is submitted before proceeding any further for the case:

1. The dependency does not exist at the pinned version of the googleapis repo.
- The dependency does not exist at the pinned version of the googleapis repo.

```shell
bazelisk --batch query --noshow_progress --noshow_loading_progress \
Expand All @@ -52,9 +51,6 @@ bazelisk --batch query --noshow_progress --noshow_loading_progress \
ERROR: no targets found beneath 'commerce'
```

2. Check `$bazel_output_base/external/googleapis~/api-index-v1.json`, if
`$library` with the correct version is not in `apis` section.

### Edit the scripts and configuration

Update the
Expand Down Expand Up @@ -98,7 +94,7 @@ Find the list of `.proto` files that will need to be included:

```shell
find "${bazel_output_base}/external/googleapis+/${subdir}" -name '*.proto' -print0 |
xargs -0 grep -l '^service'
xargs -0 grep -l '^service' | sed 's|.*/external/googleapis/||' | sort

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The sed pattern .*/external/googleapis/ will not match the paths generated by the find command because the directory name contains a + (i.e., external/googleapis+). As a result, the prefix will not be stripped.

Using googleapis[^/]*/ instead will robustly handle both Bzlmod (googleapis+ or googleapis~) and legacy workspace layouts.

Suggested change
xargs -0 grep -l '^service' | sed 's|.*/external/googleapis/||' | sort
xargs -0 grep -l '^service' | sed 's|.*/external/googleapis[^/]*/||' | sort

```

> **Note:** While older service definitions may not include the version
Expand Down
Loading