Sfoglia il codice sorgente

Changes History view to Commits

main
Eric Amodio 4 anni fa
parent
commit
fedf064401
9 ha cambiato i file con 813 aggiunte e 810 eliminazioni
  1. +426
    -423
      package.json
  2. +10
    -10
      src/config.ts
  3. +11
    -11
      src/container.ts
  4. +14
    -14
      src/views/commitsView.ts
  5. +3
    -3
      src/views/nodes/branchNode.ts
  6. +3
    -3
      src/views/nodes/compareBranchNode.ts
  7. +6
    -6
      src/views/viewBase.ts
  8. +14
    -14
      src/views/viewCommands.ts

+ 426
- 423
package.json
File diff soppresso perché troppo grande
Vedi File


+ 10
- 10
src/config.ts Vedi File

@ -431,10 +431,10 @@ export const viewsCommonConfigKeys: (keyof ViewsCommonConfig)[] = [
interface ViewsConfigs {
branches: BranchesViewConfig;
commits: CommitsViewConfig;
compare: CompareViewConfig;
contributors: ContributorsViewConfig;
fileHistory: FileHistoryViewConfig;
history: HistoryViewConfig;
lineHistory: LineHistoryViewConfig;
remotes: RemotesViewConfig;
repositories: RepositoriesViewConfig;
@ -446,10 +446,10 @@ interface ViewsConfigs {
export type ViewsConfigKeys = keyof ViewsConfigs;
export const viewsConfigKeys: ViewsConfigKeys[] = [
'branches',
'commits',
'compare',
'contributors',
'fileHistory',
'history',
'lineHistory',
'remotes',
'repositories',
@ -482,6 +482,14 @@ export interface BranchesViewConfig {
showTrackingBranch: boolean;
}
export interface CommitsViewConfig {
avatars: boolean;
branches: undefined;
files: ViewsFilesConfig;
showBranchComparison: false | ViewShowBranchComparison;
showTrackingBranch: boolean;
}
export interface CompareViewConfig {
avatars: boolean;
enabled: boolean;
@ -500,14 +508,6 @@ export interface FileHistoryViewConfig {
location: ViewLocation;
}
export interface HistoryViewConfig {
avatars: boolean;
branches: undefined;
files: ViewsFilesConfig;
showBranchComparison: false | ViewShowBranchComparison;
showTrackingBranch: boolean;
}
export interface LineHistoryViewConfig {
avatars: boolean;
enabled: boolean;

+ 11
- 11
src/container.ts Vedi File

@ -24,10 +24,10 @@ import { GitTerminalLinkProvider } from './terminal/linkProvider';
import { GitDocumentTracker } from './trackers/gitDocumentTracker';
import { GitLineTracker } from './trackers/gitLineTracker';
import { BranchesView } from './views/branchesView';
import { CommitsView } from './views/commitsView';
import { CompareView } from './views/compareView';
import { ContributorsView } from './views/contributorsView';
import { FileHistoryView } from './views/fileHistoryView';
import { HistoryView } from './views/historyView';
import { LineHistoryView } from './views/lineHistoryView';
import { RemotesView } from './views/remotesView';
import { RepositoriesView } from './views/repositoriesView';
@ -69,8 +69,8 @@ export class Container {
context.subscriptions.push((this._welcomeWebview = new WelcomeWebview()));
context.subscriptions.push((this._branchesView = new BranchesView()));
context.subscriptions.push((this._commitsView = new CommitsView()));
context.subscriptions.push((this._contributorsView = new ContributorsView()));
context.subscriptions.push((this._historyView = new HistoryView()));
context.subscriptions.push((this._remotesView = new RemotesView()));
context.subscriptions.push((this._stashesView = new StashesView()));
context.subscriptions.push((this._tagsView = new TagsView()));
@ -195,6 +195,15 @@ export class Container {
return this._branchesView;
}
private static _commitsView: CommitsView | undefined;
static get commitsView() {
if (this._commitsView === undefined) {
this._context.subscriptions.push((this._commitsView = new CommitsView()));
}
return this._commitsView;
}
private static _compareView: CompareView | undefined;
static get compareView() {
if (this._compareView === undefined) {
@ -263,15 +272,6 @@ export class Container {
}
}
private static _historyView: HistoryView | undefined;
static get historyView() {
if (this._historyView === undefined) {
this._context.subscriptions.push((this._historyView = new HistoryView()));
}
return this._historyView;
}
private static _keyboard: Keyboard;
static get keyboard() {
return this._keyboard;

src/views/historyView.ts → src/views/commitsView.ts Vedi File

@ -8,7 +8,7 @@ import {
TreeItemCollapsibleState,
window,
} from 'vscode';
import { configuration, HistoryViewConfig, ViewFilesLayout } from '../configuration';
import { CommitsViewConfig, configuration, ViewFilesLayout } from '../configuration';
import { Container } from '../container';
import {
GitLogCommit,
@ -37,12 +37,12 @@ import {
import { debug, gate } from '../system';
import { ViewBase } from './viewBase';
export class HistoryRepositoryNode extends SubscribeableViewNode<HistoryView> {
export class CommitsRepositoryNode extends SubscribeableViewNode<CommitsView> {
private children: (BranchNode | CompareBranchNode)[] | undefined;
constructor(
uri: GitUri,
view: HistoryView,
view: CommitsView,
parent: ViewNode,
public readonly repo: Repository,
private readonly root: boolean,
@ -129,10 +129,10 @@ export class HistoryRepositoryNode extends SubscribeableViewNode {
}
}
export class HistoryViewNode extends ViewNode<HistoryView> {
private children: HistoryRepositoryNode[] | undefined;
export class CommitsViewNode extends ViewNode<CommitsView> {
private children: CommitsRepositoryNode[] | undefined;
constructor(view: HistoryView) {
constructor(view: CommitsView) {
super(unknownGitUri, view);
}
@ -149,7 +149,7 @@ export class HistoryViewNode extends ViewNode {
const root = repositories.length === 1;
this.children = repositories.map(
r => new HistoryRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, r, root),
r => new CommitsRepositoryNode(GitUri.fromRepoPath(r.path), this.view, this, r, root),
);
if (root) {
@ -157,10 +157,10 @@ export class HistoryViewNode extends ViewNode {
const branch = await child.repo.getBranch();
if (branch != null) {
this.view.title = `${branch.name} Branch`;
this.view.title = `${branch.name} Commits`;
this.view.titleDescription = branch?.getTrackingStatus();
} else {
this.view.title = 'Current Branch';
this.view.title = 'Commits';
this.view.titleDescription = undefined;
}
@ -170,20 +170,20 @@ export class HistoryViewNode extends ViewNode {
}
getTreeItem(): TreeItem {
const item = new TreeItem('History', TreeItemCollapsibleState.Expanded);
const item = new TreeItem('Commits', TreeItemCollapsibleState.Expanded);
return item;
}
}
export class HistoryView extends ViewBase<HistoryViewNode, HistoryViewConfig> {
protected readonly configKey = 'history';
export class CommitsView extends ViewBase<CommitsViewNode, CommitsViewConfig> {
protected readonly configKey = 'commits';
constructor() {
super('gitlens.views.history', 'History');
super('gitlens.views.commits', 'Commits');
}
getRoot() {
return new HistoryViewNode(this);
return new CommitsViewNode(this);
}
protected registerCommands() {

+ 3
- 3
src/views/nodes/branchNode.ts Vedi File

@ -3,7 +3,7 @@ import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { BranchesView } from '../branchesView';
import { BranchTrackingStatusNode } from './branchTrackingStatusNode';
import { CommitNode } from './commitNode';
import { HistoryView } from '../historyView';
import { CommitsView } from '../commitsView';
import { MessageNode, ShowMoreNode } from './common';
import { ViewBranchesLayout } from '../../configuration';
import { GlyphChars } from '../../constants';
@ -18,7 +18,7 @@ import { debug, gate, Iterables, log, Strings } from '../../system';
import { ContextValues, PageableViewNode, ViewNode, ViewRefNode } from './viewNode';
export class BranchNode
extends ViewRefNode<BranchesView | HistoryView | RemotesView | RepositoriesView, GitBranchReference>
extends ViewRefNode<BranchesView | CommitsView | RemotesView | RepositoriesView, GitBranchReference>
implements PageableViewNode {
static key = ':branch';
static getId(repoPath: string, name: string, root: boolean): string {
@ -34,7 +34,7 @@ export class BranchNode
constructor(
uri: GitUri,
view: BranchesView | HistoryView | RemotesView | RepositoriesView,
view: BranchesView | CommitsView | RemotesView | RepositoriesView,
parent: ViewNode,
public readonly branch: GitBranch,
// Specifies that the node is shown as a root under the repository node

+ 3
- 3
src/views/nodes/compareBranchNode.ts Vedi File

@ -1,11 +1,11 @@
'use strict';
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { CommitsView } from '../commitsView';
import { BranchComparison, BranchComparisons, GlyphChars, WorkspaceState } from '../../constants';
import { ViewShowBranchComparison } from '../../config';
import { Container } from '../../container';
import { GitBranch, GitRevision } from '../../git/git';
import { GitUri } from '../../git/gitUri';
import { HistoryView } from '../historyView';
import { CommandQuickPickItem, ReferencePicker } from '../../quickpicks';
import { RepositoriesView } from '../repositoriesView';
import { RepositoryNode } from './repositoryNode';
@ -14,7 +14,7 @@ import { FilesQueryResults, ResultsFilesNode } from './resultsFilesNode';
import { debug, gate, log, Strings } from '../../system';
import { ContextValues, ViewNode } from './viewNode';
export class CompareBranchNode extends ViewNode<HistoryView | RepositoriesView> {
export class CompareBranchNode extends ViewNode<CommitsView | RepositoriesView> {
static key = ':compare-branch';
static getId(repoPath: string, name: string): string {
return `${RepositoryNode.getId(repoPath)}${this.key}(${name})`;
@ -25,7 +25,7 @@ export class CompareBranchNode extends ViewNode
constructor(
uri: GitUri,
view: HistoryView | RepositoriesView,
view: CommitsView | RepositoriesView,
parent: ViewNode,
public readonly branch: GitBranch,
) {

+ 6
- 6
src/views/viewBase.ts Vedi File

@ -17,15 +17,15 @@ import {
window,
} from 'vscode';
import { BranchesView } from './branchesView';
import { HistoryView } from './historyView';
import { CommitsView } from './commitsView';
import { CompareView } from './compareView';
import {
BranchesViewConfig,
CommitsViewConfig,
CompareViewConfig,
configuration,
ContributorsViewConfig,
FileHistoryViewConfig,
HistoryViewConfig,
LineHistoryViewConfig,
RemotesViewConfig,
RepositoriesViewConfig,
@ -34,8 +34,8 @@ import {
TagsViewConfig,
ViewsCommonConfig,
viewsCommonConfigKeys,
ViewsConfigKeys,
viewsConfigKeys,
ViewsConfigKeys,
} from '../configuration';
import { Container } from '../container';
import { ContributorsView } from './contributorsView';
@ -56,7 +56,7 @@ export type View =
| CompareView
| ContributorsView
| FileHistoryView
| HistoryView
| CommitsView
| LineHistoryView
| RemotesView
| RepositoriesView
@ -67,7 +67,7 @@ export type ViewsWithFiles =
| BranchesView
| CompareView
| ContributorsView
| HistoryView
| CommitsView
| RemotesView
| RepositoriesView
| SearchView
@ -85,7 +85,7 @@ export abstract class ViewBase<
| CompareViewConfig
| ContributorsViewConfig
| FileHistoryViewConfig
| HistoryViewConfig
| CommitsViewConfig
| LineHistoryViewConfig
| RemotesViewConfig
| RepositoriesViewConfig

+ 14
- 14
src/views/viewCommands.ts Vedi File

@ -113,9 +113,9 @@ export class ViewCommands {
this,
);
commands.registerCommand('gitlens.views.contributors.addAuthors', this.contributorsAddAuthors, this);
commands.registerCommand('gitlens.views.contributor.addAuthor', this.contributorsAddAuthors, this);
commands.registerCommand('gitlens.views.contributor.copyToClipboard', this.contributorCopyToClipboard, this);
commands.registerCommand('gitlens.views.addAuthors', this.addAuthors, this);
commands.registerCommand('gitlens.views.addAuthor', this.addAuthors, this);
commands.registerCommand('gitlens.views.copyContributorToClipboard', this.copyContributorToClipboard, this);
commands.registerCommand('gitlens.views.openChanges', this.openChanges, this);
commands.registerCommand('gitlens.views.openChangesWithWorking', this.openChangesWithWorking, this);
@ -189,6 +189,16 @@ export class ViewCommands {
}
@debug()
private addAuthors(node: ContributorNode | ContributorsNode) {
if (!(node instanceof ContributorNode) && !(node instanceof ContributorsNode)) return Promise.resolve();
return GitActions.Contributor.addAuthors(
node.uri.repoPath,
node instanceof ContributorNode ? node.contributor : undefined,
);
}
@debug()
private addRemote(node: RemoteNode) {
if (!(node instanceof RemoteNode)) return Promise.resolve();
@ -227,17 +237,7 @@ export class ViewCommands {
}
@debug()
private contributorsAddAuthors(node: ContributorNode | ContributorsNode) {
if (!(node instanceof ContributorNode) && !(node instanceof ContributorsNode)) return Promise.resolve();
return GitActions.Contributor.addAuthors(
node.uri.repoPath,
node instanceof ContributorNode ? node.contributor : undefined,
);
}
@debug()
private contributorCopyToClipboard(node: ContributorNode) {
private copyContributorToClipboard(node: ContributorNode) {
if (!(node instanceof ContributorNode)) return Promise.resolve();
return GitActions.Contributor.copyToClipboard(node.contributor);

Caricamento…
Annulla
Salva