Skip to content

Commit

Permalink
Merge branch 'http-config'
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Nov 17, 2022
2 parents 42356ab + b5c316e commit 665b53e
Show file tree
Hide file tree
Showing 98 changed files with 2,343 additions and 1,074 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ gitoxide-core-tools = ["gitoxide-core/organize", "gitoxide-core/estimate-hours"]
## Use blocking client networking.
gitoxide-core-blocking-client = ["gitoxide-core/blocking-client"]
## Support synchronous 'http' and 'https' transports (e.g. for clone, fetch and push) at the expense of compile times and binary size.
http-client-curl = ["git-transport-for-configuration-only/http-client-curl"]
http-client-curl = ["git-repository/blocking-http-transport"]
## Use async client networking.
gitoxide-core-async-client = ["gitoxide-core/async-client", "futures-lite"]

Expand All @@ -86,8 +86,6 @@ gitoxide-core = { version = "^0.20.0", path = "gitoxide-core" }
git-features = { version = "^0.23.1", path = "git-features" }
git-repository = { version = "^0.27.0", path = "git-repository", default-features = false }

git-transport-for-configuration-only = { package = "git-transport", optional = true, version = "^0.21.2", path = "git-transport" }

clap = { version = "3.2.5", features = ["derive", "cargo"] }
prodash = { version = "21", optional = true, default-features = false }
atty = { version = "0.2.14", optional = true, default-features = false }
Expand Down
1 change: 1 addition & 0 deletions STABILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ How do we avoid staying in the initial development phase (IDP) forever?

There is a couple of questions to ask and answer positively:

- _Is everything in it's tracking issue named "`<crate-name>` towards 1.0" resolved?_
- _Does the crate fulfill its intended purpose well enough?_
- _Do the dependent workspace crates fulfill their intended purposes well enough?_
- _Do they hide types and functionality of lower-tier workspace crates and external IDP crates?_
Expand Down
4 changes: 2 additions & 2 deletions git-config-value/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct Color {
/// suffix after fetching the value. [`integer::Suffix`] provides
/// [`bitwise_offset()`][integer::Suffix::bitwise_offset] to help with the
/// math, or [to_decimal()][Integer::to_decimal()] for obtaining a usable value in one step.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
pub struct Integer {
/// The value, without any suffix modification
pub value: i64,
Expand All @@ -34,7 +34,7 @@ pub struct Integer {
}

/// Any value that can be interpreted as a boolean.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[derive(Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug)]
#[allow(missing_docs)]
pub struct Boolean(pub bool);

Expand Down
1 change: 0 additions & 1 deletion git-glob/tests/matching/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion git-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ required-features = ["async-client"]

[dependencies]
git-features = { version = "^0.23.1", path = "../git-features", features = ["progress"] }
git-transport = { version = "^0.21.1", path = "../git-transport" }
git-transport = { version = "^0.21.2", path = "../git-transport" }
git-hash = { version = "^0.9.11", path = "../git-hash" }
git-credentials = { version = "^0.6.1", path = "../git-credentials" }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
/// The kind of command to invoke on the server side.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
pub enum Command {
/// List references.
LsRefs,
/// Fetch a pack.
Fetch,
}
//! V2 command abstraction to validate invocations and arguments, like a database of what we know about them.
use super::Command;
use std::borrow::Cow;

/// A key value pair of values known at compile time.
pub type Feature = (&'static str, Option<&'static str>);
pub type Feature = (&'static str, Option<Cow<'static, str>>);

impl Command {
/// Produce the name of the command as known by the server side.
Expand All @@ -25,7 +20,7 @@ mod with_io {
use bstr::{BString, ByteSlice};
use git_transport::client::Capabilities;

use crate::fetch::{agent, command::Feature, Command};
use crate::{command::Feature, Command};

impl Command {
/// Only V2
Expand Down Expand Up @@ -134,14 +129,13 @@ mod with_io {
feature => server_capabilities.contains(feature),
})
.map(|s| (s, None))
.chain(Some(agent()))
.collect()
}
git_transport::Protocol::V2 => {
let supported_features: Vec<_> = server_capabilities
.iter()
.find_map(|c| {
if c.name() == Command::Fetch.as_str().as_bytes().as_bstr() {
if c.name() == Command::Fetch.as_str() {
c.values().map(|v| v.map(|f| f.to_owned()).collect())
} else {
None
Expand All @@ -153,11 +147,10 @@ mod with_io {
.copied()
.filter(|feature| supported_features.iter().any(|supported| supported == feature))
.map(|s| (s, None))
.chain(Some(agent()))
.collect()
}
},
Command::LsRefs => vec![agent()],
Command::LsRefs => vec![],
}
}
/// Panics if the given arguments and features don't match what's statically known. It's considered a bug in the delegate.
Expand Down Expand Up @@ -212,3 +205,6 @@ mod with_io {
}
}
}

#[cfg(test)]
mod tests;
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ mod v1 {
const GITHUB_CAPABILITIES: &str = "multi_ack thin-pack side-band ofs-delta shallow deepen-since deepen-not deepen-relative no-progress include-tag allow-tip-sha1-in-want allow-reachable-sha1-in-want no-done symref=HEAD:refs/heads/main filter agent=git/github-gdf51a71f0236";
mod fetch {
mod default_features {
use crate::fetch::{
self,
tests::command::v1::{capabilities, GITHUB_CAPABILITIES},
Command,
};
use crate::command::tests::v1::{capabilities, GITHUB_CAPABILITIES};
use crate::Command;

#[test]
fn it_chooses_the_best_multi_ack_and_sideband() {
Expand All @@ -21,7 +18,7 @@ mod v1 {
git_transport::Protocol::V1,
&capabilities("multi_ack side-band side-band-64k multi_ack_detailed")
),
&[("side-band-64k", None), ("multi_ack_detailed", None), fetch::agent()]
&[("side-band-64k", None), ("multi_ack_detailed", None),]
);
}

Expand All @@ -42,7 +39,6 @@ mod v1 {
("allow-reachable-sha1-in-want", None),
("no-done", None),
("filter", None),
fetch::agent()
],
"we don't enforce include-tag or no-progress"
);
Expand All @@ -61,7 +57,8 @@ mod v2 {

mod fetch {
mod default_features {
use crate::fetch::{self, tests::command::v2::capabilities, Command};
use crate::command::tests::v2::capabilities;
use crate::Command;

#[test]
fn all_features() {
Expand All @@ -73,7 +70,6 @@ mod v2 {
["shallow", "filter", "ref-in-want", "sideband-all", "packfile-uris"]
.iter()
.map(|s| (*s, None))
.chain(Some(fetch::agent()))
.collect::<Vec<_>>()
)
}
Expand All @@ -82,7 +78,8 @@ mod v2 {
mod initial_arguments {
use bstr::ByteSlice;

use crate::fetch::{tests::command::v2::capabilities, Command};
use crate::command::tests::v2::capabilities;
use crate::Command;

#[test]
fn for_all_features() {
Expand All @@ -102,7 +99,8 @@ mod v2 {

mod ls_refs {
mod default_features {
use crate::fetch::{self, tests::command::v2::capabilities, Command};
use crate::command::tests::v2::capabilities;
use crate::Command;

#[test]
fn default_as_there_are_no_features() {
Expand All @@ -111,15 +109,16 @@ mod v2 {
git_transport::Protocol::V2,
&capabilities("something-else", "does not matter as there are none")
),
&[fetch::agent()]
&[]
);
}
}

mod validate {
use bstr::ByteSlice;

use crate::fetch::{tests::command::v2::capabilities, Command};
use crate::command::tests::v2::capabilities;
use crate::Command;

#[test]
fn ref_prefixes_can_always_be_used() {
Expand Down
3 changes: 2 additions & 1 deletion git-protocol/src/fetch/arguments/async_io.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use futures_lite::io::AsyncWriteExt;
use git_transport::{client, client::TransportV2Ext};

use crate::fetch::{Arguments, Command};
use crate::fetch::Arguments;
use crate::Command;

impl Arguments {
/// Send fetch arguments to the server, and indicate this is the end of negotiations only if `add_done_argument` is present.
Expand Down
7 changes: 5 additions & 2 deletions git-protocol/src/fetch/arguments/blocking_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::io::Write;

use git_transport::{client, client::TransportV2Ext};

use crate::fetch::{Arguments, Command};
use crate::fetch::Arguments;
use crate::Command;

impl Arguments {
/// Send fetch arguments to the server, and indicate this is the end of negotiations only if `add_done_argument` is present.
Expand Down Expand Up @@ -45,7 +46,9 @@ impl Arguments {
}
transport.invoke(
Command::Fetch.as_str(),
self.features.iter().filter(|(_, v)| v.is_some()).cloned(),
self.features
.iter()
.filter_map(|(k, v)| v.as_ref().map(|v| (*k, Some(v.as_ref())))),
Some(std::mem::replace(&mut self.args, retained_state).into_iter()),
)
}
Expand Down
6 changes: 3 additions & 3 deletions git-protocol/src/fetch/arguments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bstr::{BStr, BString, ByteSlice, ByteVec};
pub struct Arguments {
/// The active features/capabilities of the fetch invocation
#[cfg(any(feature = "async-client", feature = "blocking-client"))]
features: Vec<crate::fetch::command::Feature>,
features: Vec<crate::command::Feature>,

args: Vec<BString>,
haves: Vec<BString>,
Expand Down Expand Up @@ -136,8 +136,8 @@ impl Arguments {
/// Create a new instance to help setting up arguments to send to the server as part of a `fetch` operation
/// for which `features` are the available and configured features to use.
#[cfg(any(feature = "async-client", feature = "blocking-client"))]
pub fn new(version: git_transport::Protocol, features: Vec<crate::fetch::command::Feature>) -> Self {
use crate::fetch::Command;
pub fn new(version: git_transport::Protocol, features: Vec<crate::command::Feature>) -> Self {
use crate::Command;
let has = |name: &str| features.iter().any(|f| f.0 == name);
let filter = has("filter");
let shallow = has("shallow");
Expand Down
Loading

0 comments on commit 665b53e

Please sign in to comment.