aboutsummaryrefslogtreecommitdiff
path: root/api/git.js
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-05-10 15:50:25 +0200
committerHampusM <hampus@hampusmat.com>2021-05-10 15:50:25 +0200
commitd546492f4fd400ae61a6abbe1905fdbc67451c4d (patch)
treecb52ab484ed3118918879339dadbb59889492b69 /api/git.js
parentf6bbf168c6a3004cd922ebc6d4171d1dfc43707e (diff)
Commit endpoint includes hash, author & date and removed unnecessary characters from the to and from values
Diffstat (limited to 'api/git.js')
-rw-r--r--api/git.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/api/git.js b/api/git.js
index 9718f39..3f7b69c 100644
--- a/api/git.js
+++ b/api/git.js
@@ -146,7 +146,7 @@ function getCommit(base_dir, repo, hash)
{
return new Promise((resolve) =>
{
- const git = execGit(`${base_dir}/${repo}`, "show", ['--format=format:\"hash\": \"%H\, \"author\": \"%an <%ae>\", \"date\": \"%at\", \"message\": \"%s\", \"diff\": \"', hash], (err) => resolve(err));
+ const git = execGit(`${base_dir}/${repo}`, "show", ['--format=format:{\"hash\": \"%H\", \"author\": \"%an <%ae>\", \"date\": \"%at\", \"message\": \"%s\"}', hash], (err) => resolve(err));
let commit = [];
@@ -177,8 +177,8 @@ function getCommit(base_dir, repo, hash)
let header = file_diff.slice(1, chunk_header_index - 2);
const from_to = file_diff.slice(chunk_header_index - 2, chunk_header_index);
- file_info["from"] = from_to[0];
- file_info["to"] = from_to[1];
+ file_info["from"] = from_to[0].slice(4);
+ file_info["to"] = from_to[1].slice(4);
if(chunk_header_index != file_diff.length) {
const chunk_header = /^@@\ (-[0-9,]+)\ (\+[0-9,]+)\ @@(?:\ (.*))?/.exec(file_diff[chunk_header_index]);
@@ -224,7 +224,9 @@ function getCommit(base_dir, repo, hash)
start = index;
}
if(index === diff.length - 1) {
- resolve({ "data": result });
+ let data = JSON.parse(commit.toString().split('\n').slice(0,1)[0]);
+ data["files"] = result;
+ resolve({ "data": data });
}
});
});