Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the shallow clone behavior of the git walkers #4

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions modules/importer/src/runner/common/walker/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ impl<H> GitWalker<H, (), ()>
where
H: Handler,
{
/// Create a new GitWalker for a given repo and handler. By
/// default, a "shallow clone" (depth=1) of the repo will be
/// walked.
pub fn new(source: impl Into<String>, handler: H) -> Self {
Self {
source: source.into(),
Expand All @@ -84,7 +87,7 @@ where
working_dir: (),
handler,
progress: (),
depth: 0,
depth: 1, // shallow clone, by default
}
}
}
Expand Down Expand Up @@ -195,7 +198,10 @@ where
builder.branch(branch);
}

let fo = self.create_fetch_options();
let mut fo = Self::create_fetch_options();
if self.continuation.0.is_none() {
fo.depth(self.depth);
}
builder.fetch_options(fo).clone(&self.source, path)
});

Expand All @@ -209,7 +215,7 @@ where
log::info!("Fetching updates");
let mut remote = repo.find_remote("origin")?;

let mut fo = self.create_fetch_options();
let mut fo = Self::create_fetch_options();
remote.fetch(&[] as &[&str], Some(&mut fo), None)?;
remote.disconnect()?;

Expand Down Expand Up @@ -317,7 +323,7 @@ where
Ok(Continuation(Some(commit.to_string())))
}

fn create_fetch_options<'cb>(&self) -> FetchOptions<'cb> {
fn create_fetch_options<'cb>() -> FetchOptions<'cb> {
let mut cb = RemoteCallbacks::new();
cb.transfer_progress(|progress| {
let received = progress.received_objects();
Expand Down Expand Up @@ -352,7 +358,7 @@ where

let mut fo = FetchOptions::new();
fo.remote_callbacks(cb);
fo.depth(self.depth);
fo.depth(i32::MAX);
fo
}

Expand Down