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
53 self53 self
54 }54 }
55 55
56 /// Assure new values are matching [these rules](https://github.com/git/git/blob/66e871b6647ffea61a77a0f82c7ef3415f1ee79c/Documentation/config.txt#L17:L20)
56 pub fn to_write(&self, _out: impl io::Write) -> io::Result<()> {57 pub fn to_write(&self, _out: impl io::Write) -> io::Result<()> {
57 unimplemented!("to write")58 unimplemented!("to write")
58 }59 }
git-config/src/lib.rs+7−0
@@ -1,6 +1,13 @@
1#![forbid(unsafe_code)]1#![forbid(unsafe_code)]
2// #![forbid(rust_2018_idioms)]2// #![forbid(rust_2018_idioms)]
3#![allow(dead_code)]3#![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.
4 11
5use std::ops::Range;12use std::ops::Range;
6 13
git-config/src/spanned.rs+8−4
@@ -1,15 +1,19 @@
1use crate::Span;1use crate::Span;
2 2
3// we parse leading and trailing whitespace into comments, avoiding the notion of whitespace.3// 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 feature4// This means we auto-trim whitespace otherwise, which we a feature.
5pub(crate) type Comment = Span;5// All whitespace is automatically an empty comment.
6#[derive(Clone, PartialOrd, PartialEq, Ord, Eq)]
7pub(crate) struct Comment(Span);
6 8
7/// A section or sub-section (in case `sub_name` is `Some()`), i.e.9/// A section or sub-section (in case `sub_name` is `Some()`), i.e.
8///10///
9/// ```text11/// ```text
10/// [hello]12/// [section]
13///
14/// [section.sub-section]
11///15///
12/// [hello.world]16/// [section "Sub-Section"]
13/// ```17/// ```
14#[derive(Clone, PartialOrd, PartialEq, Ord, Eq)]18#[derive(Clone, PartialOrd, PartialEq, Ord, Eq)]
15pub(crate) struct Section {19pub(crate) struct Section {
tasks.md+13−0
@@ -8,6 +8,19 @@ · 7 unmodified lines
8 * [x] use `git-id` inside of `git-features`, remove cycle8 * [x] use `git-id` inside of `git-features`, remove cycle
9* **git-config**9* **git-config**
10 * A complete implementation, writing a the git remote configuration is needed for finalizing the clone10 * 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
11 * [ ] `Config` type which integrates multiple files into one interface, much like a *multi* version of `File`24 * [ ] `Config` type which integrates multiple files into one interface, much like a *multi* version of `File`
12* **git-ref**25* **git-ref**
13 * [ ] create ref pointing to ID26 * [ ] 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