Skip to content

Commit f8f1249

Browse files
committed
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.
1 parent 129176f commit f8f1249

File tree

4 files changed

+44
-12
lines changed

4 files changed

+44
-12
lines changed

Diff for: gitoxide-core/src/repository/mod.rs

+6-12
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,12 @@ pub fn init(directory: Option<PathBuf>) -> Result<git::discover::repository::Pat
1414
.with_context(|| "Repository initialization failed")
1515
}
1616

17-
pub mod config;
18-
19-
pub mod tree;
20-
2117
pub mod commit;
22-
18+
pub mod config;
19+
pub mod exclude;
20+
pub mod mailmap;
21+
pub mod odb;
22+
pub mod remote;
2323
pub mod revision;
24-
24+
pub mod tree;
2525
pub mod verify;
26-
27-
pub mod odb;
28-
29-
pub mod mailmap;
30-
31-
pub mod exclude;

Diff for: gitoxide-core/src/repository/remote.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Diff for: src/plumbing/main.rs

+15
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use git_repository::bstr::io::BufReadExt;
1313
use gitoxide_core as core;
1414
use gitoxide_core::pack::verify;
1515

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

8990
match cmd {
91+
Subcommands::Remote(remote::Platform { name: _, cmd }) => match cmd {
92+
remote::Subcommands::Refs => prepare_and_run(
93+
"config-list",
94+
verbose,
95+
progress,
96+
progress_keep_open,
97+
None,
98+
move |_progress, _out, _err| {
99+
Ok(())
100+
// core::repository::remote::refs(repository(Mode::Lenient)?, name, format, out)
101+
},
102+
),
103+
}
104+
.map(|_| ()),
90105
Subcommands::Config(config::Platform { filter }) => prepare_and_run(
91106
"config-list",
92107
verbose,

Diff for: src/plumbing/options.rs

+22
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ pub enum Subcommands {
7272
/// Interact with the mailmap.
7373
#[clap(subcommand)]
7474
Mailmap(mailmap::Subcommands),
75+
/// Interact with the remote hosts.
76+
Remote(remote::Platform),
7577
/// Interact with the exclude files like .gitignore.
7678
#[clap(subcommand)]
7779
Exclude(exclude::Subcommands),
@@ -94,6 +96,26 @@ pub mod config {
9496
}
9597
}
9698

99+
pub mod remote {
100+
#[derive(Debug, clap::Parser)]
101+
pub struct Platform {
102+
/// The name of the remote to connect to.
103+
#[clap(long, short = 'n', default_value = "origin")]
104+
pub name: String,
105+
106+
/// Subcommands
107+
#[clap(subcommand)]
108+
pub cmd: Subcommands,
109+
}
110+
111+
#[derive(Debug, clap::Subcommand)]
112+
#[clap(visible_alias = "remotes")]
113+
pub enum Subcommands {
114+
/// Print all references available on the remote
115+
Refs,
116+
}
117+
}
118+
97119
pub mod mailmap {
98120
#[derive(Debug, clap::Subcommand)]
99121
pub enum Subcommands {

0 commit comments

Comments
 (0)