Skip to content

Commit 25c3716

Browse files
authored
disable untrackedChangesEnableTrash in linux snap (microsoft#242188)
* disable untrackedChangesEnableTrash in linux snap related to microsoft#241476 cc @lszomoru * missing isLinuxSnap check
1 parent d88e573 commit 25c3716

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

extensions/git/package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@
288288
"config.commitShortHashLength": "Controls the length of the commit short hash.",
289289
"config.diagnosticsCommitHook.Enabled": "Controls whether to check for unresolved diagnostics before committing.",
290290
"config.diagnosticsCommitHook.Sources": "Controls the list of sources (**Item**) and the minimum severity (**Value**) to be considered before committing. **Note:** To ignore diagnostics from a particular source, add the source to the list and set the minimum severity to `none`.",
291-
"config.discardUntrackedChangesToTrash": "Controls whether discarding untracked changes moves the file(s) to the Recycle Bin (Windows), Trash (macOS, Linux) instead of deleting them permanently. **Note:** This setting has no effect when connected to a remote.",
291+
"config.discardUntrackedChangesToTrash": "Controls whether discarding untracked changes moves the file(s) to the Recycle Bin (Windows), Trash (macOS, Linux) instead of deleting them permanently. **Note:** This setting has no effect when connected to a remote or when running in Linux as a snap package.",
292292
"submenu.explorer": "Git",
293293
"submenu.commit": "Commit",
294294
"submenu.commit.amend": "Amend",

extensions/git/src/commands.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { Model } from './model';
1414
import { GitResourceGroup, Repository, Resource, ResourceGroupType } from './repository';
1515
import { DiffEditorSelectionHunkToolbarContext, applyLineChanges, getIndexDiffInformation, getModifiedRange, getWorkingTreeDiffInformation, intersectDiffWithRange, invertLineChange, toLineChanges, toLineRanges } from './staging';
1616
import { fromGitUri, toGitUri, isGitUri, toMergeUris, toMultiFileDiffEditorUris } from './uri';
17-
import { DiagnosticSeverityConfig, dispose, getCommitShortHash, grep, isDefined, isDescendant, isRemote, isWindows, pathEquals, relativePath, toDiagnosticSeverity, truncate } from './util';
17+
import { DiagnosticSeverityConfig, dispose, getCommitShortHash, grep, isDefined, isDescendant, isLinuxSnap, isRemote, isWindows, pathEquals, relativePath, toDiagnosticSeverity, truncate } from './util';
1818
import { GitTimelineItem } from './timelineProvider';
1919
import { ApiRepository } from './api/api1';
2020
import { getRemoteSourceActions, pickRemoteSource } from './remoteSource';
@@ -2175,7 +2175,7 @@ export class CommandCenter {
21752175

21762176
private getDiscardUntrackedChangesDialogDetails(resources: Resource[]): [string, string, string] {
21772177
const config = workspace.getConfiguration('git');
2178-
const discardUntrackedChangesToTrash = config.get<boolean>('discardUntrackedChangesToTrash', true) && !isRemote;
2178+
const discardUntrackedChangesToTrash = config.get<boolean>('discardUntrackedChangesToTrash', true) && !isRemote && !isLinuxSnap;
21792179

21802180
const messageWarning = !discardUntrackedChangesToTrash
21812181
? resources.length === 1

extensions/git/src/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IPushErrorHandlerRegistry } from './pushError';
2222
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
2323
import { StatusBarCommands } from './statusbar';
2424
import { toGitUri } from './uri';
25-
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, getCommitShortHash, IDisposable, isDescendant, isRemote, Limiter, onceEvent, pathEquals, relativePath } from './util';
25+
import { anyEvent, combinedDisposable, debounceEvent, dispose, EmptyDisposable, eventToPromise, filterEvent, find, getCommitShortHash, IDisposable, isDescendant, isLinuxSnap, isRemote, Limiter, onceEvent, pathEquals, relativePath } from './util';
2626
import { IFileWatcher, watch } from './watch';
2727
import { ISourceControlHistoryItemDetailsProviderRegistry } from './historyItemDetailsProvider';
2828

@@ -1349,7 +1349,7 @@ export class Repository implements Disposable {
13491349

13501350
async clean(resources: Uri[]): Promise<void> {
13511351
const config = workspace.getConfiguration('git');
1352-
const discardUntrackedChangesToTrash = config.get<boolean>('discardUntrackedChangesToTrash', true) && !isRemote;
1352+
const discardUntrackedChangesToTrash = config.get<boolean>('discardUntrackedChangesToTrash', true) && !isRemote && !isLinuxSnap;
13531353

13541354
await this.run(
13551355
Operation.Clean(!this.optimisticUpdateEnabled()),

extensions/git/src/util.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import byline from 'byline';
1212
export const isMacintosh = process.platform === 'darwin';
1313
export const isWindows = process.platform === 'win32';
1414
export const isRemote = env.remoteName !== undefined;
15+
export const isLinux = process.platform === 'linux';
16+
export const isLinuxSnap = isLinux && !!process.env['SNAP'] && !!process.env['SNAP_REVISION'];
1517

1618
export function log(...args: any[]): void {
1719
console.log.apply(console, ['git:', ...args]);

0 commit comments

Comments
 (0)