From d3ec7022bc9a994aafc0dfca50bfd6269754a2fe Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 15 Nov 2020 22:05:28 -0500 Subject: [PATCH] Fixes #1150 - issues with no remotes --- CHANGELOG.md | 6 ++++++ src/git/models/remote.ts | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e38636..c55bd0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ 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 [#1150](https://github.com/eamodio/vscode-gitlens/issues/1150) - Cannot read property 'provider' of undefined + ## [11.0.0] - 2020-11-14 ### Added diff --git a/src/git/models/remote.ts b/src/git/models/remote.ts index 99ffaa0..f6a0df8 100644 --- a/src/git/models/remote.ts +++ b/src/git/models/remote.ts @@ -12,6 +12,8 @@ export class GitRemote< TProvider extends RemoteProvider | undefined = RemoteProvider | RemoteProviderWithApi | undefined > { static getHighlanderProviders(remotes: GitRemote[]) { + if (remotes.length === 0) return undefined; + const remote = remotes.length === 1 ? remotes[0] : remotes.find(r => r.default); if (remote != null) return [remote.provider]; @@ -22,6 +24,8 @@ export class GitRemote< } static getHighlanderProviderName(remotes: GitRemote[]) { + if (remotes.length === 0) return undefined; + const remote = remotes.length === 1 ? remotes[0] : remotes.find(r => r.default); if (remote != null) return remote.provider.name;