Pārlūkot izejas kodu

Closes #2320 use commit details for terminal links

main
Eric Amodio pirms 2 gadiem
vecāks
revīzija
006eae8a96
6 mainītis faili ar 95 papildinājumiem un 13 dzēšanām
  1. +8
    -2
      CHANGELOG.md
  2. +9
    -1
      package.json
  3. +1
    -0
      src/config.ts
  4. +26
    -10
      src/terminal/linkProvider.ts
  5. +40
    -0
      src/webviews/apps/settings/partials/terminal-links.html
  6. +11
    -0
      src/webviews/apps/settings/settings.html

+ 8
- 2
CHANGELOG.md Parādīt failu

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds a Terminal Links section to the GitLens Interactive Settings
### Changed
- Improved Rebase editor — better performance and user experience
@ -17,6 +21,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds emoji support for commit messages — closes [#1789](https://github.com/gitkraken/vscode-gitlens/issues/1789)
- Ensures that large rebases show rich commit details
- Changes the _Home_ view to always be available
- Changes SHA terminal links to use the _Commit Details_ view — closes [#2320](https://github.com/gitkraken/vscode-gitlens/issues/2320)
- Adds a `gitlens.terminalLinks.showDetailsView` setting to specify whether to show the _Commit Details_ view when clicking on a commit link
### Fixed
@ -45,9 +51,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds a banner to the _Commit Details_ view to let users know they can move the view to the Secondary Side Bar
### Updated
### Changed
- Updates the _Commit Graph_ settings clarity and ordering
- Changes the _Commit Graph_ settings for improved clarity and ordering
### Fixed

+ 9
- 1
package.json Parādīt failu

@ -2683,7 +2683,15 @@
"type": "boolean",
"default": true,
"markdownDescription": "Specifies whether to enable terminal links — autolinks in the integrated terminal to quickly jump to more details for commits, branches, tags, and more",
"scope": "window"
"scope": "window",
"order": 10
},
"gitlens.terminalLinks.showDetailsView": {
"type": "boolean",
"default": true,
"markdownDescription": "Specifies whether to show the _Commit Details_ view when clicking on a commit link in the integrated terminal",
"scope": "window",
"order": 20
}
}
},

+ 1
- 0
src/config.ts Parādīt failu

@ -156,6 +156,7 @@ export interface Config {
};
terminalLinks: {
enabled: boolean;
showDetailsView: boolean;
};
views: ViewsConfig;
virtualRepositories: {

+ 26
- 10
src/terminal/linkProvider.ts Parādīt failu

@ -2,20 +2,23 @@ import type { Disposable, TerminalLink, TerminalLinkContext, TerminalLinkProvide
import { commands, window } from 'vscode';
import type {
GitCommandsCommandArgs,
ShowCommitsInViewCommandArgs,
ShowQuickBranchHistoryCommandArgs,
ShowQuickCommitCommandArgs,
} from '../commands';
import { configuration } from '../configuration';
import { Commands } from '../constants';
import type { Container } from '../container';
import type { PagedResult } from '../git/gitProvider';
import type { GitBranch } from '../git/models/branch';
import { getBranchNameWithoutRemote } from '../git/models/branch';
import { GitReference } from '../git/models/reference';
import type { GitTag } from '../git/models/tag';
const commandsRegexShared =
/\b(g(?:it)?\b\s*)\b(branch|checkout|cherry-pick|fetch|grep|log|merge|pull|push|rebase|reset|revert|show|stash|status|tag)\b/gi;
// Since negative lookbehind isn't supported in all browsers, leave out the negative lookbehind condition `(?<!\.lock)` to ensure the branch name doesn't end with `.lock`
const refRegexShared = /\b((?!.*\/\.)(?!.*\.\.)(?!.*\/\/)(?!.*@\{)[^\000-\037\177 ~^:?*[\\]+[^./])\b/gi;
const refRegexShared = /\b((?!.*\/\.)(?!.*\.\.)(?!.*\/\/)(?!.*@\{)[^\000-\037\177 ,~^:?*[\\]+[^ ./])\b/gi;
const rangeRegex = /^[0-9a-f]{7,40}\.\.\.?[0-9a-f]{7,40}$/;
const shaRegex = /^[0-9a-f]{7,40}$/;
@ -43,6 +46,8 @@ export class GitTerminalLinkProvider implements Disposable, TerminalLinkProvider
const repoPath = this.container.git.highlander?.path;
if (!repoPath) return [];
const showDetailsView = configuration.get('terminalLinks.showDetailsView');
const links: GitTerminalLink[] = [];
let branchResults: PagedResult<GitBranch> | undefined;
@ -100,7 +105,10 @@ export class GitTerminalLinkProvider implements Disposable, TerminalLinkProvider
// TODO@eamodio handle paging
}
const branch = branchResults.values.find(r => r.name === ref);
let branch = branchResults.values.find(r => r.name === ref);
if (branch == null) {
branch = branchResults.values.find(r => getBranchNameWithoutRemote(r.name) === ref);
}
if (branch != null) {
const link: GitTerminalLink<ShowQuickBranchHistoryCommandArgs> = {
startIndex: match.index,
@ -161,17 +169,25 @@ export class GitTerminalLinkProvider implements Disposable, TerminalLinkProvider
}
if (await this.container.git.validateReference(repoPath, ref)) {
const link: GitTerminalLink<ShowQuickCommitCommandArgs> = {
const link: GitTerminalLink<ShowQuickCommitCommandArgs | ShowCommitsInViewCommandArgs> = {
startIndex: match.index,
length: ref.length,
tooltip: 'Show Commit',
command: {
command: Commands.ShowQuickCommit,
args: {
repoPath: repoPath,
sha: ref,
},
},
command: showDetailsView
? {
command: Commands.ShowInDetailsView,
args: {
repoPath: repoPath,
refs: [ref],
},
}
: {
command: Commands.ShowQuickCommit,
args: {
repoPath: repoPath,
sha: ref,
},
},
};
links.push(link);
}

+ 40
- 0
src/webviews/apps/settings/partials/terminal-links.html Parādīt failu

@ -0,0 +1,40 @@
<section id="terminal-links" class="section--settings section--collapsible">
<div class="section__header">
<div class="setting__input setting__input--big">
<input id="terminalLinks.enabled" name="terminalLinks.enabled" type="checkbox" data-setting />
<label for="terminalLinks.enabled">Terminal Links</label>
<a
class="link__learn-more"
title="Learn more"
href="https://github.com/gitkraken/vscode-gitlens/#terminal-links-"
>
<i class="icon icon__info"></i>
</a>
</div>
<p class="section__header-hint">
Adds autolinks for branches, tags, commits, and commit ranges in the integrated terminal
</p>
</div>
<div class="section__group">
<div class="section__content">
<div class="settings settings--fixed ml-1">
<div class="setting" data-enablement="terminalLinks.enabled" disabled>
<div class="setting__input">
<input
id="terminalLinks.showDetailsView"
name="terminalLinks.showDetailsView"
type="checkbox"
data-setting
disabled
/>
<label for="terminalLinks.showDetailsView">Show Commit Details view for commit links</label>
</div>
</div>
</div>
</div>
<div class="section__preview"></div>
</div>
</section>

+ 11
- 0
src/webviews/apps/settings/settings.html Parādīt failu

@ -85,6 +85,7 @@
<%= require('html-loader?{"esModule":false}!./partials/commit-graph.html') %>
<%= require('html-loader?{"esModule":false}!./partials/rebase-editor.html') %>
<%= require('html-loader?{"esModule":false}!./partials/autolinks.html') %>
<%= require('html-loader?{"esModule":false}!./partials/terminal-links.html') %>
<%= require('html-loader?{"esModule":false}!./partials/dates.html') %>
<%= require('html-loader?{"esModule":false}!./partials/menus.html') %>
<%= require('html-loader?{"esModule":false}!./partials/shortcuts.html') %>
@ -306,6 +307,16 @@
<a
class="sidebar__jump-link"
data-action="jump"
href="#terminal-links"
title="Jump to Terminal Links"
>Terminal Links</a
>
</li>
<li class="mt-1">
<a
class="sidebar__jump-link"
data-action="jump"
href="#dates"
title="Jump to Dates & Times settings"
>Dates & Times</a

Notiek ielāde…
Atcelt
Saglabāt