Skip to content

Commit 78e48f2

Browse files
committed
adapt to changes in gix-config
1 parent 0ec2389 commit 78e48f2

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

gitoxide-core/src/repository/config.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use anyhow::{bail, Result};
2-
use gix::{bstr::BString, config::Key};
2+
use gix::{bstr::BString, config::AsKey};
33

44
use crate::OutputFormat;
55

@@ -57,12 +57,12 @@ struct Filter {
5757

5858
impl Filter {
5959
fn new(input: BString) -> Self {
60-
match ((&input).section_name(), (&input).subsection_name()) {
61-
(section, subsection) if !section.is_empty() => Filter {
62-
name: section.into(),
63-
subsection: subsection.map(ToOwned::to_owned),
60+
match input.try_as_key() {
61+
Some(key) => Filter {
62+
name: key.section_name.into(),
63+
subsection: key.subsection_name.map(ToOwned::to_owned),
6464
},
65-
_ => Filter {
65+
None => Filter {
6666
name: input.to_string(),
6767
subsection: None,
6868
},

gix-submodule/src/access.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ impl File {
119119
pub fn path(&self, name: &BStr) -> Result<Cow<'_, BStr>, config::path::Error> {
120120
let path_bstr =
121121
self.config
122-
.string(&format!("submodule.{name}.path"))
122+
.string(format!("submodule.{name}.path"))
123123
.ok_or_else(|| config::path::Error::Missing {
124124
submodule: name.to_owned(),
125125
})?;
@@ -148,7 +148,7 @@ impl File {
148148
pub fn url(&self, name: &BStr) -> Result<gix_url::Url, config::url::Error> {
149149
let url = self
150150
.config
151-
.string(&format!("submodule.{name}.url"))
151+
.string(format!("submodule.{name}.url"))
152152
.ok_or_else(|| config::url::Error::Missing {
153153
submodule: name.to_owned(),
154154
})?;
@@ -166,7 +166,7 @@ impl File {
166166

167167
/// Retrieve the `update` field of the submodule named `name`, if present.
168168
pub fn update(&self, name: &BStr) -> Result<Option<Update>, config::update::Error> {
169-
let value: Update = match self.config.string(&format!("submodule.{name}.update")) {
169+
let value: Update = match self.config.string(format!("submodule.{name}.update")) {
170170
Some(v) => v.as_ref().try_into().map_err(|()| config::update::Error::Invalid {
171171
submodule: name.to_owned(),
172172
actual: v.into_owned(),
@@ -196,7 +196,7 @@ impl File {
196196
///
197197
/// Note that `Default` is implemented for [`Branch`].
198198
pub fn branch(&self, name: &BStr) -> Result<Option<Branch>, config::branch::Error> {
199-
let branch = match self.config.string(&format!("submodule.{name}.branch")) {
199+
let branch = match self.config.string(format!("submodule.{name}.branch")) {
200200
Some(v) => v,
201201
None => return Ok(None),
202202
};
@@ -215,7 +215,7 @@ impl File {
215215
/// Note that if it's unset, it should be retrieved from `fetch.recurseSubmodules` in the configuration.
216216
pub fn fetch_recurse(&self, name: &BStr) -> Result<Option<FetchRecurse>, config::Error> {
217217
self.config
218-
.boolean(&format!("submodule.{name}.fetchRecurseSubmodules"))
218+
.boolean(format!("submodule.{name}.fetchRecurseSubmodules"))
219219
.map(FetchRecurse::new)
220220
.transpose()
221221
.map_err(|value| config::Error {
@@ -228,7 +228,7 @@ impl File {
228228
/// Retrieve the `ignore` field of the submodule named `name`, or `None` if unset.
229229
pub fn ignore(&self, name: &BStr) -> Result<Option<Ignore>, config::Error> {
230230
self.config
231-
.string(&format!("submodule.{name}.ignore"))
231+
.string(format!("submodule.{name}.ignore"))
232232
.map(|value| {
233233
Ignore::try_from(value.as_ref()).map_err(|()| config::Error {
234234
field: "ignore",
@@ -243,6 +243,6 @@ impl File {
243243
///
244244
/// If `true`, the submodule will be checked out with `depth = 1`. If unset, `false` is assumed.
245245
pub fn shallow(&self, name: &BStr) -> Result<Option<bool>, gix_config::value::Error> {
246-
self.config.boolean(&format!("submodule.{name}.shallow")).transpose()
246+
self.config.boolean(format!("submodule.{name}.shallow")).transpose()
247247
}
248248
}

gix-submodule/src/is_active_platform.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl IsActivePlatform {
3434
&mut gix_pathspec::attributes::search::Outcome,
3535
) -> bool,
3636
) -> Result<bool, gix_config::value::Error> {
37-
if let Some(val) = config.boolean(&format!("submodule.{name}.active")).transpose()? {
37+
if let Some(val) = config.boolean(format!("submodule.{name}.active")).transpose()? {
3838
return Ok(val);
3939
};
4040
if let Some(val) = self.search.as_mut().map(|search| {
@@ -44,6 +44,6 @@ impl IsActivePlatform {
4444
}) {
4545
return Ok(val);
4646
}
47-
Ok(config.string(&format!("submodule.{name}.url")).is_some())
47+
Ok(config.string(format!("submodule.{name}.url")).is_some())
4848
}
4949
}

0 commit comments

Comments
 (0)