Skip to content

Commit 5fca566

Browse files
author
Stephan Dilly
committed
support fetching all branches on all remotes
1 parent 4ad36bd commit 5fca566

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

asyncgit/src/fetch.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,8 @@ impl AsyncFetch {
9090
arc_progress,
9191
);
9292

93-
fetch_all(
94-
CWD,
95-
"origin",
96-
params.basic_credential.clone(),
97-
Some(progress_sender.clone()),
98-
)
99-
.expect("");
93+
fetch_all(CWD, params.basic_credential.clone())
94+
.expect("");
10095

10196
let res = fetch(
10297
CWD,

asyncgit/src/sync/remotes/mod.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,12 @@ pub(crate) fn get_default_remote_in_repo(
7676
}
7777

7878
///
79-
pub fn fetch_all(
79+
fn fetch_from_remote(
8080
repo_path: &str,
8181
remote: &str,
8282
basic_credential: Option<BasicAuthCredential>,
8383
progress_sender: Option<Sender<ProgressNotification>>,
8484
) -> Result<()> {
85-
scope_time!("fetch_all");
86-
8785
let repo = utils::repo(repo_path)?;
8886

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

100-
/// fetches from upstream/remote for `branch`
98+
/// updates/prunes all branches from all remotes
99+
pub fn fetch_all(
100+
repo_path: &str,
101+
basic_credential: Option<BasicAuthCredential>,
102+
) -> Result<()> {
103+
scope_time!("fetch_all");
104+
105+
let repo = utils::repo(repo_path)?;
106+
let remotes = repo
107+
.remotes()?
108+
.iter()
109+
.filter_map(|r| r)
110+
.map(String::from)
111+
.collect::<Vec<_>>();
112+
113+
for remote in remotes {
114+
fetch_from_remote(
115+
repo_path,
116+
&remote,
117+
basic_credential.clone(),
118+
None,
119+
)?;
120+
}
121+
122+
Ok(())
123+
}
124+
125+
/// fetches from upstream/remote for local `branch`
101126
pub(crate) fn fetch(
102127
repo_path: &str,
103128
branch: &str,

0 commit comments

Comments
 (0)