History

frame for simplified config access via Repository (#298)

Sebastian Thiel committed 4 years ago

Commit eba2b9a1 parent 76201865 files · +25 −2Browse files

Unified · Split

5 files
  1. git-repository/src/id.rs +1 −1
  2. git-repository/src/lib.rs +12 −0
  3. git-repository/src/open.rs +1 −1
  4. git-repository/src/repository/config.rs +9 −0
  5. git-repository/src/repository/mod.rs +2 −0
git-repository/src/id.rs+1−1
@@ -47,7 +47,7 @@ mod prefix { · 46 unmodified lines
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+12−0
@@ -228,6 +228,18 @@ pub fn open(directory: impl Into<std::path::PathBuf>) -> Result<crate::Repositor · 227 unmodified lines
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+1−1
@@ -31,7 +31,7 @@ impl Options { · 30 unmodified lines
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)]
git-repository/src/repository/config.rs+9−0
@@ -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+2−0
@@ -82,6 +82,8 @@ mod trait_impls; · 81 unmodified lines
8282
8383 mod cache;
8484
85+mod config;
86+
8587 mod reference;
8688
8789 mod object;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t