From c7f78eafb6218dbb53e45f7cd327e0fdb42b1140 Mon Sep 17 00:00:00 2001 From: Alexis Sellier Date: Wed, 7 Sep 2022 17:16:51 +0200 Subject: [PATCH] node: Add some docs Signed-off-by: Alexis Sellier --- node/src/rad.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/node/src/rad.rs b/node/src/rad.rs index ad5013cc..5d2f4417 100644 --- a/node/src/rad.rs +++ b/node/src/rad.rs @@ -117,6 +117,8 @@ pub enum CheckoutError { NotFound(Id), } +/// Checkout a project from storage as a working copy. +/// This effectively does a `git-clone` from storage. pub fn checkout, S: storage::ReadStorage>( proj: &Id, path: P, @@ -143,17 +145,19 @@ pub fn checkout, S: storage::ReadStorage>( )?; { + // Setup 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 _ = repo.branch(default_branch, &remote_head_commit, true)?; - } - git::set_upstream( - &repo, - REMOTE_NAME, - default_branch, - &format!("refs/remotes/{remote_id}/heads/{default_branch}"), - )?; + // Setup remote tracking for default branch. + git::set_upstream( + &repo, + REMOTE_NAME, + default_branch, + &format!("refs/remotes/{remote_id}/heads/{default_branch}"), + )?; + } Ok(repo) }