Rename `patch::State::Proposed to `patch::State::Open`

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez 2023-03-30 10:43:35 +02:00 committed by Alexis Sellier
parent 8907ddb8a5
commit 91efbd9630
No known key found for this signature in database
3 changed files with 22 additions and 21 deletions

View File

@ -98,7 +98,7 @@ mod routes {
"delegates": ["did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"],
"head": HEAD,
"patches": {
"proposed": 1,
"open": 1,
"draft": 0,
"archived": 0,
},

View File

@ -748,7 +748,7 @@ mod routes {
"delegates": [DID],
"head": HEAD,
"patches": {
"proposed": 1,
"open": 1,
"draft": 0,
"archived": 0,
},
@ -778,7 +778,7 @@ mod routes {
"delegates": [DID],
"head": HEAD,
"patches": {
"proposed": 1,
"open": 1,
"draft": 0,
"archived": 0,
},
@ -1693,7 +1693,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -1732,7 +1732,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -1810,7 +1810,7 @@ mod routes {
},
"title": "Update README",
"description": "Do some changes to README",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -1870,7 +1870,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [
"bug",
@ -1933,7 +1933,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -2006,7 +2006,7 @@ mod routes {
},
"title": "This is a updated title",
"description": "Let's write some description",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -2088,7 +2088,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -2184,7 +2184,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [
@ -2267,7 +2267,7 @@ mod routes {
},
"title": "A new `hello world`",
"description": "change `hello world` in README to something else",
"state": { "status": "proposed" },
"state": { "status": "open" },
"target": "delegates",
"tags": [],
"revisions": [

View File

@ -237,8 +237,8 @@ impl Patch {
self.revisions().next_back()
}
pub fn is_proposed(&self) -> bool {
matches!(self.state.get().get(), State::Proposed)
pub fn is_open(&self) -> bool {
matches!(self.state.get().get(), State::Open)
}
pub fn is_archived(&self) -> bool {
@ -429,11 +429,12 @@ impl Revision {
}
}
/// Patch state.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", tag = "status")]
pub enum State {
#[default]
Proposed,
Open,
Draft,
Archived,
}
@ -441,9 +442,9 @@ pub enum State {
impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Proposed => write!(f, "open"),
Self::Draft => write!(f, "draft"),
Self::Archived => write!(f, "archived"),
Self::Draft => write!(f, "draft"),
Self::Open => write!(f, "open"),
}
}
}
@ -878,7 +879,7 @@ impl<'a, 'g> Deref for PatchMut<'a, 'g> {
#[derive(Default, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PatchCounts {
pub proposed: usize,
pub open: usize,
pub draft: usize,
pub archived: usize,
}
@ -936,7 +937,7 @@ impl<'a> Patches<'a> {
.fold(PatchCounts::default(), |mut state, (_, p, _)| {
match p.state() {
State::Draft => state.draft += 1,
State::Proposed => state.proposed += 1,
State::Open => state.open += 1,
State::Archived => state.archived += 1,
}
state
@ -974,7 +975,7 @@ impl<'a> Patches<'a> {
Ok(all
.into_iter()
.filter_map(|result| result.ok())
.filter(|(_, p, _)| p.is_proposed()))
.filter(|(_, p, _)| p.is_open()))
}
/// Get patches proposed by the given key.
@ -1193,7 +1194,7 @@ mod test {
assert_eq!(patch.title(), "My first patch");
assert_eq!(patch.description(), "Blah blah blah.");
assert_eq!(patch.author().id(), &author);
assert_eq!(patch.state(), State::Proposed);
assert_eq!(patch.state(), State::Open);
assert_eq!(patch.target(), target);
assert_eq!(patch.version(), 0);