mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 19:18:59 +01:00
Adding .git/SQUASH_MSG detection to commit message autofill
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user