mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-23 10:08:49 +01:00
Merge commit 'refs/pull/70539/head' of github.com:microsoft/vscode into pr/70539
This commit is contained in:
@@ -907,10 +907,22 @@ export class Repository implements Disposable {
|
||||
}
|
||||
|
||||
async commit(message: string, opts: CommitOptions = Object.create(null)): Promise<void> {
|
||||
const config = workspace.getConfiguration('git');
|
||||
const onlyTrackStagedFile = config.get<boolean>('onlyTrackedFilesCanBeAutoStaged');
|
||||
|
||||
if (this.rebaseCommit) {
|
||||
await this.run(Operation.RebaseContinue, async () => {
|
||||
if (opts.all) {
|
||||
await this.repository.add([]);
|
||||
if (onlyTrackStagedFile) {
|
||||
const unstageFiles = await this.trackedUnstagedFiles();
|
||||
if (unstageFiles.length === 0) {
|
||||
window.showInformationMessage(localize('no changes', "There are no changes to commit."));
|
||||
return false;
|
||||
}
|
||||
await this.repository.add(unstageFiles);
|
||||
} else {
|
||||
await this.repository.add([]);
|
||||
}
|
||||
}
|
||||
|
||||
await this.repository.rebaseContinue();
|
||||
@@ -918,7 +930,16 @@ export class Repository implements Disposable {
|
||||
} else {
|
||||
await this.run(Operation.Commit, async () => {
|
||||
if (opts.all) {
|
||||
await this.repository.add([]);
|
||||
if (onlyTrackStagedFile) {
|
||||
const unstageFiles = await this.trackedUnstagedFiles();
|
||||
if (unstageFiles.length === 0) {
|
||||
window.showInformationMessage(localize('no changes', "There are no changes to commit."));
|
||||
return false;
|
||||
}
|
||||
await this.repository.add(unstageFiles);
|
||||
} else {
|
||||
await this.repository.add([]);
|
||||
}
|
||||
}
|
||||
|
||||
await this.repository.commit(message, opts);
|
||||
@@ -1580,6 +1601,12 @@ export class Repository implements Disposable {
|
||||
this.eventuallyUpdateWhenIdleAndWait();
|
||||
}
|
||||
|
||||
private async trackedUnstagedFiles(): Promise<string[]> {
|
||||
const rawChangedFiles = await this.repository.run(['ls-files', '.', '-m']);
|
||||
const parsedFiles = rawChangedFiles.stdout.split('\n').filter(l => !!l);
|
||||
return parsedFiles;
|
||||
}
|
||||
|
||||
@debounce(1000)
|
||||
private eventuallyUpdateWhenIdleAndWait(): void {
|
||||
this.updateWhenIdleAndWait();
|
||||
|
||||
Reference in New Issue
Block a user