Skip to content

Commit 1a6550d

Browse files
committed
Applies gitlens.advanced.abbreviateShaOnCopy to copyRemoteFileUrlToClipboard
Closes #2160 When copying a remote file URL to the clipboard, if the user has enabled the gitlens.advanced.abbreviateShaOnCopy setting, the SHA in the URL will now be abbreviated (shortened) just like when copying a SHA directly. This affects the following commands: - gitlens.copyRemoteFileUrlToClipboard - gitlens.copyRemoteFileUrlWithoutRange - gitlens.copyRemoteFileUrlFrom
1 parent f3998a6 commit 1a6550d

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/commands/openFileOnRemote.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LineRange } from '@gitlens/git/models/lineRange.js';
33
import type { GitRemote } from '@gitlens/git/models/remote.js';
44
import { RemoteResourceType } from '@gitlens/git/models/remoteResource.js';
55
import { getBranchNameWithoutRemote, getRemoteNameFromBranchName } from '@gitlens/git/utils/branch.utils.js';
6-
import { isSha } from '@gitlens/git/utils/revision.utils.js';
6+
import { isSha, shortenRevision } from '@gitlens/git/utils/revision.utils.js';
77
import { Logger } from '@gitlens/utils/logger.js';
88
import { pad, splitSingle } from '@gitlens/utils/string.js';
99
import { areUrisEqual } from '@gitlens/utils/uri.js';
@@ -13,6 +13,7 @@ import { GitUri } from '../git/gitUri.js';
1313
import { showGenericErrorMessage } from '../messages.js';
1414
import { showReferencePicker } from '../quickpicks/referencePicker.js';
1515
import { command, executeCommand } from '../system/-webview/command.js';
16+
import { configuration } from '../system/-webview/configuration.js';
1617
import { StatusFileNode } from '../views/nodes/statusFileNode.js';
1718
import { ActiveEditorCommand } from './commandBase.js';
1819
import { getCommandUri } from './commandBase.utils.js';
@@ -213,7 +214,10 @@ export class OpenFileOnRemoteCommand extends ActiveEditorCommand {
213214
branchOrTag: args.branchOrTag ?? 'HEAD',
214215
fileName: gitUri.relativePath,
215216
range: range,
216-
sha: sha ?? undefined,
217+
sha:
218+
sha != null && args.clipboard && configuration.get('advanced.abbreviateShaOnCopy')
219+
? shortenRevision(sha)
220+
: (sha ?? undefined),
217221
},
218222
repoPath: gitUri.repoPath,
219223
remotes: remotes,

0 commit comments

Comments
 (0)