diff --git a/CHANGELOG.md b/CHANGELOG.md index f651229..d5c510d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/constants.ts b/src/constants.ts index 5f21d03..43cbf20 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -77,6 +77,7 @@ export enum GlyphChars { ArrowBack = '\u21a9', ArrowDown = '\u2193', ArrowDropRight = '\u2937', + ArrowHeadRight = '\u27A4', ArrowLeft = '\u2190', ArrowLeftRight = '\u2194', ArrowRight = '\u2192', diff --git a/src/views/branchNode.ts b/src/views/branchNode.ts index 30c0cde..8ef5e60 100644 --- a/src/views/branchNode.ts +++ b/src/views/branchNode.ts @@ -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)); } diff --git a/src/views/commitNode.ts b/src/views/commitNode.ts index 2513ea5..abb9860 100644 --- a/src/views/commitNode.ts +++ b/src/views/commitNode.ts @@ -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