node: Add some docs

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier 2022-09-07 17:16:51 +02:00
parent 927f062dc9
commit c7f78eafb6
No known key found for this signature in database
1 changed files with 11 additions and 7 deletions

View File

@ -117,6 +117,8 @@ pub enum CheckoutError {
NotFound(Id), NotFound(Id),
} }
/// Checkout a project from storage as a working copy.
/// This effectively does a `git-clone` from storage.
pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>( pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
proj: &Id, proj: &Id,
path: P, path: P,
@ -143,17 +145,19 @@ pub fn checkout<P: AsRef<Path>, S: storage::ReadStorage>(
)?; )?;
{ {
// Setup default branch.
let remote_head_ref = format!("refs/remotes/{REMOTE_NAME}/{default_branch}"); let remote_head_ref = format!("refs/remotes/{REMOTE_NAME}/{default_branch}");
let remote_head_commit = repo.find_reference(&remote_head_ref)?.peel_to_commit()?; let remote_head_commit = repo.find_reference(&remote_head_ref)?.peel_to_commit()?;
let _ = repo.branch(default_branch, &remote_head_commit, true)?; let _ = repo.branch(default_branch, &remote_head_commit, true)?;
}
// Setup remote tracking for default branch.
git::set_upstream( git::set_upstream(
&repo, &repo,
REMOTE_NAME, REMOTE_NAME,
default_branch, default_branch,
&format!("refs/remotes/{remote_id}/heads/{default_branch}"), &format!("refs/remotes/{remote_id}/heads/{default_branch}"),
)?; )?;
}
Ok(repo) Ok(repo)
} }