Browse Source

Adds recognition for Skybbles // L5474's contribution

Tweaks shorten logic to only allow >=5 chars & always append any suffix
main
Eric Amodio 6 years ago
parent
commit
df0a30d574
4 changed files with 19 additions and 9 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +3
    -2
      README.md
  3. +1
    -1
      package.json
  4. +14
    -6
      src/git/git.ts

+ 1
- 0
CHANGELOG.md View File

@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Fixes [#606](https://github.com/eamodio/vscode-gitlens/issues/606) - ID for xxx is already registered?!
- Fixes [#607](https://github.com/eamodio/vscode-gitlens/issues/607) - Open file in Remote Doesn't URL encode
- Fixes [#608](https://github.com/eamodio/vscode-gitlens/issues/608) - Add an option to change the abbreviated commit SHA length — thanks to [PR #611](https://github.com/eamodio/vscode-gitlens/pull/611) by Skybbles // L5474 ([@Luxray5474](https://github.com/Luxray5474))
- Fixes [#613](https://github.com/eamodio/vscode-gitlens/issues/613) - Change Copy Remote URL to Clipboard to always copy a permalink (e.g. revision link)
## [9.3.0] - 2019-01-02

+ 3
- 2
README.md View File

@ -841,8 +841,8 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
### Advanced Settings [#](#advanced-settings- 'Advanced Settings')
| Name | Description |
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------|
| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7.
| ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| `gitlens.advanced.abbreviatedShaLength` | Specifies the length of abbreviated commit ids (shas) |
| `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 |
@ -919,6 +919,7 @@ A big thanks to the people that have contributed to this project:
- Zack Schuster ([@zackschuster](https://github.com/zackschuster)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=zackschuster)
- sgtwilko ([@sgtwilko](https://github.com/sgtwilko)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=sgtwilko)
- SpaceEEC ([@SpaceEEC](https://github.com/SpaceEEC)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=SpaceEEC)
- Skybbles // L5474 ([@Luxray5474](https://github.com/Luxray5474)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Luxray5474)
- Alexey Vasyukov ([@notmedia](https://github.com/notmedia)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=notmedia)
- Zyck ([@qzyse2017](https://github.com/qzyse2017)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=qzyse2017)

+ 1
- 1
package.json View File

@ -1586,7 +1586,7 @@
"gitlens.advanced.abbreviatedShaLength": {
"type": "number",
"default": "7",
"markdownDescription": "Specifies the length of the abbreviated commit SHA (a.k.a. commit ID). Default is 7.",
"markdownDescription": "Specifies the length of abbreviated commit ids (shas)",
"scope": "window"
},
"gitlens.advanced.blame.customArguments": {

+ 14
- 6
src/git/git.ts View File

@ -223,6 +223,7 @@ export class Git {
static deletedOrMissingSha = '0000000000000000000000000000000000000000-';
static shaLikeRegex = /(^[0-9a-f]{40}([\^@~:]\S*)?$)|(^[0]{40}(:|-)$)/;
static shaRegex = /(^[0-9a-f]{40}$)|(^[0]{40}(:|-)$)/;
static shaShortenRegex = /^(.*?)([\^@~:].*)?$/;
static stagedUncommittedRegex = /^[0]{40}([\^@~]\S*)?:$/;
static stagedUncommittedSha = '0000000000000000000000000000000000000000:';
static uncommittedRegex = /^[0]{40}(?:[\^@~:]\S*)?:?$/;
@ -281,13 +282,20 @@ export class Git {
return strings.uncommitted;
}
const index = ref.indexOf('^');
if (index > 5) {
// Only grab a max of 5 chars for the suffix
const suffix = ref.substring(index).substring(0, 5);
return `${ref.substring(0, Container.config.advanced.abbreviatedShaLength - suffix.length)}${suffix}`;
// Don't allow shas to be shortened to less than 5 characters
const len = Math.max(5, Container.config.advanced.abbreviatedShaLength);
// If we have a suffix, append it
const match = Git.shaShortenRegex.exec(ref);
if (match != null) {
const [, rev, suffix] = match;
if (suffix != null) {
return `${rev.substr(0, len)}${suffix}`;
}
}
return ref.substring(0, Container.config.advanced.abbreviatedShaLength);
return ref.substr(0, len);
}
static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] {

Loading…
Cancel
Save