httpd: Add more revision properties to patch
For display purposes in the web client, we add with this commit the some needed properties to the revisions in the patch endpoint. Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
parent
b6c1560a0a
commit
73221e43d7
|
|
@ -115,6 +115,10 @@ pub(crate) fn patch(id: PatchId, patch: Patch) -> Value {
|
||||||
json!({
|
json!({
|
||||||
"id": id,
|
"id": id,
|
||||||
"description": rev.description(),
|
"description": rev.description(),
|
||||||
|
"base": rev.base,
|
||||||
|
"oid": rev.oid,
|
||||||
|
"merges": rev.merges().collect::<Vec<_>>(),
|
||||||
|
"discussions": rev.discussion.comments().collect::<Comments>(),
|
||||||
"timestamp": rev.timestamp,
|
"timestamp": rev.timestamp,
|
||||||
"reviews": rev.reviews().collect::<Vec<_>>(),
|
"reviews": rev.reviews().collect::<Vec<_>>(),
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1335,6 +1335,10 @@ mod routes {
|
||||||
{
|
{
|
||||||
"id": PATCH_ID,
|
"id": PATCH_ID,
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"base": HEAD_1,
|
||||||
|
"oid": HEAD,
|
||||||
|
"merges": [],
|
||||||
|
"discussions": [],
|
||||||
"timestamp": 1671125284,
|
"timestamp": 1671125284,
|
||||||
"reviews": [],
|
"reviews": [],
|
||||||
}
|
}
|
||||||
|
|
@ -1363,6 +1367,10 @@ mod routes {
|
||||||
{
|
{
|
||||||
"id": PATCH_ID,
|
"id": PATCH_ID,
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"base": HEAD_1,
|
||||||
|
"oid": HEAD,
|
||||||
|
"merges": [],
|
||||||
|
"discussions": [],
|
||||||
"timestamp": 1671125284,
|
"timestamp": 1671125284,
|
||||||
"reviews": [],
|
"reviews": [],
|
||||||
}
|
}
|
||||||
|
|
@ -1374,7 +1382,7 @@ mod routes {
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_projects_create_patches() {
|
async fn test_projects_create_patches() {
|
||||||
const CREATED_PATCH_ID: &str = "54505091ff3561466cfbe83e7e23c21cb1bb8a17";
|
const CREATED_PATCH_ID: &str = "9170195973fb145b327b1f5cd728a6e46b3bb082";
|
||||||
|
|
||||||
let tmp = tempfile::tempdir().unwrap();
|
let tmp = tempfile::tempdir().unwrap();
|
||||||
let ctx = test::contributor(tmp.path());
|
let ctx = test::contributor(tmp.path());
|
||||||
|
|
@ -1385,8 +1393,8 @@ mod routes {
|
||||||
let body = serde_json::to_vec(&json!({
|
let body = serde_json::to_vec(&json!({
|
||||||
"title": "Update README",
|
"title": "Update README",
|
||||||
"description": "Do some changes to README",
|
"description": "Do some changes to README",
|
||||||
"target": HEAD,
|
"target": HEAD_1,
|
||||||
"oid": HEAD_1,
|
"oid": HEAD,
|
||||||
"tags": [],
|
"tags": [],
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -1434,6 +1442,10 @@ mod routes {
|
||||||
{
|
{
|
||||||
"id": CREATED_PATCH_ID,
|
"id": CREATED_PATCH_ID,
|
||||||
"description": "",
|
"description": "",
|
||||||
|
"base": HEAD_1,
|
||||||
|
"oid": HEAD,
|
||||||
|
"merges": [],
|
||||||
|
"discussions": [],
|
||||||
"timestamp": 1671125284,
|
"timestamp": 1671125284,
|
||||||
"reviews": [],
|
"reviews": [],
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,6 +393,10 @@ impl Revision {
|
||||||
self.description.get()
|
self.description.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn merges(&self) -> impl Iterator<Item = &Merge> {
|
||||||
|
self.merges.iter().map(|m| m.get())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn reviews(&self) -> impl DoubleEndedIterator<Item = (&PublicKey, &Review)> {
|
pub fn reviews(&self) -> impl DoubleEndedIterator<Item = (&PublicKey, &Review)> {
|
||||||
self.reviews.iter()
|
self.reviews.iter()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue