mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
add function to get commit detail
This commit is contained in:
parent
018afb52b6
commit
7f459482cc
5 changed files with 111 additions and 2 deletions
36
dist/index.js
vendored
36
dist/index.js
vendored
|
@ -684,6 +684,42 @@ class GitCommandManager {
|
|||
yield this.exec(args);
|
||||
});
|
||||
}
|
||||
getCommit(ref) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const endOfBody = '###EOB###';
|
||||
const output = yield this.exec([
|
||||
'show',
|
||||
'--raw',
|
||||
'--cc',
|
||||
'--diff-filter=AMD',
|
||||
`--format=%H%n%T%n%P%n%s%n%b%n${endOfBody}`,
|
||||
ref
|
||||
]);
|
||||
const lines = output.stdout.split('\n');
|
||||
const endOfBodyIndex = lines.lastIndexOf(endOfBody);
|
||||
const detailLines = lines.slice(0, endOfBodyIndex);
|
||||
return {
|
||||
sha: detailLines[0],
|
||||
tree: detailLines[1],
|
||||
parents: detailLines[2].split(' '),
|
||||
subject: detailLines[3],
|
||||
body: detailLines.slice(4, endOfBodyIndex).join('\n'),
|
||||
changes: lines.slice(endOfBodyIndex + 2, -1).map(line => {
|
||||
const change = line.match(/^:\d{6} (\d{6}) \w{7} \w{7} ([AMD])\s+(.*)$/);
|
||||
if (change) {
|
||||
return {
|
||||
mode: change[1],
|
||||
status: change[2],
|
||||
path: change[3]
|
||||
};
|
||||
}
|
||||
else {
|
||||
throw new Error(`Unexpected line format: ${line}`);
|
||||
}
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
getConfigValue(configKey_1) {
|
||||
return __awaiter(this, arguments, void 0, function* (configKey, configValue = '.') {
|
||||
const output = yield this.exec([
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue