pub struct MergeBase { /* private fields */ }Expand description
The tree at the merge-base of HEAD and the pull request’s base, and the paths the working tree changes against it. The content check for a Version PR replays the version step on this tree.
Implementations§
Source§impl MergeBase
impl MergeBase
Sourcepub fn read(root: &Path, candidates: &[String]) -> Result<Option<Self>>
pub fn read(root: &Path, candidates: &[String]) -> Result<Option<Self>>
Read the merge-base tree and list each tracked path that differs from it: committed on the branch, modified, or deleted. A symlink or a submodule differs when its entry on HEAD does. Untracked files are left out.
None when there is no repository, or no origin and none of the
candidate refs, as for files_on_merge_base.
§Errors
Returns an error under the conditions of files_on_merge_base, or
when a tree, a blob, a working tree file, or git status cannot be
read.
Sourcepub fn changed(&self) -> &BTreeSet<String>
pub fn changed(&self) -> &BTreeSet<String>
Each path, relative to the working tree’s root, that differs from the merge-base. A file differs by its bytes, a symlink by its target, and a submodule by its commit.
Sourcepub fn base_bytes(&self, rel: &str) -> Result<Option<Vec<u8>>>
pub fn base_bytes(&self, rel: &str) -> Result<Option<Vec<u8>>>
A file’s bytes at the merge-base, or None when it has no file there.
§Errors
Returns an error when the blob cannot be read.
Sourcepub fn worktree_bytes(&self, rel: &str) -> Result<Option<Vec<u8>>>
pub fn worktree_bytes(&self, rel: &str) -> Result<Option<Vec<u8>>>
A file’s bytes in the working tree, or None when it is missing.
§Errors
Returns an error when the file exists but cannot be read.
Sourcepub fn write_to(&self, dir: &Path) -> Result<()>
pub fn write_to(&self, dir: &Path) -> Result<()>
Write every regular file of the merge-base tree under dir. Each file
keeps its executable bit.
The whole tree is written because the replay’s readers are not a fixed
list. cargo metadata expands member globs and needs each member’s
target files. A pin or a served file can name any path. Symlinks
are not recreated, so no write through one leaves dir.
§Errors
Returns an error when a blob cannot be read or a file cannot be written.