Skip to content

Commit

Permalink
a sketch of how fetching could work, but it fails with the line-reade…
Browse files Browse the repository at this point in the history
…r for some reason (#450)
  • Loading branch information
Byron committed Oct 2, 2022
1 parent 92bbe33 commit ac17e11
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions gitoxide-core/src/repository/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ pub const PROGRESS_RANGE: std::ops::RangeInclusive<u8> = 1..=2;

pub(crate) mod function {
#![allow(unused_variables, unused_mut)]

use super::Options;
use crate::OutputFormat;
use anyhow::bail;
use git_repository as git;

pub fn fetch(
Expand All @@ -29,7 +32,21 @@ pub(crate) mod function {
ref_specs,
}: Options,
) -> anyhow::Result<()> {
let _remote = crate::repository::remote::by_name_or_url(&repo, remote.as_deref())?;
todo!()
if format != OutputFormat::Human {
bail!("JSON output isn't yet supported for fetching.");
}
let mut remote = crate::repository::remote::by_name_or_url(&repo, remote.as_deref())?;
if !ref_specs.is_empty() {
remote.replace_refspecs(ref_specs.iter(), git::remote::Direction::Fetch)?;
}

let res = remote
.connect(git::remote::Direction::Fetch, progress)?
.prepare_fetch(Default::default())?
.with_dry_run(dry_run)
.receive(&git::interrupt::IS_INTERRUPTED)?;

dbg!(res);
Ok(())
}
}

0 comments on commit ac17e11

Please sign in to comment.