History

more planning for config parser implementation

Sebastian Thiel committed 5 years ago

Commit 9676db91 parent 598622b4 files · +29 −4Browse files

Unified · Split

4 files
  1. git-config/src/file/edit.rs +1 −0
  2. git-config/src/lib.rs +7 −0
  3. git-config/src/spanned.rs +8 −4
  4. tasks.md +13 −0
git-config/src/file/edit.rs+1−0
@@ -53,6 +53,7 @@ impl<'a> Edits<'a> { · 52 unmodified lines
5353 self
5454 }
5555
56+ /// Assure new values are matching [these rules](https://github.com/git/git/blob/66e871b6647ffea61a77a0f82c7ef3415f1ee79c/Documentation/config.txt#L17:L20)
5657 pub fn to_write(&self, _out: impl io::Write) -> io::Result<()> {
5758 unimplemented!("to write")
5859 }
git-config/src/lib.rs+7−0
@@ -1,6 +1,13 @@
11 #![forbid(unsafe_code)]
22 // #![forbid(rust_2018_idioms)]
33 #![allow(dead_code)]
4+//! This crate aims to parse all `git` configuration files found in the wild and apply the same restrictions by default.
5+//! It will do so while providing helpful error messages in case of syntax errors.
6+//!
7+//! Editing is fully supported and non-destructive.
8+//!
9+//! Additionally it's a stated goal as well to apply such restrictions only when values are read and optionally allow
10+//! a less limited character set. This opens up the git configuration format to other languages than English.
411
512 use std::ops::Range;
613
git-config/src/spanned.rs+8−4
@@ -1,15 +1,19 @@
11 use crate::Span;
22
33 // we parse leading and trailing whitespace into comments, avoiding the notion of whitespace.
4−// This means we auto-trim whitespace otherwise, which I consider a feature
5−pub(crate) type Comment = Span;
4+// This means we auto-trim whitespace otherwise, which we a feature.
5+// All whitespace is automatically an empty comment.
6+#[derive(Clone, PartialOrd, PartialEq, Ord, Eq)]
7+pub(crate) struct Comment(Span);
68
79 /// A section or sub-section (in case `sub_name` is `Some()`), i.e.
810 ///
911 /// ```text
10−/// [hello]
12+/// [section]
13+///
14+/// [section.sub-section]
1115 ///
12−/// [hello.world]
16+/// [section "Sub-Section"]
1317 /// ```
1418 #[derive(Clone, PartialOrd, PartialEq, Ord, Eq)]
1519 pub(crate) struct Section {
tasks.md+13−0
@@ -8,6 +8,19 @@ · 7 unmodified lines
88 * [x] use `git-id` inside of `git-features`, remove cycle
99 * **git-config**
1010 * A complete implementation, writing a the git remote configuration is needed for finalizing the clone
11+ * **API round trip** - read - edit - write - read
12+ * [ ] parse sections (not sub-sections) and whitespace/comments
13+ * [ ] write all
14+ * [ ] Add section
15+ * [ ] write all
16+ * [ ] rename section
17+ * [ ] write all
18+ * [ ] delete section
19+ * [ ] write all
20+ * [ ] Sections lookup
21+ * [ ] case-insensitive section
22+ * [ ] case-sensitive subsection
23+ * [ ] case sensitive 'legacy section.subsection' lookup
1124 * [ ] `Config` type which integrates multiple files into one interface, much like a *multi* version of `File`
1225 * **git-ref**
1326 * [ ] create ref pointing to ID

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