Skip to content

Commit 261b216

Browse files
committed
Adds tags node to the view
1 parent 334931d commit 261b216

File tree

16 files changed

+211
-37
lines changed

16 files changed

+211
-37
lines changed

CHANGELOG.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,27 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
66

77
## [7.0.0-beta2] - 2017-12-16
88
### Added
9-
- Adds a new `Active Repository` node to `Repository View` of the `GitLens` view -- closes [#224](https://github.com/eamodio/vscode-gitlens/issues/224)
9+
- Adds a new `Active Repository` node to the `Repository View` of the `GitLens` view -- closes [#224](https://github.com/eamodio/vscode-gitlens/issues/224)
1010
- Automatically updates to track the repository of the active editor
1111
- Only visible if there is more than 1 repository within the workspace
12+
13+
- Adds a new `Tags` node to the `Repository View` of the `GitLens` view
14+
- Provides a list of tags
15+
- Expand each tag to easily see its revision (commit) history
16+
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
17+
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
18+
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
19+
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, and `Refresh` commands
20+
- Provides a context menu with a `Refresh` command
21+
1222
- Adds [Gravatar](https://en.gravatar.com/) support to the `GitLens` view
1323
- Adds `gitlens.gitExplorer.gravatars` setting to specify whether or not to show gravatar images instead of commit (or status) icons in the `GitLens` view
1424
- Adds `gitlens.gitExplorer.gravatarsDefault` setting to specify the style of the gravatar default (fallback) images in the `GitLens` view<br />`identicon` - a geometric pattern<br />`mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - faces with differing features and backgrounds
1525
- Adds `gitlens.resultsExplorer.gravatars` setting to specify whether or not to show gravatar images instead of commit (or status) icons in the `GitLens Results` view
1626
- Adds `gitlens.resultsExplorer.gravatarsDefault` setting to specify the style of the gravatar default (fallback) images in the `GitLens Results` view<br />`identicon` - a geometric pattern<br />`mm` - (mystery-man) a simple, cartoon-style silhouetted outline of a person (does not vary by email hash)<br />`monsterid` - a monster with different colors, faces, etc<br />`retro` - 8-bit arcade-style pixelated faces<br />`robohash` - a robot with different colors, faces, etc<br />`wavatar` - faces with differing features and backgrounds
17-
- Adds `Select for Compare` command (`gitlens.explorers.selectForCompare`) to branch and revision (commit) nodes in the `GitLens` view to mark the base revision of a comparision
18-
- Adds `Compare with Selected` command (`gitlens.explorers.compareWithSelected`) to branch and revision (commit) nodes in the `GitLens` view once another branch or revision (commit) node within the same repository has been selected to compare the current selection with the previously selected revision (branch or commit)
19-
- Adds `Apply Changes` option to the commit/stash file quick pick menu -- closes [#232](https://github.com/eamodio/vscode-gitlens/issues/232)
20-
- Adds `Show All Commits` option to the commit search quick pick menu to show all the results, if there are more than the threshold
21-
- Adds `Show in Results` option to the commit search quick pick menu to show the results in the `GitLens Results` view
22-
- Adds `Show in Results` option to the file history quick pick menu to show the history in the `GitLens Results` view
27+
28+
- Adds `Select for Compare` command (`gitlens.explorers.selectForCompare`) to branch, remote branch, tag, and revision (commit) nodes in the `GitLens` view to mark the base reference of a comparision
29+
- Adds `Compare with Selected` command (`gitlens.explorers.compareWithSelected`) to branch, remote branch, tag, and revision (commit) nodes in the `GitLens` view once another reference within the same repository has been selected to compare the current selection with the previously selected reference in the `GitLens Results` view
2330

2431
- Adds an all-new, on-demand `GitLens Results` view to the Explorer activity
2532

@@ -39,6 +46,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
3946

4047
- Provides toolbar commands to `Search Commits`, `Keep Results`, `Refresh`, `Show Files in Automatic View` or `Show Files in List View` or `Show Files in Tree View`, and `Close`
4148

49+
- Adds `Apply Changes` option to the commit/stash file quick pick menu -- closes [#232](https://github.com/eamodio/vscode-gitlens/issues/232)
50+
- Adds `Show All Commits` option to the commit search quick pick menu to show all the results, if there are more than the threshold
51+
- Adds `Show in Results` option to the commit search quick pick menu to show the results in the `GitLens Results` view
52+
- Adds `Show in Results` option to the file history quick pick menu to show the history in the `GitLens Results` view
53+
54+
### Changed
55+
- Improves startup performance a bit
56+
4257
### Fixed
4358
- Fixes [#228](https://github.com/eamodio/vscode-gitlens/issues/228) - Gutter blame spills over heatmap
4459
- Fixes incorrect blame highlighting -- thanks to [PR #231](https://github.com/eamodio/vscode-gitlens/pull/231) by Alexey Vasyukov ([@notmedia](https://github.com/notmedia))!

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ While GitLens is highly customizable and provides many [configuration settings](
160160
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
161161
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
162162
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
163-
- Provides a context menu on each branch with `Open Branch in Remote`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
163+
- Provides a context menu on each branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Rebase Branch to Remote (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
164164
- Provides a context menu with `Open Branches in Remote`, and `Refresh` commands
165165

166166
- `Remotes` node — provides a list of remotes
@@ -170,7 +170,7 @@ While GitLens is highly customizable and provides many [configuration settings](
170170
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
171171
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`,`Show Commit Details`, `Compare with Selected`, `Select for Compare`, and `Refresh` commands
172172
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, `Show File History`, and `Show Commit File Details` commands
173-
- Provides a context menu on each remote branch with `Open Branch in Remote`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
173+
- Provides a context menu on each remote branch with `Open Branch in Remote`, `Compare with Selected`, `Select for Compare`, `Checkout Branch (via Terminal)`, `Create Branch (via Terminal)...`, `Delete Branch (via Terminal)`, `Squash Branch into Commit (via Terminal)`, and `Refresh` commands
174174
- Provides a context menu on each remote with `Open Branches in Remote`, `Open Repository in Remote`, `Remove Remote (via Terminal)`, and `Refresh` commands
175175
- Provides a context menu with a `Refresh` command
176176

@@ -180,6 +180,14 @@ While GitLens is highly customizable and provides many [configuration settings](
180180
- Provides a context menu on each stashed file with `Apply Changes`, `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, and `Show File History` commands
181181
- Provides a context menu with `Stash Changes`, and `Refresh` commands
182182

183+
- `Tags` node — provides a list of tags
184+
- Expand each tag to easily see its revision (commit) history
185+
- Expand each revision (commit) to quickly see the set of files changed, complete with status indicators for adds, changes, renames, and deletes
186+
- Provides a context menu on each revision (commit) with `Open Commit in Remote`, `Open All Changes`, `Open All Changes with Working Tree`, `Open Files`, `Open Revisions`, `Copy Commit ID to Clipboard`, `Copy Commit Message to Clipboard`, `Show Commit Details`, `Compare with Selected`, `Select for Compare`, `Rebase Commit (via Terminal)`, `Reset Commit (via Terminal)`, and `Refresh` commands
187+
- Provides a context menu on each changed file with `Open Changes`, `Open Changes with Working Tree`, `Open File`, `Open Revision`, `Open File in Remote`, `Open Revision in Remote`, `Apply Changes`, and `Show Commit File Details` commands
188+
- Provides a context menu on each tag with `Compare with Selected`, `Select for Compare`, and `Refresh` commands
189+
- Provides a context menu with a `Refresh` command
190+
183191
- `History View` - provides the revision history of the active file
184192

185193
![GitLens History view](https://raw.githubusercontent.com/eamodio/vscode-gitlens/master/images/screenshot-git-custom-view-history.png)

images/dark/icon-tag.svg

Lines changed: 4 additions & 0 deletions
Loading

images/light/icon-tag.svg

Lines changed: 4 additions & 0 deletions
Loading

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2671,6 +2671,16 @@
26712671
"when": "viewItem == gitlens:status-upstream",
26722672
"group": "8_gitlens@1"
26732673
},
2674+
{
2675+
"command": "gitlens.explorers.compareWithSelected",
2676+
"when": "viewItem == gitlens:tag && gitlens:explorers:canCompare",
2677+
"group": "7_gitlens@1"
2678+
},
2679+
{
2680+
"command": "gitlens.explorers.selectForCompare",
2681+
"when": "viewItem == gitlens:tag",
2682+
"group": "7_gitlens@2"
2683+
},
26742684
{
26752685
"command": "gitlens.gitExplorer.refreshNode",
26762686
"when": "view == gitlens.gitExplorer && viewItem != gitlens:commit-file && viewItem != gitlens:stash-file && viewItem != gitlens:status-file",

src/git/git.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export * from './parsers/logParser';
1919
export * from './parsers/remoteParser';
2020
export * from './parsers/stashParser';
2121
export * from './parsers/statusParser';
22+
export * from './parsers/tagParser';
2223
export * from './remotes/provider';
2324

2425
let git: IGit;
@@ -147,15 +148,15 @@ export class Git {
147148
return git;
148149
}
149150

150-
static async getVersionedFile(repoPath: string | undefined, fileName: string, branchOrSha: string) {
151-
const data = await Git.show(repoPath, fileName, branchOrSha, { encoding: 'binary' });
151+
static async getVersionedFile(repoPath: string | undefined, fileName: string, ref: string) {
152+
const data = await Git.show(repoPath, fileName, ref, { encoding: 'binary' });
152153
if (data === undefined) return undefined;
153154

154-
if (Git.isStagedUncommitted(branchOrSha)) {
155-
branchOrSha = '';
155+
if (Git.isStagedUncommitted(ref)) {
156+
ref = '';
156157
}
157158

158-
const suffix = Strings.truncate(Strings.sanitizeForFileSystem(Git.isSha(branchOrSha) ? Git.shortenSha(branchOrSha) : branchOrSha), 50, '');
159+
const suffix = Strings.truncate(Strings.sanitizeForFileSystem(Git.isSha(ref) ? Git.shortenSha(ref) : ref), 50, '');
159160
const ext = path.extname(fileName);
160161
return new Promise<string>((resolve, reject) => {
161162
tmp.file({ prefix: `${path.basename(fileName, ext)}-${suffix}__`, postfix: ext },
@@ -165,7 +166,7 @@ export class Git {
165166
return;
166167
}
167168

168-
Logger.log(`getVersionedFile[${destination}]('${repoPath}', '${fileName}', ${branchOrSha})`);
169+
Logger.log(`getVersionedFile[${destination}]('${repoPath}', '${fileName}', ${ref})`);
169170
fs.appendFile(destination, data, { encoding: 'binary' }, err => {
170171
if (err) {
171172
reject(err);
@@ -330,10 +331,10 @@ export class Git {
330331
return gitCommand({ cwd: repoPath }, ...params);
331332
}
332333

333-
static difftool_dirDiff(repoPath: string, tool: string, sha1: string, sha2?: string) {
334-
const params = [`difftool`, `--dir-diff`, `--tool=${tool}`, sha1];
335-
if (sha2) {
336-
params.push(sha2);
334+
static difftool_dirDiff(repoPath: string, tool: string, ref1: string, ref2?: string) {
335+
const params = [`difftool`, `--dir-diff`, `--tool=${tool}`, ref1];
336+
if (ref2) {
337+
params.push(ref2);
337338
}
338339

339340
return gitCommand({ cwd: repoPath }, ...params);
@@ -503,18 +504,18 @@ export class Git {
503504
}
504505
}
505506

506-
static async show(repoPath: string | undefined, fileName: string, branchOrSha: string, options: { encoding?: string } = {}) {
507+
static async show(repoPath: string | undefined, fileName: string, ref: string, options: { encoding?: string } = {}) {
507508
const [file, root] = Git.splitPath(fileName, repoPath);
508509

509-
if (Git.isStagedUncommitted(branchOrSha)) {
510-
branchOrSha = ':';
510+
if (Git.isStagedUncommitted(ref)) {
511+
ref = ':';
511512
}
512-
if (Git.isUncommitted(branchOrSha)) throw new Error(`sha=${branchOrSha} is uncommitted`);
513+
if (Git.isUncommitted(ref)) throw new Error(`sha=${ref} is uncommitted`);
513514

514515
const opts = { cwd: root, encoding: options.encoding || 'utf8', willHandleErrors: true } as GitCommandOptions;
515-
const args = branchOrSha.endsWith(':')
516-
? `${branchOrSha}./${file}`
517-
: `${branchOrSha}:./${file}`;
516+
const args = ref.endsWith(':')
517+
? `${ref}./${file}`
518+
: `${ref}:./${file}`;
518519

519520
try {
520521
const data = await gitCommand(opts, 'show', args);
@@ -573,4 +574,10 @@ export class Git {
573574
const porcelain = porcelainVersion >= 2 ? `--porcelain=v${porcelainVersion}` : '--porcelain';
574575
return gitCommand({ cwd: root, env: { ...process.env, GIT_OPTIONAL_LOCKS: '0' } }, 'status', porcelain, file);
575576
}
577+
578+
static tag(repoPath: string) {
579+
const params = [`tag`, `-l`];
580+
581+
return gitCommand({ cwd: repoPath }, ...params);
582+
}
576583
}

src/git/models/models.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export * from './remote';
1010
export * from './repository';
1111
export * from './stash';
1212
export * from './stashCommit';
13-
export * from './status';
13+
export * from './status';
14+
export * from './tag';

src/git/models/repository.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { Functions } from '../../system';
33
import { ConfigurationChangeEvent, Disposable, Event, EventEmitter, RelativePattern, Uri, workspace, WorkspaceFolder } from 'vscode';
44
import { configuration, IRemotesConfig } from '../../configuration';
5-
import { GitBranch, GitDiffShortStat, GitRemote, GitStash, GitStatus } from '../git';
5+
import { GitBranch, GitDiffShortStat, GitRemote, GitStash, GitStatus, GitTag } from '../git';
66
import { GitService, GitUri } from '../../gitService';
77
import { RemoteProviderFactory, RemoteProviderMap } from '../remotes/factory';
88
import * as _path from 'path';
@@ -237,11 +237,11 @@ export class Repository extends Disposable {
237237
return this._branch;
238238
}
239239

240-
async getBranches(): Promise<GitBranch[]> {
240+
getBranches(): Promise<GitBranch[]> {
241241
return this.git.getBranches(this.path);
242242
}
243243

244-
async getChangedFilesCount(sha?: string): Promise<GitDiffShortStat | undefined> {
244+
getChangedFilesCount(sha?: string): Promise<GitDiffShortStat | undefined> {
245245
return this.git.getChangedFilesCount(this.path, sha);
246246
}
247247

@@ -258,14 +258,18 @@ export class Repository extends Disposable {
258258
return this._remotes;
259259
}
260260

261-
async getStashList(): Promise<GitStash | undefined> {
261+
getStashList(): Promise<GitStash | undefined> {
262262
return this.git.getStashList(this.path);
263263
}
264264

265-
async getStatus(): Promise<GitStatus | undefined> {
265+
getStatus(): Promise<GitStatus | undefined> {
266266
return this.git.getStatusForRepo(this.path);
267267
}
268268

269+
getTags(): Promise<GitTag[]> {
270+
return this.git.getTags(this.path);
271+
}
272+
269273
async hasRemote(): Promise<boolean> {
270274
const branch = await this.getBranch();
271275
return branch !== undefined && branch.tracking !== undefined;

src/git/models/tag.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
export class GitTag {
4+
5+
constructor(
6+
public readonly repoPath: string,
7+
public readonly name: string
8+
) { }
9+
}

src/git/parsers/tagParser.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
import { Arrays } from '../../system';
3+
import { GitTag } from './../git';
4+
5+
export class GitTagParser {
6+
7+
static parse(data: string, repoPath: string): GitTag[] | undefined {
8+
if (!data) return undefined;
9+
10+
const tags = Arrays.filterMap(data.split('\n'), t => !!t ? new GitTag(repoPath, t) : undefined);
11+
if (!tags.length) return undefined;
12+
13+
return tags;
14+
}
15+
}

0 commit comments

Comments
 (0)