Update some git stuff
This commit is contained in:
parent
97f7d8d073
commit
4b4dbd7b93
23
index.js
23
index.js
|
@ -123,19 +123,22 @@ function getGitCommitDetails() {
|
||||||
// Use child_process.execSync to run the `git log -1 --format=%H%x09%an%x09%ae%x09%ad%x09%s` command
|
// Use child_process.execSync to run the `git log -1 --format=%H%x09%an%x09%ae%x09%ad%x09%s` command
|
||||||
// and return the output as a string
|
// and return the output as a string
|
||||||
const stdout = childProcess.execSync('git log -1 --format=%H%x09%an%x09%ae%x09%ad%x09%s').toString();
|
const stdout = childProcess.execSync('git log -1 --format=%H%x09%an%x09%ae%x09%ad%x09%s').toString();
|
||||||
|
const origin = childProcess.execSync('git config --get remote.origin.url').toString().trim().replace(/\.git$/, '');
|
||||||
// Split the output string into an array of fields
|
// Split the output string into an array of fields
|
||||||
const fields = stdout.split('\t');
|
const fields = stdout.split('\t');
|
||||||
|
|
||||||
// Return the commit details as a JSON object
|
// Return the commit details as a JSON object
|
||||||
return {
|
return {
|
||||||
hash: fields[0].substring(0, 7),
|
commit: {
|
||||||
fullHash: fields[0],
|
hash: fields[0].substring(0, 7),
|
||||||
author: fields[1],
|
fullHash: fields[0],
|
||||||
email: fields[2],
|
author: fields[1],
|
||||||
timestamp: fields[3],
|
email: fields[2],
|
||||||
subject: fields[4],
|
timestamp: fields[3],
|
||||||
};
|
subject: fields[4]
|
||||||
|
},
|
||||||
|
origin
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -454,8 +457,8 @@ app.get('/', (req, res) => {
|
||||||
],
|
],
|
||||||
"about": {
|
"about": {
|
||||||
"author": "Chris Chrome",
|
"author": "Chris Chrome",
|
||||||
"repo": "https://github.com/TerraDevelopers/TerraStatusAPI",
|
// Get repo
|
||||||
"commit": getGitCommitDetails()
|
"repo": getGitCommitDetails()
|
||||||
},
|
},
|
||||||
// Rate limit X requests per Y minutes per IP, as a string
|
// Rate limit X requests per Y minutes per IP, as a string
|
||||||
"rateLimit": `${config.rateLimitMax} requests per ${config.rateLimitWindow} minutes`,
|
"rateLimit": `${config.rateLimitMax} requests per ${config.rateLimitWindow} minutes`,
|
||||||
|
|
Loading…
Reference in a new issue