Browse Source

💄 & minor fixes

Adds @kh0m contribution
main
Eric Amodio 4 years ago
parent
commit
3345f67f7c
4 changed files with 27 additions and 18 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -0
      README.md
  3. +14
    -6
      package.json
  4. +11
    -12
      src/commands/copyCurrentBranch.ts

+ 1
- 0
CHANGELOG.md View File

@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds the _Add Remote_ command to the branch status in the _Branches_, _Commits_, and _Repositories_ views when there are no Git remotes configured
- Adds a new _Browse Repository from Before Here_ (`gitlens.browseRepoBeforeRevision`) and _Browse Repository from Before Here in New Window_ (`gitlens.browseRepoBeforeRevisionInNewWindow`) commands
- Adds _Repository from Before Here_ and _Repository from Before Here in New Window_ to the _Browse_ submenu of commits in the views
- Adds a new _Copy Current Branch Name_ (`gitlens.copyCurrentBranch`) command to copy the current branch name to the clipboard — closes [#1306](https://github.com/eamodio/vscode-gitlens/issues/1306) — thanks to [PR #1307](https://github.com/eamodio/vscode-gitlens/pull/1307) by Ken Hom ([@kh0m](https://github.com/kh0m))
### Changed

+ 1
- 0
README.md View File

@ -1013,6 +1013,7 @@ A big thanks to the people that have contributed to this project:
- Geoffrey ([@g3offrey](https://github.com/g3offrey)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=g3offrey)
- grozan ([@grozan](https://github.com/grozan)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=grozan)
- Guillem ([@guillemglez](https://github.com/guillemglez)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=guillemglez)
- Ken Hom ([@kh0m](https://github.com/kh0m)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=kh0m)
- Yukai Huang ([@Yukaii](https://github.com/Yukaii)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=Yukaii)
- Justin Hutchings ([@jhutchings1](https://github.com/jhutchings1)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=jhutchings1)
- Roy Ivy III ([@rivy](https://github.com/rivy)) — [contributions](https://github.com/eamodio/vscode-gitlens/commits?author=rivy)

+ 14
- 6
package.json View File

@ -141,6 +141,7 @@
"onCommand:gitlens.addAuthors",
"onCommand:gitlens.connectRemoteProvider",
"onCommand:gitlens.disconnectRemoteProvider",
"oncommand:gitlens.copyCurrentBranch",
"onCommand:gitlens.copyMessageToClipboard",
"onCommand:gitlens.copyShaToClipboard",
"onCommand:gitlens.closeUnchangedFiles",
@ -185,7 +186,6 @@
"onCommand:gitlens.fetchRepositories",
"onCommand:gitlens.pullRepositories",
"onCommand:gitlens.pushRepositories",
"oncommand:gitlens.copyCurrentBranch",
"onStartupFinished"
],
"contributes": {
@ -3186,6 +3186,15 @@
"category": "GitLens"
},
{
"command": "gitlens.copyCurrentBranch",
"title": "Copy Current Branch Name",
"category": "GitLens",
"icon": {
"dark": "images/dark/icon-copy.svg",
"light": "images/light/icon-copy.svg"
}
},
{
"command": "gitlens.copyMessageToClipboard",
"title": "Copy Message",
"category": "GitLens",
@ -4694,11 +4703,6 @@
"command": "gitlens.views.tags.setShowAvatarsOff",
"title": "Hide Avatars",
"category": "GitLens"
},
{
"command": "gitlens.copyCurrentBranch",
"title": "Copy Current Branch",
"category": "GitLens"
}
],
"menus": {
@ -5036,6 +5040,10 @@
"when": "config.gitlens.integrations.enabled && gitlens:hasRichRemotes"
},
{
"command": "gitlens.copyCurrentBranch",
"when": "gitlens:enabled"
},
{
"command": "gitlens.copyMessageToClipboard",
"when": "gitlens:activeFileStatus =~ /blameable/"
},

+ 11
- 12
src/commands/copyCurrentBranch.ts View File

@ -1,13 +1,12 @@
'use strict';
import { env , TextEditor , Uri , window } from 'vscode';
import { GitService } from '../git/gitService';
import { env, TextEditor, Uri, window } from 'vscode';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
import { Container } from '../container';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { ActiveEditorCommand, command, Commands, getCommandUri, getRepoPathOrActiveOrPrompt } from './common';
@command()
export class CopyCurrentBranch extends ActiveEditorCommand {
export class CopyCurrentBranchCommand extends ActiveEditorCommand {
constructor() {
super(Commands.CopyCurrentBranch);
}
@ -17,17 +16,17 @@ export class CopyCurrentBranch extends ActiveEditorCommand {
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
const repoPath = await getRepoPathOrActiveOrPrompt(gitUri, editor, 'Copy Current Branch');
const repoPath = await getRepoPathOrActiveOrPrompt(gitUri, editor, 'Copy Current Branch Name');
if (!repoPath) return;
const service = new GitService();
try {
const gitBranch = await service.getBranch(repoPath);
if (gitBranch?.name) await env.clipboard.writeText(gitBranch?.name);
const branch = await Container.git.getBranch(repoPath);
if (branch?.name) {
await env.clipboard.writeText(branch.name);
}
} catch (ex) {
Logger.error(ex, 'CopyCurrentBranch');
void window.showErrorMessage('Unable to copy current branch. See output channel for more details');
Logger.error(ex, 'CopyCurrentBranchCommand');
void window.showErrorMessage('Unable to copy current branch name. See output channel for more details');
}
}
}

Loading…
Cancel
Save