Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions scripts/extract/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"protovalidate_cc": {
"comment": ["1.2.0 not released yet so target unreleased commit"],
"archive": "https://github.com/bufbuild/protovalidate-cc/archive/{ref}.tar.gz",
"ref": "5f8219d280b4ad65abd0adcd17b50d0ed30d2406",
"sha256": "e7b03936881be348ffeeba10f12d6507828f536f53750cbd6de7f1bedacc0e6b"
"ref": "dbc6dfe6855491a62da4fa2ced46ff2163f13d11",
"sha256": "4ed5feee2e64c7484c9bb49e37808ab381adec63d752c152ea9573e74f497e97"
},
"module_overrides": {
"_comment": ["Use newer cel-cpp for Windows compatibility."],
Expand Down
37 changes: 23 additions & 14 deletions scripts/extract_native_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ class Repo(typing.NamedTuple):

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

# A ref pinned by commit rather than by tag.
COMMIT_SHA = re.compile(r"[0-9a-f]{40}")

# The probe package this script injects into the extraction workspace.
PROBE_PACKAGE = "pv_extract"

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


def try_run(cmd: list[str], cwd: Path) -> bool:
"""Runs a command that is allowed to fail, reporting whether it worked."""
print(f" $ {' '.join(cmd[:6])}{' ...' if len(cmd) > 6 else ''}", flush=True)
return subprocess.run(cmd, cwd=cwd, check=False).returncode == 0


class Aquery:
"""Indexed view over one `bazel aquery --output=jsonproto` result."""

Expand Down Expand Up @@ -767,22 +776,22 @@ def resolve_in_submodule(path: Path, ref: str) -> str:
found = git(path, "rev-parse", "--verify", "--quiet", candidate, check=False)
if found:
return found
# Not present locally yet so fetch first.
for fetch_args in (["origin", "tag", ref], ["origin", ref]):
run(
# Not present locally yet, so fetch first.
fetches = [["origin", ref]]
if not COMMIT_SHA.fullmatch(ref):
fetches.insert(0, ["origin", "tag", ref])
for fetch_args in fetches:
if not try_run(
["git", "-C", str(path), "fetch", "--depth", "1", *fetch_args],
cwd=REPO_ROOT,
)
found = git(
path, "rev-parse", "--verify", "--quiet", f"{ref}^{{commit}}", check=False
)
if found:
return found
found = git(
path, "rev-parse", "--verify", "--quiet", "FETCH_HEAD^{commit}", check=False
)
if found:
return found
):
continue
for candidate in (f"{ref}^{{commit}}", "FETCH_HEAD^{commit}"):
found = git(
path, "rev-parse", "--verify", "--quiet", candidate, check=False
)
if found:
return found
message = f"could not resolve {ref} in {path}"
raise SystemExit(message)

Expand Down
Loading