Skip to content

Applies gitlens.advanced.abbreviateShaOnCopy to copyRemoteFileUrlToClipboard#5223

Open
01luyicheng wants to merge 3 commits into
gitkraken:mainfrom
01luyicheng:feature/abbreviate-sha-on-copy-remote-url
Open

Applies gitlens.advanced.abbreviateShaOnCopy to copyRemoteFileUrlToClipboard#5223
01luyicheng wants to merge 3 commits into
gitkraken:mainfrom
01luyicheng:feature/abbreviate-sha-on-copy-remote-url

Conversation

@01luyicheng

Copy link
Copy Markdown

Description

This PR applies the gitlens.advanced.abbreviateShaOnCopy setting to the gitlens.copyRemoteFileUrlToClipboard command (and related clipboard commands), so that when copying a remote file URL to the clipboard, the SHA in the URL will be abbreviated if the user has enabled this setting.

Fixes #2160

Changes

  • Modified OpenFileOnRemoteCommand.execute() in src/commands/openFileOnRemote.ts
  • When args.clipboard is true and configuration.get('advanced.abbreviateShaOnCopy') is enabled, the SHA is shortened using shortenRevision() before being passed to the remote provider URL builder

Affected Commands

  • gitlens.copyRemoteFileUrlToClipboard
  • gitlens.copyRemoteFileUrlWithoutRange
  • gitlens.copyRemoteFileUrlFrom

Checklist

  • I have read the Contributing Guidelines
  • The code follows the project's coding standards
  • The change is minimal and focused on the issue at hand
  • The behavior is consistent with the existing copyShaToClipboard command

Copilot AI review requested due to automatic review settings May 13, 2026 12:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the “Copy Remote File URL …” command family to respect the existing gitlens.advanced.abbreviateShaOnCopy setting, abbreviating commit SHAs in generated remote URLs when copying to the clipboard.

Changes:

  • Imports shortenRevision() and applies it to the sha passed into the remote URL builder when args.clipboard is true and advanced.abbreviateShaOnCopy is enabled.
  • Wires configuration access into OpenFileOnRemoteCommand.execute() to drive the new behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/commands/openFileOnRemote.ts Outdated
range: range,
sha: sha ?? undefined,
sha:
sha != null && args.clipboard && configuration.get('advanced.abbreviateShaOnCopy')
…ipboard

Closes gitkraken#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
@01luyicheng 01luyicheng force-pushed the feature/abbreviate-sha-on-copy-remote-url branch from 1a6550d to 9b0ad08 Compare May 13, 2026 12:40
@01luyicheng 01luyicheng requested a review from Copilot May 27, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Apply gitlens.advanced.abbreviateShaOnCopy to gitlens.copyRemoteFileUrlToClipboard

2 participants