提交 010a92da 编写于 作者: W William Raiford

Load commit.template working.

上级 13ff0573
......@@ -270,12 +270,21 @@ export interface IPushOptions {
setUpstream?: boolean;
}
/** These are `git log` options. */
/**
* These are `git log` options.
* The use case driving this is getting the previous commit message, message only.
* @example prevCount: 1, format: '%B' executes `git log -1 --format=%B`
* */
export interface ILogOptions {
/**
* @example `git log -1` to get the last commit log
* @example `git log -1 --format=%B` to get the last commit log, message only
*/
prevCount?: number;
/**
* @example format: "%B" translates to `git log --format=%B` to get the message only
*/
format?: string;
}
export interface IRawGitService {
......
......@@ -562,7 +562,10 @@ export class Repository {
console.log('repository.getLog');
const args = ['log'];
if (options && options.prevCount) { args.push(`-${options.prevCount}`); }
if (options) {
if (options.prevCount) { args.push(`-${options.prevCount}`); }
if (options.format) { args.push(`--format=${options.format}`); }
}
return this.run(args, { log: false }).then(result => {
console.log(`Repository.getLog=>result: ${result.stdout.trim()}`);
......
......@@ -204,13 +204,13 @@ export class RawGitService implements IRawGitService {
console.log(`getCommitInfo.config err=> ${err.message}`);
return "";
}),
this.repo.getLog({ prevCount: 1 }).then(log => log, err => ""),
this.repo.getLog({ prevCount: 1, format: '%B' }).then(log => log, err => ""),
this.status()
]).then(r => {
console.log('RawGitService.getCommitInfo=>Promise.join');
let status = <IRawStatus>r[2];
status.commitInfo = {
template: r[0] ? this.tryReadFile(r[0].stdout) : "",
template: r[0] ? this.tryReadFile(r[0].stdout.trim()) : "",
// template: r[0] ? r[0].stdout : "",
prevCommitMsg: r[1]
};
......@@ -224,11 +224,14 @@ export class RawGitService implements IRawGitService {
*/
private tryReadFile(file: string): string {
try {
if (!fs.existsSync(file)) {
console.log(`file doesnt exist. file: ${file}`)
}
// Check the file itself
// if (!fs.existsSync(file)) {
// console.log(`file doesnt exist. file: ${file}`)
// }
return fs.existsSync(file) ? fs.readFileSync(file, 'utf8') : "";
} catch (error) {
console.error(`Error reading file. file: ${file}, error: ${error.message})`);
return "";
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册