git: Pick which remote to fetch (#26897)

I don't want to fetch `--all` branch, we should can picker which remote
to fetch.

Release Notes:

- Added the `git::FetchFrom` action to fetch from a single remote.

---------

Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
CharlesChen0823 2025-06-06 23:28:07 +08:00 committed by GitHub
parent a40ee74a1f
commit edd40566b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 155 additions and 42 deletions

View file

@ -6,7 +6,7 @@ use util::ResultExt as _;
#[derive(Clone)]
pub enum RemoteAction {
Fetch,
Fetch(Option<Remote>),
Pull(Remote),
Push(SharedString, Remote),
}
@ -14,7 +14,7 @@ pub enum RemoteAction {
impl RemoteAction {
pub fn name(&self) -> &'static str {
match self {
RemoteAction::Fetch => "fetch",
RemoteAction::Fetch(_) => "fetch",
RemoteAction::Pull(_) => "pull",
RemoteAction::Push(_, _) => "push",
}
@ -34,15 +34,19 @@ pub struct SuccessMessage {
pub fn format_output(action: &RemoteAction, output: RemoteCommandOutput) -> SuccessMessage {
match action {
RemoteAction::Fetch => {
RemoteAction::Fetch(remote) => {
if output.stderr.is_empty() {
SuccessMessage {
message: "Already up to date".into(),
style: SuccessStyle::Toast,
}
} else {
let message = match remote {
Some(remote) => format!("Synchronized with {}", remote.name),
None => "Synchronized with remotes".into(),
};
SuccessMessage {
message: "Synchronized with remotes".into(),
message,
style: SuccessStyle::ToastWithLog { output },
}
}