提交 3f90d90a 编写于 作者: D Daniel Davis

Adding .git/SQUASH_MSG detection to commit message autofill

上级 277627c0
......@@ -1939,6 +1939,17 @@ export class Repository {
return message.replace(/^\s*#.*$\n?/gm, '').trim();
}
async getSquashMessage(): Promise<string | undefined> {
const squashMsgPath = path.join(this.repositoryRoot, '.git', 'SQUASH_MSG');
try {
const raw = await fs.readFile(squashMsgPath, 'utf8');
return this.stripCommitMessageComments(raw);
} catch {
return undefined;
}
}
async getMergeMessage(): Promise<string | undefined> {
const mergeMsgPath = path.join(this.repositoryRoot, '.git', 'MERGE_MSG');
......
......@@ -866,9 +866,12 @@ export class Repository implements Disposable {
async getInputTemplate(): Promise<string> {
const mergeMessage = await this.repository.getMergeMessage();
const squashMessage = await this.repository.getSquashMessage();
if (mergeMessage) {
return mergeMessage;
} else if (squashMessage) {
return squashMessage;
}
return await this.repository.getCommitTemplate();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册