Skip to content

Commit

Permalink
fix: compatibility_level is optional
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy committed Aug 9, 2024
1 parent e9e826b commit 3fdaa4e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bzlreg/module_bazel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,15 @@ auto bzlreg::module_bazel::parse( //

auto mod = module_bazel{};
mod.name = attr_as_string(result.attrs.at("name"));
mod.version = attr_as_string(result.attrs.at("version"));
mod.compatibility_level = attr_as_int(result.attrs.at("compatibility_level"));
if(result.attrs.contains("version")) {
mod.version = attr_as_string(result.attrs.at("version"));
}
if(result.attrs.contains("compatibility_level")) {
mod.compatibility_level =
attr_as_int(result.attrs.at("compatibility_level"));
} else {
mod.compatibility_level = 1;
}

while(!absl::StripAsciiWhitespace(result.contents_after).empty()) {
result = parse_call(result.contents_after);
Expand Down

0 comments on commit 3fdaa4e

Please sign in to comment.