Skip to content

Commit

Permalink
support fetching all branches on all remotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Nov 22, 2021
1 parent 9b6eed0 commit 1c96ec3
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 11 deletions.
9 changes: 2 additions & 7 deletions asyncgit/src/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ impl AsyncFetch {
arc_progress,
);

fetch_all(
CWD,
"origin",
params.basic_credential.clone(),
Some(progress_sender.clone()),
)
.expect("");
fetch_all(CWD, params.basic_credential.clone())
.expect("");

let res = fetch(
CWD,
Expand Down
33 changes: 29 additions & 4 deletions asyncgit/src/sync/remotes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,12 @@ pub(crate) fn get_default_remote_in_repo(
}

///
pub fn fetch_all(
fn fetch_from_remote(
repo_path: &str,
remote: &str,
basic_credential: Option<BasicAuthCredential>,
progress_sender: Option<Sender<ProgressNotification>>,
) -> Result<()> {
scope_time!("fetch_all");

let repo = utils::repo(repo_path)?;

let mut remote = repo.find_remote(remote)?;
Expand All @@ -97,7 +95,34 @@ pub fn fetch_all(
Ok(())
}

/// fetches from upstream/remote for `branch`
/// updates/prunes all branches from all remotes
pub fn fetch_all(
repo_path: &str,
basic_credential: Option<BasicAuthCredential>,
) -> Result<()> {
scope_time!("fetch_all");

let repo = utils::repo(repo_path)?;
let remotes = repo
.remotes()?
.iter()
.filter_map(|r| r)
.map(String::from)
.collect::<Vec<_>>();

for remote in remotes {
fetch_from_remote(
repo_path,
&remote,
basic_credential.clone(),
None,
)?;
}

Ok(())
}

/// fetches from upstream/remote for local `branch`
pub(crate) fn fetch(
repo_path: &str,
branch: &str,
Expand Down

0 comments on commit 1c96ec3

Please sign in to comment.