Merge pull request #101114 from daniel-j-davis/feature/add-git-squash-message
Adding .git/SQUASH_MSG detection to commit message auto-fill #101078
This commit is contained in:
commit
57f08f6b74
2 changed files with 14 additions and 3 deletions
|
@ -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');
|
||||
|
||||
|
|
|
@ -865,10 +865,10 @@ export class Repository implements Disposable {
|
|||
}
|
||||
|
||||
async getInputTemplate(): Promise<string> {
|
||||
const mergeMessage = await this.repository.getMergeMessage();
|
||||
const commitMessage = (await Promise.all([this.repository.getMergeMessage(), this.repository.getSquashMessage()])).find(msg => msg !== undefined);
|
||||
|
||||
if (mergeMessage) {
|
||||
return mergeMessage;
|
||||
if (commitMessage) {
|
||||
return commitMessage;
|
||||
}
|
||||
|
||||
return await this.repository.getCommitTemplate();
|
||||
|
|
Loading…
Reference in a new issue