Browse Source

Fixes #1062 - enables copying of short commit SHAs

eamodio/vscode-gitlens#611 added a setting for commit SHA length,
`gitlens.advanced.abbreviatedShaLength`.

This commit will add `gitlens.advanced.useAbbreviatedShaLengthForCopy`,
which will copy the abbreviated commit SHA instead of the full SHA.
Respects `gitlens.advanced.abbreviatedShaLength`.
main
Brendon Smith 4 years ago
committed by Eric Amodio
parent
commit
628ed498a0
5 changed files with 14 additions and 2 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +2
    -0
      README.md
  3. +7
    -1
      package.json
  4. +3
    -1
      src/commands/copyShaToClipboard.ts
  5. +1
    -0
      src/config.ts

+ 1
- 0
CHANGELOG.md View File

@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds a new _Browse Repository from Before Here_ (`gitlens.browseRepoBeforeRevision`) and _Browse Repository from Before Here in New Window_ (`gitlens.browseRepoBeforeRevisionInNewWindow`) commands
- Adds _Repository from Before Here_ and _Repository from Before Here in New Window_ to the _Browse_ submenu of commits in the views
- Adds a new _Copy Current Branch Name_ (`gitlens.copyCurrentBranch`) command to copy the current branch name to the clipboard — closes [#1306](https://github.com/eamodio/vscode-gitlens/issues/1306) — thanks to [PR #1307](https://github.com/eamodio/vscode-gitlens/pull/1307) by Ken Hom ([@kh0m](https://github.com/kh0m))
- Adds a `gitlens.advanced.useAbbreviatedShaLengthForCopy` setting to copy the abbreviated commit SHA to the clipboard — closes [#1062](https://github.com/eamodio/vscode-gitlens/issues/1062) — thanks to [PR #1316](https://github.com/eamodio/vscode-gitlens/pull/1316) by Brendon Smith ([@br3ndonland](https://github.com/br3ndonland))
### Changed

+ 2
- 0
README.md View File

@ -957,6 +957,7 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
| `gitlens.showWelcomeOnInstall` | Specifies whether to show the Welcome (Quick Setup) experience on first install |
| `gitlens.showWhatsNewAfterUpgrades` | Specifies whether to show the What's New notification after upgrading to new feature releases |
| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of abbreviated commit SHAs (shas) |
| `gitlens.advanced.useAbbreviatedShaLengthForCopy` | Specifies whether abbreviated commit SHAs should be copied instead of full-length SHAs. Respects `abbreviatedShaLength`. |
| `gitlens.advanced.blame.customArguments` | Specifies additional arguments to pass to the `git blame` command |
| `gitlens.advanced.blame.delayAfterEdit` | Specifies the time (in milliseconds) to wait before re-blaming an unsaved document after an edit. Use 0 to specify an infinite wait |
| `gitlens.advanced.blame.sizeThresholdAfterEdit` | Specifies the maximum document size (in lines) allowed to be re-blamed after an edit while still unsaved. Use 0 to specify no maximum |
@ -1044,6 +1045,7 @@ A big thanks to the people that have contributed to this project:
- Miguel Solorio ([@misolori](https://github.com/misolori)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=misolori)
- SpaceEEC ([@SpaceEEC](https://github.com/SpaceEEC)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=SpaceEEC)
- Skybbles ([@Luxray5474](https://github.com/Luxray5474)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Luxray5474)
- Brendon Smith ([@br3ndonland](https://github.com/br3ndonland)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=br3ndonland)
- Mike Surcouf ([@mikes-gh](https://github.com/mikes-gh)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=mikes-gh)
- Alexey Svetliakov ([@asvetliakov](https://github.com/asvetliakov)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=asvetliakov)
- Alexey Vasyukov ([@notmedia](https://github.com/notmedia)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=notmedia)

+ 7
- 1
package.json View File

@ -2341,7 +2341,7 @@
},
"gitlens.advanced.abbreviatedShaLength": {
"type": "number",
"default": "7",
"default": 7,
"markdownDescription": "Specifies the length of abbreviated commit SHAs",
"scope": "window"
},
@ -2464,6 +2464,12 @@
"markdownDescription": "Specifies the amount (percent) of similarity a deleted and added file pair must have to be considered a rename",
"scope": "window"
},
"gitlens.advanced.useAbbreviatedShaLengthForCopy": {
"type": "boolean",
"default": false,
"markdownDescription": "Specifies whether abbreviated commit SHAs should be copied instead of full-length SHAs. Respects `abbreviatedShaLength`.",
"scope": "window"
},
"gitlens.advanced.useSymmetricDifferenceNotation": {
"type": "boolean",
"default": true,

+ 3
- 1
src/commands/copyShaToClipboard.ts View File

@ -29,7 +29,9 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
protected preExecute(context: CommandContext, args?: CopyShaToClipboardCommandArgs) {
if (isCommandContextViewNodeHasCommit(context)) {
args = { ...args };
args.sha = context.node.commit.sha;
args.sha = Container.config.advanced.useAbbreviatedShaLengthForCopy
? context.node.commit.shortSha
: context.node.commit.sha;
return this.execute(context.editor, context.node.commit.uri, args);
} else if (isCommandContextViewNodeHasBranch(context)) {
args = { ...args };

+ 1
- 0
src/config.ts View File

@ -304,6 +304,7 @@ export interface AdvancedConfig {
};
repositorySearchDepth: number;
similarityThreshold: number | null;
useAbbreviatedShaLengthForCopy: boolean;
useSymmetricDifferenceNotation: boolean;
}

Loading…
Cancel
Save