Przeglądaj źródła

Fixes #201 checks tracking vs has remotes

main
Eric Amodio 7 lat temu
rodzic
commit
0be0a56577
10 zmienionych plików z 51 dodań i 29 usunięć
  1. +4
    -0
      CHANGELOG.md
  2. +9
    -9
      package.json
  3. +6
    -6
      src/annotations/annotations.ts
  4. +1
    -1
      src/annotations/blameAnnotationProvider.ts
  5. +1
    -1
      src/annotations/recentChangesAnnotationProvider.ts
  6. +1
    -1
      src/constants.ts
  7. +1
    -1
      src/currentLineController.ts
  8. +3
    -5
      src/git/gitContextTracker.ts
  9. +16
    -5
      src/git/models/repository.ts
  10. +9
    -0
      src/gitService.ts

+ 4
- 0
CHANGELOG.md Wyświetl plik

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Fixed
- Fixes [#201](https://github.com/eamodio/vscode-gitlens/issues/201) - "Open in Remote" commands should check for branch upstream tracking
## [6.1.0] - 2017-11-13
### Added
- Adds support for nested repositories and submodules -- closes [#198](https://github.com/eamodio/vscode-gitlens/issues/198)

+ 9
- 9
package.json Wyświetl plik

@ -1496,23 +1496,23 @@
},
{
"command": "gitlens.openBranchesInRemote",
"when": "gitlens:activeHasRemotes"
"when": "gitlens:activeHasRemote"
},
{
"command": "gitlens.openBranchInRemote",
"when": "gitlens:activeHasRemotes"
"when": "gitlens:activeHasRemote"
},
{
"command": "gitlens.openCommitInRemote",
"when": "gitlens:activeIsBlameable && gitlens:activeHasRemotes"
"when": "gitlens:activeIsBlameable && gitlens:activeHasRemote"
},
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:activeIsTracked && gitlens:activeHasRemotes"
"when": "gitlens:activeIsTracked && gitlens:activeHasRemote"
},
{
"command": "gitlens.openRepoInRemote",
"when": "gitlens:activeHasRemotes"
"when": "gitlens:activeHasRemote"
},
{
"command": "gitlens.stashApply",
@ -1638,7 +1638,7 @@
"editor/context": [
{
"command": "gitlens.openFileInRemote",
"when": "editorTextFocus && gitlens:activeHasRemotes && config.gitlens.advanced.menus.editorContext.remote",
"when": "editorTextFocus && gitlens:activeHasRemote && config.gitlens.advanced.menus.editorContext.remote",
"group": "navigation@100"
},
{
@ -1706,12 +1706,12 @@
},
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:enabled && gitlens:activeHasRemotes && config.gitlens.advanced.menus.editorTitle.remote",
"when": "gitlens:enabled && gitlens:activeHasRemote && config.gitlens.advanced.menus.editorTitle.remote",
"group": "1_gitlens"
},
{
"command": "gitlens.openRepoInRemote",
"when": "gitlens:enabled && gitlens:activeHasRemotes && config.gitlens.advanced.menus.editorTitle.remote",
"when": "gitlens:enabled && gitlens:activeHasRemote && config.gitlens.advanced.menus.editorTitle.remote",
"group": "1_gitlens"
},
{
@ -1743,7 +1743,7 @@
"editor/title/context": [
{
"command": "gitlens.openFileInRemote",
"when": "gitlens:enabled && gitlens:hasRemotes && config.gitlens.advanced.menus.editorTitleContext.remote",
"when": "gitlens:enabled && gitlens:activeHasRemote && config.gitlens.advanced.menus.editorTitleContext.remote",
"group": "1_gitlens"
},
{

+ 6
- 6
src/annotations/annotations.ts Wyświetl plik

@ -48,7 +48,7 @@ export class Annotations {
return '#793738';
}
private static getHoverCommandBar(commit: GitCommit, hasRemotes: boolean, annotationType?: FileAnnotationType) {
private static getHoverCommandBar(commit: GitCommit, hasRemote: boolean, annotationType?: FileAnnotationType) {
let commandBar = `[\`${GlyphChars.DoubleArrowLeft}\`](${DiffWithCommand.getMarkdownCommandArgs(commit)} "Open Changes") `;
if (commit.previousSha !== undefined) {
@ -62,7 +62,7 @@ export class Annotations {
commandBar += `[\`${GlyphChars.SquareWithTopShadow}\`](${OpenFileRevisionCommand.getMarkdownCommandArgs(uri, annotationType || FileAnnotationType.Gutter, line)} "Blame Previous Revision") `;
}
if (hasRemotes) {
if (hasRemote) {
commandBar += `[\`${GlyphChars.ArrowUpRight}\`](${OpenCommitInRemoteCommand.getMarkdownCommandArgs(commit.sha)} "Open in Remote") `;
}
@ -71,7 +71,7 @@ export class Annotations {
return commandBar;
}
static getHoverMessage(commit: GitCommit, dateFormat: string | null, hasRemotes: boolean, annotationType?: FileAnnotationType): MarkdownString {
static getHoverMessage(commit: GitCommit, dateFormat: string | null, hasRemote: boolean, annotationType?: FileAnnotationType): MarkdownString {
if (dateFormat === null) {
dateFormat = 'MMMM Do, YYYY h:MMa';
}
@ -80,7 +80,7 @@ export class Annotations {
let commandBar = '';
let showCommitDetailsCommand = '';
if (!commit.isUncommitted) {
commandBar = `\n\n${this.getHoverCommandBar(commit, hasRemotes, annotationType)}`;
commandBar = `\n\n${this.getHoverCommandBar(commit, hasRemote, annotationType)}`;
showCommitDetailsCommand = `[\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.sha)} "Show Commit Details")`;
message = commit.message
@ -129,8 +129,8 @@ export class Annotations {
} as DecorationOptions;
}
static detailsHover(commit: GitCommit, dateFormat: string | null, hasRemotes: boolean, annotationType?: FileAnnotationType): DecorationOptions {
const message = this.getHoverMessage(commit, dateFormat, hasRemotes, annotationType);
static detailsHover(commit: GitCommit, dateFormat: string | null, hasRemote: boolean, annotationType?: FileAnnotationType): DecorationOptions {
const message = this.getHoverMessage(commit, dateFormat, hasRemote, annotationType);
return {
hoverMessage: message
} as DecorationOptions;

+ 1
- 1
src/annotations/blameAnnotationProvider.ts Wyświetl plik

@ -103,7 +103,7 @@ export abstract class BlameAnnotationProviderBase extends AnnotationProviderBase
}
}
const message = Annotations.getHoverMessage(logCommit || commit, this._config.defaultDateFormat, await this.git.hasRemotes(commit.repoPath), this._config.blame.file.annotationType);
const message = Annotations.getHoverMessage(logCommit || commit, this._config.defaultDateFormat, await this.git.hasRemote(commit.repoPath), this._config.blame.file.annotationType);
return new Hover(message, document.validateRange(new Range(position.line, 0, position.line, endOfLineIndex)));
}

+ 1
- 1
src/annotations/recentChangesAnnotationProvider.ts Wyświetl plik

@ -48,7 +48,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
if (cfg.hover.details) {
this._decorations.push({
hoverMessage: Annotations.getHoverMessage(commit, dateFormat, await this.git.hasRemotes(commit.repoPath), this._config.blame.file.annotationType),
hoverMessage: Annotations.getHoverMessage(commit, dateFormat, await this.git.hasRemote(commit.repoPath), this._config.blame.file.annotationType),
range: range
} as DecorationOptions);
}

+ 1
- 1
src/constants.ts Wyświetl plik

@ -35,7 +35,7 @@ export enum CommandContext {
GitExplorerView = 'gitlens:gitExplorer:view',
HasRemotes = 'gitlens:hasRemotes',
HasRepository = 'gitlens:hasRepository',
ActiveHasRemotes = 'gitlens:activeHasRemotes',
ActiveHasRemote = 'gitlens:activeHasRemote',
ActiveIsBlameable = 'gitlens:activeIsBlameable',
ActiveFileIsTracked = 'gitlens:activeIsTracked',
Key = 'gitlens:key'

+ 1
- 1
src/currentLineController.ts Wyświetl plik

@ -427,7 +427,7 @@ export class CurrentLineController extends Disposable {
}
}
const message = Annotations.getHoverMessage(logCommit || commit, this._config.defaultDateFormat, await this.git.hasRemotes(commit.repoPath), this._config.blame.file.annotationType);
const message = Annotations.getHoverMessage(logCommit || commit, this._config.defaultDateFormat, await this.git.hasRemote(commit.repoPath), this._config.blame.file.annotationType);
return new Hover(message, range);
}

+ 3
- 5
src/git/gitContextTracker.ts Wyświetl plik

@ -191,13 +191,11 @@ export class GitContextTracker extends Disposable {
private async updateRemotes() {
let hasRemotes = false;
if (this._context.repo !== undefined) {
hasRemotes = await this._context.repo.hasRemotes();
setCommandContext(CommandContext.ActiveHasRemotes, hasRemotes);
}
else {
setCommandContext(CommandContext.ActiveHasRemotes, false);
hasRemotes = await this._context.repo.hasRemote();
}
setCommandContext(CommandContext.ActiveHasRemote, hasRemotes);
if (!hasRemotes) {
const repositories = await this.git.getRepositories();
for (const repo of repositories) {

+ 16
- 5
src/git/models/repository.ts Wyświetl plik

@ -65,6 +65,7 @@ export class Repository extends Disposable {
readonly normalizedPath: string;
readonly storage: Map<string, any> = new Map();
private _branch: Promise<GitBranch | undefined> | undefined;
private readonly _disposable: Disposable;
private _fireChangeDebounced: ((e: RepositoryChangeEvent) => void) | undefined = undefined;
private _fireFileSystemChangeDebounced: ((e: RepositoryFileSystemChangeEvent) => void) | undefined = undefined;
@ -72,7 +73,7 @@ export class Repository extends Disposable {
private _fsWatcherDisposable: Disposable | undefined;
private _pendingChanges: { repo?: RepositoryChangeEvent, fs?: RepositoryFileSystemChangeEvent } = { };
private _providerMap: RemoteProviderMap | undefined;
private _remotes: GitRemote[] | undefined;
private _remotes: Promise<GitRemote[]> | undefined;
private _suspended: boolean;
constructor(
@ -148,6 +149,8 @@ export class Repository extends Disposable {
return;
}
this._branch = undefined;
if (uri !== undefined && uri.path.endsWith('refs/remotes')) {
this._remotes = undefined;
this.fireChange(RepositoryChange.Remotes);
@ -227,8 +230,11 @@ export class Repository extends Disposable {
return this.folder === workspace.getWorkspaceFolder(uri);
}
async getBranch(): Promise<GitBranch | undefined> {
return this.git.getBranch(this.path);
getBranch(): Promise<GitBranch | undefined> {
if (this._branch === undefined) {
this._branch = this.git.getBranch(this.path);
}
return this._branch;
}
async getBranches(): Promise<GitBranch[]> {
@ -239,14 +245,14 @@ export class Repository extends Disposable {
return this.git.getChangedFilesCount(this.path, sha);
}
async getRemotes(): Promise<GitRemote[]> {
getRemotes(): Promise<GitRemote[]> {
if (this._remotes === undefined) {
if (this._providerMap === undefined) {
const remotesCfg = configuration.get<IRemotesConfig[] | null | undefined>(configuration.name('remotes').value, this.folder.uri);
this._providerMap = RemoteProviderFactory.createMap(remotesCfg);
}
this._remotes = await this.git.getRemotesCore(this.path, this._providerMap);
this._remotes = this.git.getRemotesCore(this.path, this._providerMap);
}
return this._remotes;
@ -260,6 +266,11 @@ export class Repository extends Disposable {
return this.git.getStatusForRepo(this.path);
}
async hasRemote(): Promise<boolean> {
const branch = await this.getBranch();
return branch !== undefined && branch.tracking !== undefined;
}
async hasRemotes(): Promise<boolean> {
const remotes = await this.getRemotes();
return remotes !== undefined && remotes.length > 0;

+ 9
- 0
src/gitService.ts Wyświetl plik

@ -992,6 +992,15 @@ export class GitService extends Disposable {
}
}
async hasRemote(repoPath: string | undefined): Promise<boolean> {
if (repoPath === undefined) return false;
const repository = await this.getRepository(repoPath);
if (repository === undefined) return false;
return repository.hasRemote();
}
async hasRemotes(repoPath: string | undefined): Promise<boolean> {
if (repoPath === undefined) return false;

Ładowanie…
Anuluj
Zapisz