Repository navigation
Refresh trusted review publishers before readiness #1751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5c8d0e3
1e737f6
b67aef4
62d5097
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,12 +108,21 @@ def _has_replacement_refs(common_dir: Path) -> bool: | |
| return b" refs/replace/" in packed | ||
|
|
||
|
|
||
| def _remote_workflow(worktree: Path, branch: str, previous: Config | None) -> tuple[Config, str]: | ||
| def _remote_workflow(worktree: Path, branch: str, previous: Config | None, *, refresh: bool) -> tuple[Config, str]: | ||
| source = f"origin/{branch}:workflow.toml" | ||
| hint = "Fetch the trusted base workflow, or supply --config for bootstrap or an override." | ||
| ref = f"refs/remotes/origin/{branch}" | ||
| if refresh: | ||
| fetched = _proc.run( | ||
| ["git", "fetch", "--quiet", "--no-tags", "--no-recurse-submodules", | ||
| "--no-write-fetch-head", "origin", f"+refs/heads/{branch}:{ref}"], | ||
| cwd=worktree, env_allowlist=worktree_mod.GIT_ENV, timeout=60, | ||
| ) | ||
| if fetched.exit_code != 0: | ||
| raise ConfigError(f"could not refresh origin/{branch}. {hint}") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Fetch failure drops git's diagnostic When the refresh fetch fails (authentication, network, a missing remote branch or a 60s timeout that returns a non-zero exit), the user only sees |
||
| directory_args = ["--path-format=absolute", "--git-common-dir"] if previous is not None else [] | ||
| resolved = _proc.run( | ||
| ["git", "rev-parse", *directory_args, "--verify", f"refs/remotes/origin/{branch}^{{commit}}"], | ||
| ["git", "rev-parse", *directory_args, "--verify", f"{ref}^{{commit}}"], | ||
| cwd=worktree, env_allowlist=worktree_mod.GIT_ENV, timeout=60, | ||
| ) | ||
| if resolved.exit_code != 0: | ||
|
|
@@ -140,7 +149,7 @@ def _remote_workflow(worktree: Path, branch: str, previous: Config | None) -> tu | |
| raise ConfigError(f"{source}: {exc}. {hint}") from None | ||
|
|
||
|
|
||
| def load_trusted(worktree: Path, *, previous: Config | None = None) -> Config: | ||
| def load_trusted(worktree: Path, *, previous: Config | None = None, refresh: bool = False) -> Config: | ||
| """Select delivery policy using Git's origin default and its trusted workflow.""" | ||
| prefix = "refs/remotes/origin/" | ||
| default = _proc.run( | ||
|
|
@@ -154,10 +163,10 @@ def load_trusted(worktree: Path, *, previous: Config | None = None) -> Config: | |
| "or supply --config for bootstrap or an override." | ||
| ) | ||
| branch = ref.removeprefix(prefix) | ||
| policy, revision = _remote_workflow(worktree, branch, previous) | ||
| policy, revision = _remote_workflow(worktree, branch, previous, refresh=refresh) | ||
| if policy.base_branch == branch: | ||
| return replace(policy, trusted_base_revision=revision) | ||
| base, revision = _remote_workflow(worktree, policy.base_branch, previous) | ||
| base, revision = _remote_workflow(worktree, policy.base_branch, previous, refresh=refresh) | ||
| if base.base_branch != policy.base_branch: | ||
| raise ConfigError("trusted origin workflows disagree on repo.base; align them or supply --config") | ||
| return replace(base, trusted_base_revision=revision) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Docs say the base is fetched once, but there can be two fetches
load_trustedcalls_remote_workflow(..., refresh=refresh)for origin's default branch. When that workflow'srepo.basenames a different branch, it calls it again for that branch. Soready/mergecan fetch two branches, and the default branch it fetches isn't necessarily the configured base. Also,refs/remotes/origin/HEADis not refreshed, so the branch chosen as the policy source can still come from stale local state. Either reword the doc (e.g. "fetch origin's default branch and the configured base branch at startup") or note that origin/HEAD is taken from local state.