Rename `patch::State::Proposed to `patch::State::Open`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
8907ddb8a5
commit
91efbd9630
|
|
@ -98,7 +98,7 @@ mod routes {
|
||||||
"delegates": ["did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"],
|
"delegates": ["did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"],
|
||||||
"head": HEAD,
|
"head": HEAD,
|
||||||
"patches": {
|
"patches": {
|
||||||
"proposed": 1,
|
"open": 1,
|
||||||
"draft": 0,
|
"draft": 0,
|
||||||
"archived": 0,
|
"archived": 0,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -748,7 +748,7 @@ mod routes {
|
||||||
"delegates": [DID],
|
"delegates": [DID],
|
||||||
"head": HEAD,
|
"head": HEAD,
|
||||||
"patches": {
|
"patches": {
|
||||||
"proposed": 1,
|
"open": 1,
|
||||||
"draft": 0,
|
"draft": 0,
|
||||||
"archived": 0,
|
"archived": 0,
|
||||||
},
|
},
|
||||||
|
|
@ -778,7 +778,7 @@ mod routes {
|
||||||
"delegates": [DID],
|
"delegates": [DID],
|
||||||
"head": HEAD,
|
"head": HEAD,
|
||||||
"patches": {
|
"patches": {
|
||||||
"proposed": 1,
|
"open": 1,
|
||||||
"draft": 0,
|
"draft": 0,
|
||||||
"archived": 0,
|
"archived": 0,
|
||||||
},
|
},
|
||||||
|
|
@ -1693,7 +1693,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -1732,7 +1732,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -1810,7 +1810,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "Update README",
|
"title": "Update README",
|
||||||
"description": "Do some changes to README",
|
"description": "Do some changes to README",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -1870,7 +1870,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [
|
"tags": [
|
||||||
"bug",
|
"bug",
|
||||||
|
|
@ -1933,7 +1933,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -2006,7 +2006,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "This is a updated title",
|
"title": "This is a updated title",
|
||||||
"description": "Let's write some description",
|
"description": "Let's write some description",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -2088,7 +2088,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -2184,7 +2184,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
@ -2267,7 +2267,7 @@ mod routes {
|
||||||
},
|
},
|
||||||
"title": "A new `hello world`",
|
"title": "A new `hello world`",
|
||||||
"description": "change `hello world` in README to something else",
|
"description": "change `hello world` in README to something else",
|
||||||
"state": { "status": "proposed" },
|
"state": { "status": "open" },
|
||||||
"target": "delegates",
|
"target": "delegates",
|
||||||
"tags": [],
|
"tags": [],
|
||||||
"revisions": [
|
"revisions": [
|
||||||
|
|
|
||||||
|
|
@ -237,8 +237,8 @@ impl Patch {
|
||||||
self.revisions().next_back()
|
self.revisions().next_back()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_proposed(&self) -> bool {
|
pub fn is_open(&self) -> bool {
|
||||||
matches!(self.state.get().get(), State::Proposed)
|
matches!(self.state.get().get(), State::Open)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_archived(&self) -> bool {
|
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)]
|
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase", tag = "status")]
|
#[serde(rename_all = "camelCase", tag = "status")]
|
||||||
pub enum State {
|
pub enum State {
|
||||||
#[default]
|
#[default]
|
||||||
Proposed,
|
Open,
|
||||||
Draft,
|
Draft,
|
||||||
Archived,
|
Archived,
|
||||||
}
|
}
|
||||||
|
|
@ -441,9 +442,9 @@ pub enum State {
|
||||||
impl fmt::Display for State {
|
impl fmt::Display for State {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Self::Proposed => write!(f, "open"),
|
|
||||||
Self::Draft => write!(f, "draft"),
|
|
||||||
Self::Archived => write!(f, "archived"),
|
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)]
|
#[derive(Default, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct PatchCounts {
|
pub struct PatchCounts {
|
||||||
pub proposed: usize,
|
pub open: usize,
|
||||||
pub draft: usize,
|
pub draft: usize,
|
||||||
pub archived: usize,
|
pub archived: usize,
|
||||||
}
|
}
|
||||||
|
|
@ -936,7 +937,7 @@ impl<'a> Patches<'a> {
|
||||||
.fold(PatchCounts::default(), |mut state, (_, p, _)| {
|
.fold(PatchCounts::default(), |mut state, (_, p, _)| {
|
||||||
match p.state() {
|
match p.state() {
|
||||||
State::Draft => state.draft += 1,
|
State::Draft => state.draft += 1,
|
||||||
State::Proposed => state.proposed += 1,
|
State::Open => state.open += 1,
|
||||||
State::Archived => state.archived += 1,
|
State::Archived => state.archived += 1,
|
||||||
}
|
}
|
||||||
state
|
state
|
||||||
|
|
@ -974,7 +975,7 @@ impl<'a> Patches<'a> {
|
||||||
Ok(all
|
Ok(all
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|result| result.ok())
|
.filter_map(|result| result.ok())
|
||||||
.filter(|(_, p, _)| p.is_proposed()))
|
.filter(|(_, p, _)| p.is_open()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get patches proposed by the given key.
|
/// Get patches proposed by the given key.
|
||||||
|
|
@ -1193,7 +1194,7 @@ mod test {
|
||||||
assert_eq!(patch.title(), "My first patch");
|
assert_eq!(patch.title(), "My first patch");
|
||||||
assert_eq!(patch.description(), "Blah blah blah.");
|
assert_eq!(patch.description(), "Blah blah blah.");
|
||||||
assert_eq!(patch.author().id(), &author);
|
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.target(), target);
|
||||||
assert_eq!(patch.version(), 0);
|
assert_eq!(patch.version(), 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue