From f8f124943f73bacf816c6d0055f0b66659fd3906 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sat, 20 Aug 2022 19:42:35 +0800 Subject: [PATCH] basic parsing of `gix remote refs` without any implementation. (#450) 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. --- gitoxide-core/src/repository/mod.rs | 18 ++++++------------ gitoxide-core/src/repository/remote.rs | 1 + src/plumbing/main.rs | 15 +++++++++++++++ src/plumbing/options.rs | 22 ++++++++++++++++++++++ 4 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 gitoxide-core/src/repository/remote.rs diff --git a/gitoxide-core/src/repository/mod.rs b/gitoxide-core/src/repository/mod.rs index 71ce148d319..eda9d2f564c 100644 --- a/gitoxide-core/src/repository/mod.rs +++ b/gitoxide-core/src/repository/mod.rs @@ -14,18 +14,12 @@ pub fn init(directory: Option) -> Result 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, diff --git a/src/plumbing/options.rs b/src/plumbing/options.rs index c6e8d006cd4..348a7c4cfe2 100644 --- a/src/plumbing/options.rs +++ b/src/plumbing/options.rs @@ -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), @@ -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 {