(
&mut self,
git_repo: &GitRepository,
commit_oid: git2::Oid,
)
| 101 | } |
| 102 | |
| 103 | pub(crate) fn bind_committed_head( |
| 104 | &mut self, |
| 105 | git_repo: &GitRepository, |
| 106 | commit_oid: git2::Oid, |
| 107 | ) -> CliResult<()> { |
| 108 | let commit = git_repo.find_commit(commit_oid).map_err(|error| { |
| 109 | git_error(format!( |
| 110 | "cannot bind published Git commit {commit_oid}: {error}" |
| 111 | )) |
| 112 | })?; |
| 113 | if commit.tree_id() != self.git_tree_oid()? { |
| 114 | return Err(git_error( |
| 115 | "refusing to bind a Git commit whose tree differs from the verified project tree", |
| 116 | )); |
| 117 | } |
| 118 | let observed = git_repo |
| 119 | .head() |
| 120 | .ok() |
| 121 | .and_then(|head| head.target()) |
| 122 | .ok_or_else(|| { |
| 123 | git_error("cannot bind publication to an unborn or symbolic-only HEAD") |
| 124 | })?; |
| 125 | if observed != commit_oid { |
| 126 | return Err(git_error(format!( |
| 127 | "Git HEAD changed while binding publication: expected {commit_oid}, found {observed}" |
| 128 | ))); |
| 129 | } |
| 130 | self.git_head = Some(commit_oid); |
| 131 | Ok(()) |
| 132 | } |
| 133 | |
| 134 | pub(crate) fn reobserve_before_commit( |
| 135 | &self, |
no test coverage detected