httpd: Remove diff and branches from history route
This commit is contained in:
parent
3556758386
commit
574ac3566b
|
|
@ -214,41 +214,21 @@ async fn history_handler(
|
||||||
|
|
||||||
let commits = repo
|
let commits = repo
|
||||||
.history(&sha)?
|
.history(&sha)?
|
||||||
.filter(|q| {
|
.filter_map(|commit| {
|
||||||
if let Ok(q) = q {
|
let commit = commit.ok()?;
|
||||||
if let (Some(since), Some(until)) = (since, until) {
|
let time = commit.committer.time.seconds();
|
||||||
q.committer.time.seconds() >= since && q.committer.time.seconds() < until
|
let commit = api::json::commit(&commit);
|
||||||
} else if let Some(since) = since {
|
match (since, until) {
|
||||||
q.committer.time.seconds() >= since
|
(Some(since), Some(until)) if time >= since && time < until => Some(commit),
|
||||||
} else if let Some(until) = until {
|
(Some(since), None) if time >= since => Some(commit),
|
||||||
q.committer.time.seconds() < until
|
(None, Some(until)) if time < until => Some(commit),
|
||||||
} else {
|
(None, None) => Some(commit),
|
||||||
// If neither `since` nor `until` are specified, we include the commit.
|
_ => None,
|
||||||
true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.skip(page * per_page)
|
.skip(page * per_page)
|
||||||
.take(per_page)
|
.take(per_page)
|
||||||
.map(|r| {
|
.collect::<Vec<_>>();
|
||||||
r.and_then(|c| {
|
|
||||||
let glob = Glob::all_heads().branches().and(Glob::all_remotes());
|
|
||||||
let branches: Vec<String> = repo
|
|
||||||
.revision_branches(c.id, glob)?
|
|
||||||
.iter()
|
|
||||||
.map(|b| b.refname().to_string())
|
|
||||||
.collect();
|
|
||||||
let diff = repo.diff_commit(c.id)?;
|
|
||||||
Ok(json!({
|
|
||||||
"commit": api::json::commit(&c),
|
|
||||||
"diff": diff,
|
|
||||||
"branches": branches
|
|
||||||
}))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
|
||||||
|
|
||||||
let response = json!({
|
let response = json!({
|
||||||
"commits": commits,
|
"commits": commits,
|
||||||
|
|
@ -1124,320 +1104,54 @@ mod routes {
|
||||||
json!({
|
json!({
|
||||||
"commits": [
|
"commits": [
|
||||||
{
|
{
|
||||||
"commit": {
|
"id": HEAD,
|
||||||
"id": HEAD,
|
"author": {
|
||||||
"author": {
|
"name": "Alice Liddell",
|
||||||
"name": "Alice Liddell",
|
"email": "alice@radicle.xyz"
|
||||||
"email": "alice@radicle.xyz"
|
|
||||||
},
|
|
||||||
"summary": "Add another folder",
|
|
||||||
"description": "",
|
|
||||||
"parents": [
|
|
||||||
"ee8d6a29304623a78ebfa5eeed5af674d0e58f83",
|
|
||||||
],
|
|
||||||
"committer": {
|
|
||||||
"name": "Alice Liddell",
|
|
||||||
"email": "alice@radicle.xyz",
|
|
||||||
"time": 1673003014
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"diff": {
|
"summary": "Add another folder",
|
||||||
"added": [
|
"description": "",
|
||||||
{
|
"parents": [
|
||||||
"path": "README",
|
"ee8d6a29304623a78ebfa5eeed5af674d0e58f83",
|
||||||
"diff": {
|
|
||||||
"type": "plain",
|
|
||||||
"hunks": [
|
|
||||||
{
|
|
||||||
"header": "@@ -0,0 +1 @@\n",
|
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Hello World!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "addition",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 1,
|
|
||||||
"deletions": 0,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"oid": "980a0d5f19a64b4b30a87d4206aade58726b60e3",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "dir1/README",
|
|
||||||
"diff": {
|
|
||||||
"type": "plain",
|
|
||||||
"hunks": [
|
|
||||||
{
|
|
||||||
"header": "@@ -0,0 +1 @@\n",
|
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Hello World from dir1!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "addition"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 1,
|
|
||||||
"deletions": 0,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"oid": "1dd5654ca2d2cf9f33b14c92b5ca9e1d21a91ae1",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"deleted": [
|
|
||||||
{
|
|
||||||
"path": "CONTRIBUTING",
|
|
||||||
"diff": {
|
|
||||||
"type": "plain",
|
|
||||||
"hunks": [
|
|
||||||
{
|
|
||||||
"header": "@@ -1 +0,0 @@\n",
|
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Thank you very much!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "deletion",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 0,
|
|
||||||
"deletions": 1,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"old": {
|
|
||||||
"oid": "82eb77880c693655bce074e3dbbd9fa711dc018b",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"moved": [],
|
|
||||||
"copied": [],
|
|
||||||
"modified": [],
|
|
||||||
"stats": {
|
|
||||||
"filesChanged": 3,
|
|
||||||
"insertions": 2,
|
|
||||||
"deletions": 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"branches": [
|
|
||||||
"refs/heads/master"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"commit": {
|
|
||||||
"id": PARENT,
|
|
||||||
"author": {
|
|
||||||
"name": "Alice Liddell",
|
|
||||||
"email": "alice@radicle.xyz"
|
|
||||||
},
|
|
||||||
"summary": "Add contributing file",
|
|
||||||
"description": "",
|
|
||||||
"parents": [
|
|
||||||
"f604ce9fd5b7cc77b7609beda45ea8760bee78f7",
|
|
||||||
],
|
|
||||||
"committer": {
|
|
||||||
"name": "Alice Liddell",
|
|
||||||
"email": "alice@radicle.xyz",
|
|
||||||
"time": 1673002014,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"diff": {
|
|
||||||
"added": [
|
|
||||||
{
|
|
||||||
"path": "CONTRIBUTING",
|
|
||||||
"diff": {
|
|
||||||
"type": "plain",
|
|
||||||
"hunks": [
|
|
||||||
{
|
|
||||||
"header": "@@ -0,0 +1 @@\n",
|
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Thank you very much!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "addition",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 1,
|
|
||||||
"deletions": 0,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"oid": "82eb77880c693655bce074e3dbbd9fa711dc018b",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"deleted": [
|
|
||||||
{
|
|
||||||
"path": "README",
|
|
||||||
"diff": {
|
|
||||||
"type": "plain",
|
|
||||||
"hunks": [
|
|
||||||
{
|
|
||||||
"header": "@@ -1 +0,0 @@\n",
|
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Hello World!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "deletion",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 0,
|
|
||||||
"deletions": 1,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"old": {
|
|
||||||
"oid": "980a0d5f19a64b4b30a87d4206aade58726b60e3",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"moved": [],
|
|
||||||
"copied": [],
|
|
||||||
"modified": [],
|
|
||||||
"stats": {
|
|
||||||
"filesChanged": 2,
|
|
||||||
"insertions": 1,
|
|
||||||
"deletions": 1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"branches": [
|
|
||||||
"refs/heads/master",
|
|
||||||
],
|
],
|
||||||
|
"committer": {
|
||||||
|
"name": "Alice Liddell",
|
||||||
|
"email": "alice@radicle.xyz",
|
||||||
|
"time": 1673003014
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"commit": {
|
"id": PARENT,
|
||||||
"id": INITIAL_COMMIT,
|
"author": {
|
||||||
"author": {
|
"name": "Alice Liddell",
|
||||||
"name": "Alice Liddell",
|
"email": "alice@radicle.xyz"
|
||||||
"email": "alice@radicle.xyz",
|
|
||||||
},
|
|
||||||
"summary": "Initial commit",
|
|
||||||
"description": "",
|
|
||||||
"parents": [],
|
|
||||||
"committer": {
|
|
||||||
"name": "Alice Liddell",
|
|
||||||
"email": "alice@radicle.xyz",
|
|
||||||
"time": 1673001014,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"diff": {
|
"summary": "Add contributing file",
|
||||||
"added": [
|
"description": "",
|
||||||
{
|
"parents": [
|
||||||
"path": "README",
|
"f604ce9fd5b7cc77b7609beda45ea8760bee78f7",
|
||||||
"diff": {
|
],
|
||||||
"type": "plain",
|
"committer": {
|
||||||
"hunks": [
|
"name": "Alice Liddell",
|
||||||
{
|
"email": "alice@radicle.xyz",
|
||||||
"header": "@@ -0,0 +1 @@\n",
|
"time": 1673002014,
|
||||||
"lines": [
|
|
||||||
{
|
|
||||||
"line": "Hello World!\n",
|
|
||||||
"lineNo": 1,
|
|
||||||
"type": "addition"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"old": {
|
|
||||||
"start": 0,
|
|
||||||
"end": 0,
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"start": 1,
|
|
||||||
"end": 2,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"stats": {
|
|
||||||
"additions": 1,
|
|
||||||
"deletions": 0,
|
|
||||||
},
|
|
||||||
"eof": "noneMissing",
|
|
||||||
},
|
|
||||||
"new": {
|
|
||||||
"oid": "980a0d5f19a64b4b30a87d4206aade58726b60e3",
|
|
||||||
"mode": "blob",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"deleted": [],
|
|
||||||
"moved": [],
|
|
||||||
"copied": [],
|
|
||||||
"modified": [],
|
|
||||||
"stats": {
|
|
||||||
"filesChanged": 1,
|
|
||||||
"insertions": 1,
|
|
||||||
"deletions": 0
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"branches": [
|
},
|
||||||
"refs/heads/master"
|
{
|
||||||
]
|
"id": INITIAL_COMMIT,
|
||||||
}
|
"author": {
|
||||||
|
"name": "Alice Liddell",
|
||||||
|
"email": "alice@radicle.xyz",
|
||||||
|
},
|
||||||
|
"summary": "Initial commit",
|
||||||
|
"description": "",
|
||||||
|
"parents": [],
|
||||||
|
"committer": {
|
||||||
|
"name": "Alice Liddell",
|
||||||
|
"email": "alice@radicle.xyz",
|
||||||
|
"time": 1673001014,
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"stats": {
|
"stats": {
|
||||||
"commits": 3,
|
"commits": 3,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue