Skip to content

Commit b42ac1e

Browse files
Byronpascalkuthe
authored andcommitted
refactor (#26)
- typos and form - improve docs and docs consistency.
1 parent a377ca4 commit b42ac1e

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/index/diff/delegate.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ impl Delegate {
6161
if let Some(obj) = entry_data(entry_mode, id)? {
6262
for line in obj.data.lines() {
6363
let version = version_from_json_line(line, change.location)?;
64-
if version.yanked {
65-
self.changes.push(Change::AddedAndYanked(version));
64+
let change = if version.yanked {
65+
Change::AddedAndYanked(version)
6666
} else {
67-
self.changes.push(Change::Added(version));
68-
}
67+
Change::Added(version)
68+
};
69+
self.changes.push(change)
6970
}
7071
}
7172
}
@@ -86,7 +87,7 @@ impl Delegate {
8687
if let Some(diff) = change.event.diff().transpose()? {
8788
let location = change.location;
8889
for line in diff.old.data.lines() {
89-
// Safety: We transfort an &'_ [u8] to and &'static [u8] here
90+
// Safety: We transform an &'_ [u8] to and &'static [u8] here
9091
// this is safe because we always drain the hashmap at the end of the function
9192
// the reason the HashMap has a static is that we want to reuse
9293
// the allocation for modifications
@@ -127,11 +128,12 @@ impl Delegate {
127128
})
128129
}
129130
for ChecksumWithVersion(version) in self.temporary_version_map.drain() {
130-
if version.yanked {
131-
self.changes.push(Change::AddedAndYanked(version))
131+
let change = if version.yanked {
132+
Change::AddedAndYanked(version)
132133
} else {
133-
self.changes.push(Change::Added(version))
134-
}
134+
Change::Added(version)
135+
};
136+
self.changes.push(change);
135137
}
136138
}
137139
}

src/index/diff/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl Index {
173173
/// The order of the changes for each crate are **non-deterministic**.
174174
/// The order of crates is also **non-deterministic**.
175175
///
176-
/// If a specific order is required, the changes must be sorted by the calle
176+
/// If a specific order is required, the changes must be sorted by the caller.
177177
pub fn changes_between_commits(
178178
&self,
179179
from: impl Into<git::hash::ObjectId>,
@@ -256,7 +256,7 @@ impl Index {
256256
/// The order of the changes for each crate are **non-deterministic**.
257257
/// The order of crates is also **non-deterministic**.
258258
///
259-
/// If a specific order is required, the changes must be sorted by the calle
259+
/// If a specific order is required, the changes must be sorted by the caller.
260260
pub fn changes(
261261
&self,
262262
from: impl AsRef<str>,

src/types.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ pub struct Index {
2222
/// Identify a kind of change that occurred to a crate
2323
#[derive(Clone, Eq, PartialEq, Debug)]
2424
pub enum Change {
25-
/// A crate version was added
25+
/// A crate version was added.
2626
Added(CrateVersion),
2727
/// A crate version was unyanked.
2828
Unyanked(CrateVersion),
29-
/// A crate version was unyanked.
29+
/// A crate version was added in a yanked state.
30+
///
31+
/// This can happen if we don't see the commit that added them, so it appears to pop into existence yanked.
32+
/// Knowing this should help to trigger the correct action, as simply `Yanked` crates would be treated quite differently.
3033
AddedAndYanked(CrateVersion),
3134
/// A crate version was yanked.
3235
Yanked(CrateVersion),
@@ -72,10 +75,11 @@ impl Change {
7275
}
7376
}
7477

75-
/// Returns all versions affacted by this change
76-
/// The returned slice usually has length 1
77-
/// However if a crate was purged from the index by an admin,
78-
/// all versions of the pruged crate are returned
78+
/// Returns all versions affected by this change.
79+
///
80+
/// The returned slice usually has length 1.
81+
/// However, if a crate was purged from the index by an admin,
82+
/// all versions of the purged crate are returned.
7983
pub fn versions(&self) -> &[CrateVersion] {
8084
match self {
8185
Change::Added(v)

0 commit comments

Comments
 (0)