Skip to content

Commit a6985e5

Browse files
committed
fix: put gix-credentials and gix-prompt behind the 'credentials' feature toggle.
They are also available when using https transports.
1 parent 92dd181 commit a6985e5

File tree

10 files changed

+37
-21
lines changed

10 files changed

+37
-21
lines changed

gix/Cargo.toml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ default = ["max-performance-safe", "comfort", "basic", "extras"]
5151
basic = ["blob-diff", "revision"]
5252

5353
## Various additional features and capabilities that are not necessarily part of what most users would need.
54-
extras = ["worktree-stream", "worktree-archive", "revparse-regex", "mailmap", "excludes", "attributes", "worktree-mutation"]
54+
extras = ["worktree-stream", "worktree-archive", "revparse-regex", "mailmap", "excludes", "attributes", "worktree-mutation", "credentials"]
5555

5656
## Various progress-related features that improve the look of progress message units.
5757
comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human-numbers"]
@@ -61,6 +61,10 @@ comfort = ["gix-features/progress-unit-bytes", "gix-features/progress-unit-human
6161
#! A component is a distinct feature which may be comprised of one or more methods around a particular topic.
6262
#! Providers of libraries should only activate the components they need.
6363

64+
## Access to credential helpers, which provide credentials for URLs.
65+
# Note that `gix-negotiate` just piggibacks here, as 'credentials' is equivalent to 'fetch & push' right now.
66+
credentials = ["dep:gix-credentials", "dep:gix-prompt", "dep:gix-negotiate"]
67+
6468
## Various ways to alter the worktree makeup by checkout and reset.
6569
worktree-mutation = ["attributes", "dep:gix-worktree-state"]
6670

@@ -100,11 +104,11 @@ worktree-archive = ["gix-archive", "worktree-stream", "attributes"]
100104
#! Making a choice here also affects which crypto-library ends up being used.
101105

102106
## Make `gix-protocol` available along with an async client.
103-
async-network-client = ["gix-protocol/async-client", "gix-pack/streaming-input", "attributes"]
107+
async-network-client = ["gix-protocol/async-client", "gix-pack/streaming-input", "attributes", "credentials"]
104108
## Use this if your crate uses `async-std` as runtime, and enable basic runtime integration when connecting to remote servers via the `git://` protocol.
105109
async-network-client-async-std = ["async-std", "async-network-client", "gix-transport/async-std"]
106110
## Make `gix-protocol` available along with a blocking client, providing access to the `file://`, git://` and `ssh://` transports.
107-
blocking-network-client = ["gix-protocol/blocking-client", "gix-pack/streaming-input", "attributes"]
111+
blocking-network-client = ["gix-protocol/blocking-client", "gix-pack/streaming-input", "attributes", "credentials"]
108112
## Stacks with `blocking-network-client` to provide support for HTTP/S using **curl**, and implies blocking networking as a whole, making the `https://` transport avaialble.
109113
blocking-http-transport-curl = ["blocking-network-client", "gix-transport/http-client-curl"]
110114
## Stacks with `blocking-network-client` to provide support for HTTP/S using **reqwest**, and implies blocking networking as a whole, making the `https://` transport avaialble.
@@ -169,7 +173,7 @@ serde = [ "dep:serde",
169173
"gix-revision/serde",
170174
"gix-worktree?/serde",
171175
"gix-commitgraph/serde",
172-
"gix-credentials/serde"]
176+
"gix-credentials?/serde"]
173177

174178
## Re-export the progress tree root which allows to obtain progress from various functions which take `impl gix::Progress`.
175179
## Applications which want to display progress will probably need this implementation.
@@ -201,7 +205,7 @@ gix-actor = { version = "^0.25.0", path = "../gix-actor" }
201205
gix-pack = { version = "^0.41.0", path = "../gix-pack", default-features = false, features = ["object-cache-dynamic"] }
202206
gix-revision = { version = "^0.20.0", path = "../gix-revision", default-features = false }
203207
gix-revwalk = { version = "^0.6.0", path = "../gix-revwalk" }
204-
gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate" }
208+
gix-negotiate = { version = "^0.6.0", path = "../gix-negotiate", optional = true }
205209

206210
gix-path = { version = "^0.9.0", path = "../gix-path" }
207211
gix-url = { version = "^0.22.0", path = "../gix-url" }
@@ -212,8 +216,8 @@ gix-features = { version = "^0.33.0", path = "../gix-features", features = ["pro
212216
gix-trace = { version = "^0.1.3", path = "../gix-trace" }
213217

214218
gix-glob = { version = "^0.11.0", path = "../gix-glob" }
215-
gix-credentials = { version = "^0.18.0", path = "../gix-credentials" }
216-
gix-prompt = { version = "^0.6.0", path = "../gix-prompt" }
219+
gix-credentials = { version = "^0.18.0", path = "../gix-credentials", optional = true }
220+
gix-prompt = { version = "^0.6.0", path = "../gix-prompt", optional = true }
217221
gix-index = { version = "^0.23.1", path = "../gix-index" }
218222
gix-attributes = { version = "^0.17.0", path = "../gix-attributes", optional = true }
219223
gix-ignore = { version = "^0.6.0", path = "../gix-ignore", optional = true }

gix/src/config/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{bstr::BString, repository::identity, Repository};
55

66
pub(crate) mod cache;
77
mod snapshot;
8+
#[cfg(feature = "credentials")]
89
pub use snapshot::credential_helpers;
910

1011
///
@@ -461,6 +462,7 @@ pub mod transport {
461462
key: Cow<'static, BStr>,
462463
},
463464
#[error("Could not configure the credential helpers for the authenticated proxy url")]
465+
#[cfg(feature = "credentials")]
464466
ConfigureProxyAuthenticate(#[from] crate::config::snapshot::credential_helpers::Error),
465467
#[error(transparent)]
466468
InvalidSslVersion(#[from] crate::config::ssl_version::Error),

gix/src/config/snapshot/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ mod _impls;
22
mod access;
33

44
///
5+
#[cfg(feature = "credentials")]
56
pub mod credential_helpers;

gix/src/config/tree/sections/fetch.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub type NegotiationAlgorithm = keys::Any<validate::NegotiationAlgorithm>;
3737
#[cfg(feature = "attributes")]
3838
pub type RecurseSubmodules = keys::Any<validate::RecurseSubmodules>;
3939

40+
#[cfg(feature = "credentials")]
4041
mod algorithm {
4142
use std::borrow::Cow;
4243

@@ -76,15 +77,14 @@ mod algorithm {
7677
}
7778

7879
mod validate {
79-
use crate::{
80-
bstr::BStr,
81-
config::tree::{keys, Fetch},
82-
};
80+
use crate::{bstr::BStr, config::tree::keys};
8381

8482
pub struct NegotiationAlgorithm;
8583
impl keys::Validate for NegotiationAlgorithm {
84+
#[cfg_attr(not(feature = "credentials"), allow(unused_variables))]
8685
fn validate(&self, value: &BStr) -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
87-
Fetch::NEGOTIATION_ALGORITHM.try_into_negotiation_algorithm(value.into())?;
86+
#[cfg(feature = "credentials")]
87+
crate::config::tree::Fetch::NEGOTIATION_ALGORITHM.try_into_negotiation_algorithm(value.into())?;
8888
Ok(())
8989
}
9090
}
@@ -96,7 +96,7 @@ mod validate {
9696
#[cfg(feature = "attributes")]
9797
{
9898
let boolean = gix_config::Boolean::try_from(value).map(|b| b.0);
99-
Fetch::RECURSE_SUBMODULES.try_into_recurse_submodules(boolean)?;
99+
crate::config::tree::Fetch::RECURSE_SUBMODULES.try_into_recurse_submodules(boolean)?;
100100
}
101101
Ok(())
102102
}

gix/src/env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ pub mod collate {
6565
#[error(transparent)]
6666
FindExistingRemote(#[from] crate::remote::find::existing::Error),
6767
#[error(transparent)]
68+
#[cfg(feature = "credentials")]
6869
CredentialHelperConfig(#[from] crate::config::credential_helpers::Error),
6970
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]
7071
#[error(transparent)]

gix/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub use gix_actor as actor;
8080
#[cfg(feature = "attributes")]
8181
pub use gix_attributes as attrs;
8282
pub use gix_commitgraph as commitgraph;
83+
#[cfg(feature = "credentials")]
8384
pub use gix_credentials as credentials;
8485
pub use gix_date as date;
8586
pub use gix_features as features;
@@ -98,10 +99,12 @@ pub use gix_ignore as ignore;
9899
#[doc(inline)]
99100
pub use gix_index as index;
100101
pub use gix_lock as lock;
102+
#[cfg(feature = "credentials")]
101103
pub use gix_negotiate as negotiate;
102104
pub use gix_object as objs;
103105
pub use gix_object::bstr;
104106
pub use gix_odb as odb;
107+
#[cfg(feature = "credentials")]
105108
pub use gix_prompt as prompt;
106109
#[cfg(feature = "gix-protocol")]
107110
pub use gix_protocol as protocol;

gix/src/remote/fetch.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
///
22
pub mod negotiate {
3+
#[cfg(feature = "credentials")]
34
pub use gix_negotiate::Algorithm;
45

56
#[cfg(any(feature = "blocking-network-client", feature = "async-network-client"))]

gix/tests/config/tree.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,14 @@ mod ssh {
146146
}
147147

148148
mod fetch {
149-
use gix::{
150-
config::tree::{Fetch, Key},
151-
remote::fetch::negotiate::Algorithm,
152-
};
153-
154-
use crate::config::tree::bcow;
155149

156150
#[test]
151+
#[cfg(feature = "credentials")]
157152
fn algorithm() -> crate::Result {
153+
use crate::config::tree::bcow;
154+
use gix::config::tree::{Fetch, Key};
155+
use gix::remote::fetch::negotiate::Algorithm;
156+
158157
for (actual, expected) in [
159158
("noop", Algorithm::Noop),
160159
("consecutive", Algorithm::Consecutive),
@@ -181,6 +180,8 @@ mod fetch {
181180
#[cfg(feature = "attributes")]
182181
fn recurse_submodule() -> crate::Result {
183182
use gix::bstr::ByteSlice;
183+
use gix::config::tree::{Fetch, Key};
184+
184185
for (actual, expected) in [
185186
("true", gix_submodule::config::FetchRecurse::Always),
186187
("false", gix_submodule::config::FetchRecurse::Never),

gix/tests/repository/config/config_snapshot/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ use gix::config::tree::{Branch, Core, Key};
22

33
use crate::named_repo;
44

5+
#[cfg(feature = "credentials")]
6+
mod credential_helpers;
7+
58
#[test]
69
fn commit_auto_rollback() -> crate::Result {
710
let mut repo: gix::Repository = named_repo("make_basic_repo.sh")?;
@@ -127,5 +130,3 @@ fn apply_cli_overrides() -> crate::Result {
127130

128131
Ok(())
129132
}
130-
131-
mod credential_helpers;

justfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ check:
4747
if cargo tree -p gix --no-default-features -i gix-submodule 2>/dev/null; then false; else true; fi
4848
if cargo tree -p gix --no-default-features -i gix-pathspec 2>/dev/null; then false; else true; fi
4949
if cargo tree -p gix --no-default-features -i gix-filter 2>/dev/null; then false; else true; fi
50+
if cargo tree -p gix --no-default-features -i gix-credentials 2>/dev/null; then false; else true; fi
5051
cargo check --no-default-features --features lean
5152
cargo check --no-default-features --features lean-async
5253
cargo check --no-default-features --features max
@@ -124,6 +125,7 @@ check:
124125
cargo check -p gix --no-default-features --features excludes --tests
125126
cargo check -p gix --no-default-features --features attributes --tests
126127
cargo check -p gix --no-default-features --features worktree-mutation --tests
128+
cargo check -p gix --no-default-features --features credentials --tests
127129
cargo check -p gix --no-default-features
128130
cargo check -p gix-odb --features serde
129131
cargo check --no-default-features --features max-control

0 commit comments

Comments
 (0)