Browse Source

Adds remote merge-base indicator

main
Eric Amodio 6 years ago
parent
commit
5267804919
4 changed files with 18 additions and 4 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      src/constants.ts
  3. +6
    -1
      src/views/branchNode.ts
  4. +10
    -3
      src/views/commitNode.ts

+ 1
- 0
CHANGELOG.md View File

@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased]
### Added
- Adds an indicator to the *GitLens* explorer branch history to mark the synchronization point between the local and remote branch (if available)
- Adds `${agoOrDate}` and `${authorAgoOrDate}` tokens to `gitlens.blame.format`, `gitlens.currentLine.format`, `gitlens.explorers.commitFormat`, `gitlens.explorers.stashFormat`, and `gitlens.statusBar.format` settings which will honor the `gitlens.defaultDateStyle` setting — closes [#312](https://github.com/eamodio/vscode-gitlens/issues/312)
### Fixed

+ 1
- 0
src/constants.ts View File

@ -77,6 +77,7 @@ export enum GlyphChars {
ArrowBack = '\u21a9',
ArrowDown = '\u2193',
ArrowDropRight = '\u2937',
ArrowHeadRight = '\u27A4',
ArrowLeft = '\u2190',
ArrowLeftRight = '\u2194',
ArrowRight = '\u2192',

+ 6
- 1
src/views/branchNode.ts View File

@ -40,7 +40,12 @@ export class BranchNode extends ExplorerRefNode {
const log = await Container.git.getLog(this.uri.repoPath!, { maxCount: this.maxCount, ref: this.branch.name });
if (log === undefined) return [new MessageNode('No commits yet')];
const children: (CommitNode | ShowAllNode)[] = [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.explorer, this.branch))];
let trackingRef: string | undefined = undefined;
if (this.branch.tracking !== undefined) {
trackingRef = await Container.git.getMergeBase(this.uri.repoPath!, this.branch.name, this.branch.tracking);
}
const children: (CommitNode | ShowAllNode)[] = [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.explorer, this.branch, trackingRef))];
if (log.truncated) {
children.push(new ShowAllNode('Show All Commits', this, this.explorer));
}

+ 10
- 3
src/views/commitNode.ts View File

@ -4,6 +4,7 @@ import { Command, TreeItem, TreeItemCollapsibleState } from 'vscode';
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
import { CommitFileNode, CommitFileNodeDisplayAs } from './commitFileNode';
import { ExplorerFilesLayout } from '../configuration';
import { GlyphChars } from '../constants';
import { Container } from '../container';
import { FolderNode, IFileExplorerNode } from './folderNode';
import { Explorer, ExplorerNode, ExplorerRefNode, ResourceType } from './explorerNode';
@ -15,7 +16,8 @@ export class CommitNode extends ExplorerRefNode {
constructor(
public readonly commit: GitLogCommit,
private readonly explorer: Explorer,
public readonly branch?: GitBranch
public readonly branch?: GitBranch,
private readonly trackingRef?: string
) {
super(commit.toGitUri());
}
@ -44,10 +46,15 @@ export class CommitNode extends ExplorerRefNode {
}
getTreeItem(): TreeItem {
const item = new TreeItem(CommitFormatter.fromTemplate(this.explorer.config.commitFormat, this.commit, {
let label = CommitFormatter.fromTemplate(this.explorer.config.commitFormat, this.commit, {
truncateMessageAtNewLine: true,
dataFormat: Container.config.defaultDateFormat
} as ICommitFormatOptions), TreeItemCollapsibleState.Collapsed);
} as ICommitFormatOptions);
if (this.trackingRef === this.commit.sha) {
label = `${GlyphChars.ArrowHeadRight} ${label}`;
}
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
item.contextValue = (this.branch === undefined || this.branch.current)
? ResourceType.CommitOnCurrentBranch

Loading…
Cancel
Save