Skip to content

Commit 496f942

Browse files
committed
fixup! fixup! fixup! radicle-surf: design document
1 parent 06d0c80 commit 496f942

File tree

1 file changed

+63
-60
lines changed

1 file changed

+63
-60
lines changed

radicle-surf/docs/design.md

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ of indirection defined by `Vcs` trait.
8383

8484
## Components
8585

86-
The `radicle-surf` library can split into a few main components for
86+
The `radicle-surf` library can be split into a few main components for
8787
browsing a `git` repository, each of which will be discussed in the
8888
following subsections.
8989

@@ -92,6 +92,67 @@ be the final form or signature of the functions themselves. The traits
9292
defined are recommendations, but other solutions for these
9393
representations may be discovered during implementation of this design.
9494

95+
### Revisions
96+
97+
Before describing the next components, it is important to first
98+
describe [revisions][git-revisions]. A revision in `git` is a way of
99+
specifying an `Oid`. This can be done in a multitude of ways. One can
100+
also specify a range of `Oid`s (think `git log`). The API will support
101+
taking revisions as parameters where an `Oid` is expected. It will
102+
not, however, permit ranges (at least for the time being) and so a
103+
revision will be scoped to any string that can resolve to a single
104+
`Oid`, e.g. an `Oid` string itself, a reference name, `@{date}`, etc.
105+
The aim will be to have a trait similar to:
106+
107+
108+
```rust
109+
/// `Self` is expected to be a type that can resolve to a single
110+
/// `Oid`.
111+
///
112+
/// An `Oid` is the trivial case and returns itself, and is
113+
/// infallible.
114+
///
115+
/// However, some other revisions require parsing and/or looking at the
116+
/// storage, which may result in an `Error`.
117+
pub trait FromRevision {
118+
type Error;
119+
120+
/// Resolve the revision to its `Oid`, if possible.
121+
fn peel(&self, storage: &Storage) -> Result<Oid, Self::Error>;
122+
}
123+
```
124+
125+
#### Commit-ish
126+
127+
The snapshot mentioned above is a `Commit` in `git`, where the
128+
commit points to a `Tree` object. Thus, the API should be able to take
129+
any parameter that may resolve to a `Commit`. This idea can be
130+
captured as a trait, similar to `FromRevision`, which allows something
131+
to be peeled to a `Commit`.
132+
133+
```rust
134+
/// `Self` is expected to be a type that can resolve to a single
135+
/// `Commit`.
136+
///
137+
/// A `Commit` is the trivial case and returns itself, and is
138+
/// infallible.
139+
///
140+
/// However, some other kinds of data require parsing and/or looking at the
141+
/// storage, which may result in an `Error`.
142+
///
143+
/// Common cases are:
144+
///
145+
/// * Reference that points to a commit `Oid`.
146+
/// * A `Tag` that has a `target` of `Commit`.
147+
/// * An `Oid` that is the identifier for a particular `Commit`.
148+
pub trait Commitish {
149+
type Error;
150+
151+
/// Resolve the type to its `Commit`, if possible.
152+
fn peel(&self, storage: &Storage) -> Result<Commit, Self::Error>;
153+
}
154+
```
155+
95156
### References
96157

97158
Many are familiar with `git` branches. They are the main point of
@@ -148,35 +209,6 @@ to avoid retrieving the actual object to limit the amount of data
148209
needed. The `Oid` is the minimal amount of information required to
149210
fetch the object itself.
150211

151-
### Revisions
152-
153-
Before describing the next components, it is important to first
154-
describe [revisions][git-revisions]. A revision in `git` is a way of
155-
specifying an `Oid`. This can be done in a multitude of ways. One can
156-
also specify a range of `Oid`s (think `git log`). The API will support
157-
taking revisions as parameters where an `Oid` is expected. It will
158-
not, however, permit ranges (at least for the time being) and so a
159-
revision will be scoped to any string that can resolve to a single
160-
`Oid`, e.g. an `Oid` string itself, a reference name, `@{date}`, etc.
161-
The aim will be to have a trait similar to:
162-
163-
```rust
164-
/// `Self` is expected to be a type that can resolve to a single
165-
/// `Oid`.
166-
///
167-
/// An `Oid` is the trivial case and returns itself, and is
168-
/// infallible.
169-
///
170-
/// However, some other revisions require parsing and/or looking at the
171-
/// storage, which may result in an `Error`.
172-
pub trait FromRevision {
173-
type Error;
174-
175-
/// Resolve the revision to its `Oid`, if possible.
176-
fn peel(&self, storage: &Storage) -> Result<Oid, Self::Error>;
177-
}
178-
```
179-
180212
### Objects
181213

182214
Within the `git` model, [references][#References] point to
@@ -213,36 +245,7 @@ time. Generally, this object would be a `Tree`, i.e. a directory of
213245
files. However, it may be that a particular file, i.e. `Blob`, can be
214246
viewed.
215247

216-
#### Commit-ish
217-
218-
The snapshot mentioned above is a `Commit` in `git`, where the
219-
commit points to a `Tree` object. Thus, the API should be able to take
220-
any parameter that may resolve to a `Commit`. This idea can be
221-
captured as a trait, similar to `FromRevision`, which allows something
222-
to be peeled to a `Commit`.
223-
224-
```rust
225-
/// `Self` is expected to be a type that can resolve to a single
226-
/// `Commit`.
227-
///
228-
/// A `Commit` is the trivial case and returns itself, and is
229-
/// infallible.
230-
///
231-
/// However, some other kinds of data require parsing and/or looking at the
232-
/// storage, which may result in an `Error`.
233-
///
234-
/// Common cases are:
235-
///
236-
/// * Reference that points to a commit `Oid`.
237-
/// * A `Tag` that has a `target` of `Commit`.
238-
/// * An `Oid` that is the identifier for a particular `Commit`.
239-
pub trait Commitish {
240-
type Error;
241-
242-
/// Resolve the type to its `Commit`, if possible.
243-
fn peel(&self, storage: &Storage) -> Result<Commit, Self::Error>;
244-
}
245-
```
248+
### Directories anf Files
246249

247250
This provides the building blocks for defining common cases of viewing
248251
files and directories given a `Commitish` type.

0 commit comments

Comments
 (0)