Push the current branch to the remote. Delegates the network operation to the `git` CLI so authentication behaves exactly like a plain `git push`: OpenSSH client config (`Host`/`IdentityFile`/`IdentitiesOnly`), ssh-agents, askpass prompts, and HTTPS credential helpers all work as the user expects. Do not "simplify" this back to libgit2's transport: its credential callback can only consult the ss
(
&self,
repo: &Repository,
repo_root: &std::path::Path,
git_repo: &GitRepository,
override_branch: Option<&str>,
publication: &super::shadow::VerifiedP
| 735 | /// the new remote tip is verified after the push and recorded back into |
| 736 | /// the mapping, so the next push is leased against it. |
| 737 | fn push_to_remote( |
| 738 | &self, |
| 739 | repo: &Repository, |
| 740 | repo_root: &std::path::Path, |
| 741 | git_repo: &GitRepository, |
| 742 | override_branch: Option<&str>, |
| 743 | publication: &super::shadow::VerifiedPublication, |
| 744 | common: &atomic_repository::RepositoryCommonLockGuard, |
| 745 | ) -> CliResult<()> { |
| 746 | let head = git_repo.head().map_err(|e| CliError::GitError { |
| 747 | message: format!("Failed to get HEAD: {}", e), |
| 748 | })?; |
| 749 | let current = head.shorthand().unwrap_or("HEAD"); |
| 750 | let target = override_branch.unwrap_or(current); |
| 751 | let destination = format!("refs/heads/{}", target); |
| 752 | if !super::is_publishable_git_ref(destination.as_bytes()) { |
| 753 | return Err(CliError::GitError { |
| 754 | message: format!("refusing to publish local recovery ref '{destination}'"), |
| 755 | }); |
| 756 | } |
| 757 | // CB-10B review R3: push the PINNED verified commit, never the |
| 758 | // mutable HEAD — the refspec names the exact commit the publication |
| 759 | // snapshot verified, so a branch that moves after verification |
| 760 | // cannot change what is pushed. |
| 761 | let verified_head = publication.git_head.ok_or_else(|| CliError::GitError { |
| 762 | message: "the verified publication carries no Git commit to push".to_string(), |
| 763 | })?; |
| 764 | let refspec = format!("{}:{destination}", verified_head); |
| 765 | |
| 766 | let workdir = git_repo.workdir().ok_or_else(|| CliError::GitError { |
| 767 | message: "Git repository has no working directory (bare repository?)".to_string(), |
| 768 | })?; |
| 769 | |
| 770 | // Re-observe immediately before handing the ref effect to `git push`. |
| 771 | publication.reobserve_for_git_push(repo, repo_root, git_repo)?; |
| 772 | |
| 773 | // CB-10B remote lease (RFC §8.5). Every mapped view push runs under |
| 774 | // an expected-old lease: the mapping's last_observed_remote pins the |
| 775 | // expected remote tip, an unobserved remote is observed explicitly |
| 776 | // first, and the verified new tip is recorded back for the next |
| 777 | // push. The working copy comes from the publication boundary. |
| 778 | let current_view = publication.view().to_string(); |
| 779 | let working_copy = repo |
| 780 | .require_working_copy_id() |
| 781 | .map_err(CliError::Repository)?; |
| 782 | let mapping = match repo |
| 783 | .get_ref_mapping(¤t_view) |
| 784 | .map_err(CliError::Repository)? |
| 785 | { |
| 786 | Some(mapping) => Some(mapping), |
| 787 | None => { |
| 788 | // First push for this view: create the baseline mapping so |
| 789 | // the remote observation below has a durable row to advance. |
| 790 | super::ref_mapping::ensure_baseline_mapping( |
| 791 | repo, |
| 792 | working_copy, |
| 793 | git_repo, |
| 794 | ¤t_view, |
no test coverage detected