Skip to content

Commit

Permalink
basic parsing of gix remote refs without any implementation. (#450)
Browse files Browse the repository at this point in the history
Doing so requires some fiddling with launching async functions correctly
withing `gix`. In theory, that's already possible thanks to `pack
receive`, but let's see how well this really works.
  • Loading branch information
Byron committed Aug 20, 2022
1 parent 129176f commit f8f1249
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
18 changes: 6 additions & 12 deletions gitoxide-core/src/repository/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@ pub fn init(directory: Option<PathBuf>) -> Result<git::discover::repository::Pat
.with_context(|| "Repository initialization failed")
}

pub mod config;

pub mod tree;

pub mod commit;

pub mod config;
pub mod exclude;
pub mod mailmap;
pub mod odb;
pub mod remote;
pub mod revision;

pub mod tree;
pub mod verify;

pub mod odb;

pub mod mailmap;

pub mod exclude;
1 change: 1 addition & 0 deletions gitoxide-core/src/repository/remote.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

15 changes: 15 additions & 0 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use git_repository::bstr::io::BufReadExt;
use gitoxide_core as core;
use gitoxide_core::pack::verify;

use crate::plumbing::options::remote;
use crate::{
plumbing::options::{commit, config, exclude, free, mailmap, odb, revision, tree, Args, Subcommands},
shared::pretty::prepare_and_run,
Expand Down Expand Up @@ -87,6 +88,20 @@ pub fn main() -> Result<()> {
})?;

match cmd {
Subcommands::Remote(remote::Platform { name: _, cmd }) => match cmd {
remote::Subcommands::Refs => prepare_and_run(
"config-list",
verbose,
progress,
progress_keep_open,
None,
move |_progress, _out, _err| {
Ok(())
// core::repository::remote::refs(repository(Mode::Lenient)?, name, format, out)
},
),
}
.map(|_| ()),
Subcommands::Config(config::Platform { filter }) => prepare_and_run(
"config-list",
verbose,
Expand Down
22 changes: 22 additions & 0 deletions src/plumbing/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub enum Subcommands {
/// Interact with the mailmap.
#[clap(subcommand)]
Mailmap(mailmap::Subcommands),
/// Interact with the remote hosts.
Remote(remote::Platform),
/// Interact with the exclude files like .gitignore.
#[clap(subcommand)]
Exclude(exclude::Subcommands),
Expand All @@ -94,6 +96,26 @@ pub mod config {
}
}

pub mod remote {
#[derive(Debug, clap::Parser)]
pub struct Platform {
/// The name of the remote to connect to.
#[clap(long, short = 'n', default_value = "origin")]
pub name: String,

/// Subcommands
#[clap(subcommand)]
pub cmd: Subcommands,
}

#[derive(Debug, clap::Subcommand)]
#[clap(visible_alias = "remotes")]
pub enum Subcommands {
/// Print all references available on the remote
Refs,
}
}

pub mod mailmap {
#[derive(Debug, clap::Subcommand)]
pub enum Subcommands {
Expand Down

0 comments on commit f8f1249

Please sign in to comment.