Преглед изворни кода

Adds control over following renames

Adds advanced.fileHistoryFollowsRenames setting
Adds commands to set rename following to the GitLens explorer
main
Eric Amodio пре 6 година
родитељ
комит
147301ac05
8 измењених фајлова са 70 додато и 9 уклоњено
  1. +3
    -0
      CHANGELOG.md
  2. +2
    -1
      README.md
  3. +34
    -0
      package.json
  4. +17
    -2
      src/configuration.ts
  5. +3
    -3
      src/gitService.ts
  6. +1
    -1
      src/quickPicks/commitFileDetails.ts
  7. +1
    -0
      src/ui/config.ts
  8. +9
    -2
      src/views/gitExplorer.ts

+ 3
- 0
CHANGELOG.md Прегледај датотеку

@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds a tree layout option to branches in the *GitLens* explorer — closes [#258](https://github.com/eamodio/vscode-gitlens/issues/258) thanks to [PR #260](https://github.com/eamodio/vscode-gitlens/pull/260) by Yukai Huang ([@Yukaii](https://github.com/Yukaii))!
- Adds *Follow Renames* command (`gitlens.gitExplorer.setRenameFollowingOn`) to the **GitLens** explorer *History* view to follow file renames in the history
- Adds *Don't Follow Renames* command (`gitlens.gitExplorer.setRenameFollowingOff`) to the **GitLens** explorer *History* view to not follow file renames in the history
- Adds `gitlens.advanced.fileHistoryFollowsRenames` setting to specify whether file histories will follow renames -- will affect how merge commits are shown in histories — closes [#259](https://github.com/eamodio/vscode-gitlens/issues/259)
### Fixed
- Fixes [#35](https://github.com/eamodio/vscode-gitlens/issues/35) - Copy Commit Sha to Clipboard not working (linux)

+ 2
- 1
README.md Прегледај датотеку

@ -56,7 +56,7 @@ Here are a few ways you can help — feel free to choose more than one 
A [customizable](#gitlens-explorer-settings "Jump to the GitLens Explorer settings") explorer to navigate and explore repositories or file histories. The GitLens explorer provides two views (modes) — a Repository view and a History view.
- A toolbar provides *Search Commits*, *Switch to Repository View* or *Switch to History View*, and *Refresh* commands
- Quickly switch between views using the *Switch to Repository View* or *Switch to History View* commands
- A context menu provides *Automatic Layout*, *List Layout*, and *Tree Layout* commands
- A context menu provides *Automatic Layout*, *List Layout*, *Tree Layout*, *Enable Automatic Refresh* or *Disable Automatic Refresh*, and *Follow Renames* or *Don't Follow Renames* commands
#### Repository view
<p align="center">
@ -595,6 +595,7 @@ See also [Explorer Settings](#explorer-settings "Jump to the Explorer settings")
|`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
|`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached &mdash; changing the default is not recommended
|`gitlens.advanced.git`|Specifies the git path to use
|`gitlens.advanced.fileHistoryFollowsRenames`|Specifies whether file histories will follow renames -- will affect how merge commits are shown in histories
|`gitlens.advanced.maxListItems`|Specifies the maximum number of items to show in a list. Use 0 to specify no maximum
|`gitlens.advanced.menus`|Specifies which commands will be added to which menus
|`gitlens.advanced.messages`|Specifies which messages should be suppressed

+ 34
- 0
package.json Прегледај датотеку

@ -779,6 +779,12 @@
"description": "Specifies the git path to use",
"scope": "window"
},
"gitlens.advanced.fileHistoryFollowsRenames": {
"type": "boolean",
"default": true,
"description": "Specifies whether file histories will follow renames -- will affect how merge commits are shown in histories",
"scope": "window"
},
"gitlens.advanced.maxListItems": {
"type": "number",
"default": 200,
@ -1532,6 +1538,16 @@
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"title": "Follow Renames",
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"title": "Don't Follow Renames",
"category": "GitLens"
},
{
"command": "gitlens.gitExplorer.switchToHistoryView",
"title": "Switch to History View",
"category": "GitLens",
@ -1946,6 +1962,14 @@
"when": "false"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"when": "false"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"when": "false"
},
{
"command": "gitlens.gitExplorer.switchToHistoryView",
"when": "gitlens:enabled && gitlens:gitExplorer:view == repository"
},
@ -2255,6 +2279,16 @@
"group": "2_gitlens"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOn",
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && !config.gitlens.advanced.fileHistoryFollowsRenames",
"group": "2_gitlens_1"
},
{
"command": "gitlens.gitExplorer.setRenameFollowingOff",
"when": "view == gitlens.gitExplorer && gitlens:gitExplorer:view == history && config.gitlens.advanced.fileHistoryFollowsRenames",
"group": "2_gitlens_1"
},
{
"command": "gitlens.showCommitSearch",
"when": "view == gitlens.resultsExplorer",
"group": "navigation@1"

+ 17
- 2
src/configuration.ts Прегледај датотеку

@ -110,8 +110,23 @@ export class Configuration {
return Functions.propOf(emptyConfig as IConfig, name);
}
update(section: string, value: any, target: ConfigurationTarget) {
return workspace.getConfiguration(ExtensionKey).update(section, value, target);
update(section: string, value: any, target: ConfigurationTarget, resource?: Uri | null) {
return workspace
.getConfiguration(ExtensionKey, target === ConfigurationTarget.Global ? undefined : resource!)
.update(section, value, target);
}
async updateEffective(section: string, value: any, resource: Uri | null = null) {
const inspect = await configuration.inspect(section, resource)!;
if (inspect.workspaceFolderValue !== undefined) {
await configuration.update(section, value, ConfigurationTarget.WorkspaceFolder, resource);
}
else if (inspect.workspaceValue !== undefined) {
await configuration.update(section, value, ConfigurationTarget.Workspace);
}
else {
await configuration.update(section, value, ConfigurationTarget.Global);
}
}
}

+ 3
- 3
src/gitService.ts Прегледај датотеку

@ -325,13 +325,13 @@ export class GitService extends Disposable {
}
async findNextCommit(repoPath: string, fileName: string, ref?: string): Promise<GitLogCommit | undefined> {
let log = await this.getLogForFile(repoPath, fileName, { maxCount: 1, ref: ref, reverse: true });
let log = await this.getLogForFile(repoPath, fileName, { maxCount: 1, ref: ref, renames: true, reverse: true });
let commit = log && Iterables.first(log.commits.values());
if (commit) return commit;
const nextFileName = await this.findNextFileName(repoPath, fileName, ref);
if (nextFileName) {
log = await this.getLogForFile(repoPath, nextFileName, { maxCount: 1, ref: ref, reverse: true });
log = await this.getLogForFile(repoPath, nextFileName, { maxCount: 1, ref: ref, renames: true, reverse: true });
commit = log && Iterables.first(log.commits.values());
}
@ -943,7 +943,7 @@ export class GitService extends Disposable {
options = { reverse: false, ...options };
if (options.renames === undefined) {
options.renames = true;
options.renames = Container.config.advanced.fileHistoryFollowsRenames;
}
let key = 'log';

+ 1
- 1
src/quickPicks/commitFileDetails.ts Прегледај датотеку

@ -242,7 +242,7 @@ export class CommitFileDetailsQuickPick {
// If we can't find the commit or the previous commit isn't available (since it isn't trustworthy)
if (c === undefined || c.previousSha === undefined) {
log = await Container.git.getLogForFile(commit.repoPath, uri.fsPath, { maxCount: Container.config.advanced.maxListItems, ref: commit.sha });
log = await Container.git.getLogForFile(commit.repoPath, uri.fsPath, { maxCount: Container.config.advanced.maxListItems, ref: commit.sha, renames: true });
if (log === undefined) return KeyNoopCommand;
c = log && log.commits.get(commit.sha);

+ 1
- 0
src/ui/config.ts Прегледај датотеку

@ -107,6 +107,7 @@ export interface IAdvancedConfig {
};
git: string;
fileHistoryFollowsRenames: boolean;
maxListItems: number;
menus: {

+ 9
- 2
src/views/gitExplorer.ts Прегледај датотеку

@ -45,6 +45,8 @@ export class GitExplorer extends Disposable implements TreeDataProvider
commands.registerCommand('gitlens.gitExplorer.setAutoRefreshToOn', () => this.setAutoRefresh(Container.config.gitExplorer.autoRefresh, true), this);
commands.registerCommand('gitlens.gitExplorer.setAutoRefreshToOff', () => this.setAutoRefresh(Container.config.gitExplorer.autoRefresh, false), this);
commands.registerCommand('gitlens.gitExplorer.setRenameFollowingOn', () => this.setRenameFollowing(true), this);
commands.registerCommand('gitlens.gitExplorer.setRenameFollowingOff', () => this.setRenameFollowing(false), this);
commands.registerCommand('gitlens.gitExplorer.switchToHistoryView', () => this.switchTo(GitExplorerView.History), this);
commands.registerCommand('gitlens.gitExplorer.switchToRepositoryView', () => this.switchTo(GitExplorerView.Repository), this);
@ -75,7 +77,8 @@ export class GitExplorer extends Disposable implements TreeDataProvider
if (!initializing &&
!configuration.changed(e, configuration.name('gitExplorer').value) &&
!configuration.changed(e, configuration.name('explorers').value) &&
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value)) return;
!configuration.changed(e, configuration.name('defaultGravatarsStyle').value) &&
!configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value)) return;
if (initializing || configuration.changed(e, configuration.name('gitExplorer')('enabled').value)) {
setCommandContext(CommandContext.GitExplorer, this.config.enabled);
@ -105,7 +108,7 @@ export class GitExplorer extends Disposable implements TreeDataProvider
}
}
this.reset(view!);
this.reset(view!, configuration.changed(e, configuration.name('advanced')('fileHistoryFollowsRenames').value));
}
private onRepositoriesChanged() {
@ -325,4 +328,8 @@ export class GitExplorer extends Disposable implements TreeDataProvider
this.refresh(RefreshReason.AutoRefreshChanged);
}
}
setRenameFollowing(enabled: boolean) {
configuration.updateEffective(configuration.name('advanced')('fileHistoryFollowsRenames').value, enabled);
}
}

Loading…
Откажи
Сачувај