Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced HTTP transport configuration #627

Merged
merged 30 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
25e795f
feat: Add `os_string_into_bstring()` as sibling of `os_str_into_bstr()`.
Byron Nov 24, 2022
0c98ec8
fix!: subsections are identified as `&BStr` in entire API.
Byron Nov 24, 2022
5fa9546
feat: comfort API like `string_by_key(key)` takes a key like `"remote…
Byron Nov 24, 2022
84d594c
feat!: more type-safety for remote names by making clear they can be …
Byron Nov 24, 2022
1c2e755
adapt to changes in `git-config`
Byron Nov 24, 2022
340dcad
Allow remote overrides for http options
Byron Nov 24, 2022
10f4f21
thanks clippy
Byron Nov 24, 2022
5c1abe7
pledge to support sparse checkouts from day one
Byron Nov 25, 2022
62cae0e
don't lock stdout/stderr as it will deadlock on dbg-printing
Byron Nov 25, 2022
4ebe2ac
doc: Actively discourage using `Boolean::try_from("")` explicitly.
Byron Nov 25, 2022
8e158c3
feat!: interpret the FollowRedirects option for the curl HTTP backend.
Byron Nov 25, 2022
b84ae6a
more faithfully parse http.followRedirect
Byron Nov 25, 2022
aeb4a1d
feat: add `--strict` option to enforce strict checking of configuration.
Byron Nov 25, 2022
872dc1a
update progress of http.proxyAuthMethod
Byron Nov 26, 2022
e4bf8f0
feat: Add the `Source::EnvOverride` to have a place for 'terminal' ov…
Byron Nov 26, 2022
5b9bffe
feat: `SectionMut::push_with_comment(key, comment)` to add a new vari…
Byron Nov 26, 2022
2b36d99
feat!: `File::new_section()` and related now returns their `id` as well.
Byron Nov 29, 2022
f16e361
feat!: remove `SnapshotMut::apply_cli_overrides()` in favor of `open:…
Byron Nov 28, 2022
0ce29a9
feat: `open::Options::modify()` as general pattern to allow builder m…
Byron Nov 28, 2022
f1a4c8b
adapt to changes in `git-repository`
Byron Nov 28, 2022
603f341
refactor
Byron Nov 28, 2022
e701e7e
feat: `client::http::Options::verbose` to see more debug output.
Byron Nov 29, 2022
5034544
feat: `client::http::Options::no_proxy` to disable a proxy for given …
Byron Nov 29, 2022
fc64693
feat: add `permissions::Environment::http_transport`.
Byron Nov 29, 2022
9441c26
apply related environment variables as config overrides
Byron Nov 26, 2022
49f39d6
change!: `open::ReplacementObjects` is removed in favor of two custom…
Byron Nov 29, 2022
a4ac9cf
change: represent `GIT_(COMMITTER|AUTHOR)_(NAME|EMAIL|DATE)` with git…
Byron Nov 29, 2022
becbd8d
feat!: represent object cache configuration like `GITOXIDE_PACK_CACHE…
Byron Nov 29, 2022
c4f68bf
adapt to changes in `git-repository`
Byron Nov 29, 2022
6b9632e
Merge branch 'main' into http-config
Byron Nov 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Project goals can change over time as we learn more, and they can be challenged.
* **be the best performing implementation**
* use Rust's type system to optimize for work not done without being hard to use
* make use of parallelism from the get go
* _sparse checkout_ support from day one
* **assure on-disk consistency**
* assure reads never interfere with concurrent writes
* assure multiple concurrent writes don't cause trouble
Expand Down
4 changes: 3 additions & 1 deletion cargo-smart-release/src/command/release/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ pub fn push_tags_and_head(
.into_remote(git::remote::Direction::Push)
.ok_or_else(|| anyhow!("Cannot push in uninitialized repo"))??
.name()
.expect("configured remotes have a name"),
.expect("configured remotes have a name")
.as_bstr()
.to_string(),
)
.arg("HEAD");
for tag_name in tag_names {
Expand Down
2 changes: 1 addition & 1 deletion cargo-smart-release/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Context {
) -> anyhow::Result<Self> {
let meta = cargo_metadata::MetadataCommand::new().exec()?;
let root = meta.workspace_root.clone();
let repo = git::discover(&root)?.apply_environment();
let repo = git::discover(&root)?;
let crates_index = crate::crates_index::Index::new_cargo_default()?;
let history = (force_history_segmentation
|| matches!(bump, BumpSpec::Auto)
Expand Down
9 changes: 9 additions & 0 deletions git-config-value/src/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ impl TryFrom<OsString> for Boolean {
}
}

/// # Warning
///
/// The direct usage of `try_from("string")` is discouraged as it will produce the wrong result for values
/// obtained from `core.bool-implicit-true`, which have no separator and are implicitly true.
/// This method chooses to work correctly for `core.bool-empty=`, which is an empty string and resolves
/// to being `false`.
///
/// Instead of this, obtain booleans with `config.boolean(…)`, which handles the case were no separator is
/// present correctly.
impl TryFrom<&BStr> for Boolean {
type Error = Error;

Expand Down
116 changes: 104 additions & 12 deletions git-config/src/file/access/comfort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,39 @@ impl<'event> File<'event> {
pub fn string(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<Cow<'_, BStr>> {
self.string_filter(section_name, subsection_name, key, &mut |_| true)
}

/// Like [`string()`][File::string()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn string_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<Cow<'_, BStr>> {
self.string_filter_by_key(key, &mut |_| true)
}

/// Like [`string()`][File::string()], but the section containing the returned value must pass `filter` as well.
pub fn string_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<Cow<'_, BStr>> {
self.raw_value_filter(section_name, subsection_name, key, filter).ok()
}

/// Like [`string_filter()`][File::string_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn string_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<Cow<'_, BStr>> {
let key = crate::parse::key(key)?;
self.raw_value_filter(key.section_name, key.subsection_name, key.value_name, filter)
.ok()
}

/// Like [`value()`][File::value()], but returning `None` if the path wasn't found.
///
/// Note that this path is not vetted and should only point to resources which can't be used
Expand All @@ -38,12 +54,17 @@ impl<'event> File<'event> {
pub fn path(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<crate::Path<'_>> {
self.path_filter(section_name, subsection_name, key, &mut |_| true)
}

/// Like [`path()`][File::path()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn path_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<crate::Path<'_>> {
self.path_filter_by_key(key, &mut |_| true)
}

/// Like [`path()`][File::path()], but the section containing the returned value must pass `filter` as well.
///
/// This should be the preferred way of accessing paths as those from untrusted
Expand All @@ -53,7 +74,7 @@ impl<'event> File<'event> {
pub fn path_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<crate::Path<'_>> {
Expand All @@ -62,21 +83,36 @@ impl<'event> File<'event> {
.map(crate::Path::from)
}

/// Like [`path_filter()`][File::path_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn path_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<crate::Path<'_>> {
let key = crate::parse::key(key)?;
self.path_filter(key.section_name, key.subsection_name, key.value_name, filter)
}

/// Like [`value()`][File::value()], but returning `None` if the boolean value wasn't found.
pub fn boolean(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<Result<bool, value::Error>> {
self.boolean_filter(section_name, subsection_name, key, &mut |_| true)
}

/// Like [`boolean()`][File::boolean()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn boolean_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<bool, value::Error>> {
self.boolean_filter_by_key(key, &mut |_| true)
}

/// Like [`boolean()`][File::boolean()], but the section containing the returned value must pass `filter` as well.
pub fn boolean_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<Result<bool, value::Error>> {
Expand All @@ -99,21 +135,36 @@ impl<'event> File<'event> {
None
}

/// Like [`boolean_filter()`][File::boolean_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn boolean_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<Result<bool, value::Error>> {
let key = crate::parse::key(key)?;
self.boolean_filter(key.section_name, key.subsection_name, key.value_name, filter)
}

/// Like [`value()`][File::value()], but returning an `Option` if the integer wasn't found.
pub fn integer(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<Result<i64, value::Error>> {
self.integer_filter(section_name, subsection_name, key, &mut |_| true)
}

/// Like [`integer()`][File::integer()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn integer_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<i64, value::Error>> {
self.integer_filter_by_key(key, &mut |_| true)
}

/// Like [`integer()`][File::integer()], but the section containing the returned value must pass `filter` as well.
pub fn integer_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<Result<i64, value::Error>> {
Expand All @@ -124,44 +175,75 @@ impl<'event> File<'event> {
}))
}

/// Like [`integer_filter()`][File::integer_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn integer_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<Result<i64, value::Error>> {
let key = crate::parse::key(key)?;
self.integer_filter(key.section_name, key.subsection_name, key.value_name, filter)
}

/// Similar to [`values(…)`][File::values()] but returning strings if at least one of them was found.
pub fn strings(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<Vec<Cow<'_, BStr>>> {
self.raw_values(section_name, subsection_name, key).ok()
}

/// Like [`strings()`][File::strings()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn strings_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<Vec<Cow<'_, BStr>>> {
let key = crate::parse::key(key)?;
self.strings(key.section_name, key.subsection_name, key.value_name)
}

/// Similar to [`strings(…)`][File::strings()], but all values are in sections that passed `filter`.
pub fn strings_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<Vec<Cow<'_, BStr>>> {
self.raw_values_filter(section_name, subsection_name, key, filter).ok()
}

/// Like [`strings_filter()`][File::strings_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn strings_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<Vec<Cow<'_, BStr>>> {
let key = crate::parse::key(key)?;
self.strings_filter(key.section_name, key.subsection_name, key.value_name, filter)
}

/// Similar to [`values(…)`][File::values()] but returning integers if at least one of them was found
/// and if none of them overflows.
pub fn integers(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
) -> Option<Result<Vec<i64>, value::Error>> {
self.integers_filter(section_name, subsection_name, key, &mut |_| true)
}

/// Like [`integers()`][File::integers()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn integers_by_key<'a>(&self, key: impl Into<&'a BStr>) -> Option<Result<Vec<i64>, value::Error>> {
self.integers_filter_by_key(key, &mut |_| true)
}

/// Similar to [`integers(…)`][File::integers()] but all integers are in sections that passed `filter`
/// and that are not overflowing.
pub fn integers_filter(
&self,
section_name: impl AsRef<str>,
subsection_name: Option<&str>,
subsection_name: Option<&BStr>,
key: impl AsRef<str>,
filter: &mut MetadataFilter,
) -> Option<Result<Vec<i64>, value::Error>> {
Expand All @@ -179,4 +261,14 @@ impl<'event> File<'event> {
.collect()
})
}

/// Like [`integers_filter()`][File::integers_filter()], but suitable for statically known `key`s like `remote.origin.url`.
pub fn integers_filter_by_key<'a>(
&self,
key: impl Into<&'a BStr>,
filter: &mut MetadataFilter,
) -> Option<Result<Vec<i64>, value::Error>> {
let key = crate::parse::key(key)?;
self.integers_filter(key.section_name, key.subsection_name, key.value_name, filter)
}
}
Loading