ref #44776 Get previous commits as part of commit info

This commit is contained in:
Ryuichi Inagaki
2018-04-08 23:41:43 +10:00
parent d562ebbf25
commit 3fdf0bcc56
2 changed files with 9 additions and 6 deletions

View File

@@ -481,6 +481,7 @@ export class Git {
export interface Commit {
hash: string;
message: string;
previousHashes: string[];
}
export class GitStatusParser {
@@ -1287,14 +1288,14 @@ export class Repository {
}
async getCommit(ref: string): Promise<Commit> {
const result = await this.run(['show', '-s', '--format=%H\n%B', ref]);
const match = /^([0-9a-f]{40})\n([^]*)$/m.exec(result.stdout.trim());
const result = await this.run(['show', '-s', '--format=%H\n%P\n%B', ref]);
const match = /^([0-9a-f]{40})\n(.*)\n([^]*)$/m.exec(result.stdout.trim());
if (!match) {
return Promise.reject<Commit>('bad commit format');
}
return { hash: match[1], message: match[2] };
return { hash: match[1], message: match[3], previousHashes: [match[2]] };
}
async updateSubmodules(paths: string[]): Promise<void> {