MCPcopy Create free account
hub / github.com/Qovery/engine / checkout

Function checkout

lib-engine/src/cmd/git.rs:186–205  ·  view source on GitHub ↗
(repo: &'a Repository, commit_id: &'a str)

Source from the content-addressed store, hash-verified

184}
185
186fn checkout<'a>(repo: &'a Repository, commit_id: &'a str) -> Result<Object<'a>, Error> {
187 let obj = repo.revparse_single(commit_id).map_err(|err| {
188 let repo_url = repo
189 .find_remote("origin")
190 .map(|remote| remote.url().unwrap_or_default().to_string())
191 .unwrap_or_default();
192 let msg = format!(
193 "Unable to use git object commit ID {} on repository {}: {}",
194 &commit_id, &repo_url, &err
195 );
196 Error::from_str(&msg)
197 })?;
198
199 // Specify some options to be sure repository is in a clean state
200 let mut checkout_opts = CheckoutBuilder::new();
201 checkout_opts.force().remove_ignored(true).remove_untracked(true);
202
203 repo.reset(&obj, Hard, Some(&mut checkout_opts))?;
204 Ok(obj)
205}
206
207fn file_content_at_commit(repo: &Repository, commit_id: &str, file_path: &Path) -> Result<Vec<u8>, Error> {
208 let obj = repo.revparse_single(commit_id).map_err(|err| {

Callers 3

clone_at_tagFunction · 0.85
clone_at_commitFunction · 0.85
test_git_checkoutFunction · 0.85

Calls 1

urlMethod · 0.80

Tested by 1

test_git_checkoutFunction · 0.68