Skip to content

Commit 056b09b

Browse files
committed
frame for simplified config access via Repository (#298)
1 parent 5849d5b commit 056b09b

File tree

5 files changed

+25
-2
lines changed

5 files changed

+25
-2
lines changed

git-repository/src/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod prefix {
4747
#[error(transparent)]
4848
FindExisting(#[from] crate::object::find::existing::OdbError),
4949
#[error(transparent)]
50-
Config(#[from] git_config::parser::ParserOrIoError<'static>),
50+
Config(#[from] crate::config::open::Error),
5151
#[error(transparent)]
5252
Prefix(#[from] git_hash::prefix::Error),
5353
}

git-repository/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ pub fn open(directory: impl Into<std::path::PathBuf>) -> Result<crate::Repositor
228228
///
229229
pub mod open;
230230

231+
///
232+
mod config {
233+
///
234+
pub mod open {
235+
pub type Error = git_config::parser::ParserOrIoError<'static>;
236+
}
237+
///
238+
pub mod query {
239+
pub type Error = git_config::file::GitConfigError<'static>;
240+
}
241+
}
242+
231243
///
232244
pub mod init {
233245
use std::{convert::TryInto, path::Path};

git-repository/src/open.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl Options {
3131
#[allow(missing_docs)]
3232
pub enum Error {
3333
#[error(transparent)]
34-
Config(#[from] git_config::parser::ParserOrIoError<'static>),
34+
Config(#[from] crate::config::open::Error),
3535
#[error(transparent)]
3636
NotARepository(#[from] crate::path::is::Error),
3737
#[error(transparent)]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use crate::config;
2+
3+
/// Provide simplified access to git configuration values
4+
impl crate::Repository {
5+
/// Return the integer value at `key` (like `core.abbrev`) or use the given `default` value if it isn't present.
6+
pub fn config_int(_key: &str, _default: i64) -> Result<i64, config::query::Error> {
7+
todo!()
8+
}
9+
}

git-repository/src/repository/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ mod trait_impls;
8282

8383
mod cache;
8484

85+
mod config;
86+
8587
mod reference;
8688

8789
mod object;

0 commit comments

Comments
 (0)