Skip to content

Commit 597a15c

Browse files
authored
Update protovalidate-cc for empty bytes fix (#517)
1 parent eef12cb commit 597a15c

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

‎scripts/extract/versions.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"protovalidate_cc": {
66
"comment": ["1.2.0 not released yet so target unreleased commit"],
77
"archive": "https://github.com/bufbuild/protovalidate-cc/archive/{ref}.tar.gz",
8-
"ref": "5f8219d280b4ad65abd0adcd17b50d0ed30d2406",
9-
"sha256": "e7b03936881be348ffeeba10f12d6507828f536f53750cbd6de7f1bedacc0e6b"
8+
"ref": "dbc6dfe6855491a62da4fa2ced46ff2163f13d11",
9+
"sha256": "4ed5feee2e64c7484c9bb49e37808ab381adec63d752c152ea9573e74f497e97"
1010
},
1111
"module_overrides": {
1212
"_comment": ["Use newer cel-cpp for Windows compatibility."],

‎scripts/extract_native_sources.py‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ class Repo(typing.NamedTuple):
127127

128128
VENDOR_HEADER_SUFFIXES = (".h", ".hpp", ".inc", ".def")
129129

130+
# A ref pinned by commit rather than by tag.
131+
COMMIT_SHA = re.compile(r"[0-9a-f]{40}")
132+
130133
# The probe package this script injects into the extraction workspace.
131134
PROBE_PACKAGE = "pv_extract"
132135

@@ -157,6 +160,12 @@ def run(cmd: list[str], cwd: Path, *, capture: bool = False) -> str:
157160
return ""
158161

159162

163+
def try_run(cmd: list[str], cwd: Path) -> bool:
164+
"""Runs a command that is allowed to fail, reporting whether it worked."""
165+
print(f" $ {' '.join(cmd[:6])}{' ...' if len(cmd) > 6 else ''}", flush=True)
166+
return subprocess.run(cmd, cwd=cwd, check=False).returncode == 0
167+
168+
160169
class Aquery:
161170
"""Indexed view over one `bazel aquery --output=jsonproto` result."""
162171

@@ -767,22 +776,22 @@ def resolve_in_submodule(path: Path, ref: str) -> str:
767776
found = git(path, "rev-parse", "--verify", "--quiet", candidate, check=False)
768777
if found:
769778
return found
770-
# Not present locally yet so fetch first.
771-
for fetch_args in (["origin", "tag", ref], ["origin", ref]):
772-
run(
779+
# Not present locally yet, so fetch first.
780+
fetches = [["origin", ref]]
781+
if not COMMIT_SHA.fullmatch(ref):
782+
fetches.insert(0, ["origin", "tag", ref])
783+
for fetch_args in fetches:
784+
if not try_run(
773785
["git", "-C", str(path), "fetch", "--depth", "1", *fetch_args],
774786
cwd=REPO_ROOT,
775-
)
776-
found = git(
777-
path, "rev-parse", "--verify", "--quiet", f"{ref}^{{commit}}", check=False
778-
)
779-
if found:
780-
return found
781-
found = git(
782-
path, "rev-parse", "--verify", "--quiet", "FETCH_HEAD^{commit}", check=False
783-
)
784-
if found:
785-
return found
787+
):
788+
continue
789+
for candidate in (f"{ref}^{{commit}}", "FETCH_HEAD^{commit}"):
790+
found = git(
791+
path, "rev-parse", "--verify", "--quiet", candidate, check=False
792+
)
793+
if found:
794+
return found
786795
message = f"could not resolve {ref} in {path}"
787796
raise SystemExit(message)
788797

0 commit comments

Comments
 (0)