Quellcode durchsuchen

Fixes #276 - branches w/o upstream failed

main
Eric Amodio vor 6 Jahren
Ursprung
Commit
d762eb798d
2 geänderte Dateien mit 22 neuen und 18 gelöschten Zeilen
  1. +3
    -0
      CHANGELOG.md
  2. +19
    -18
      src/git/git.ts

+ 3
- 0
CHANGELOG.md Datei anzeigen

@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Added
- Adds `gitlens.statusBar.reduceFlicker` setting to specify whether to reduce the status bar "flickering" when changing lines by not first clearing the previous blame information -- closes [#272](https://github.com/eamodio/vscode-gitlens/issues/272)
### Fixed
- Fixes [#276](https://github.com/eamodio/vscode-gitlens/issues/276) - Lookup for branches without upstreams fails
## [8.0.0] - 2018-02-07
### Added
- Adds an all-new GitLens welcome page via the *Welcome* (`gitlens.showWelcomePage`) command — provides a welcome / onboarding experience — closes [#51](https://github.com/eamodio/vscode-gitlens/issues/51)

+ 19
- 18
src/git/git.ts Datei anzeigen

@ -1,5 +1,5 @@
'use strict';
import { Strings } from '../system';
import { Objects, Strings } from '../system';
import { findGitPath, IGit } from './gitLocator';
import { Logger } from '../logger';
import { CommandOptions, runCommand } from './shell';
@ -56,16 +56,17 @@ const stashFormat = [
const defaultStashParams = ['stash', 'list', '--name-status', '-M', `--format=${stashFormat}`];
const GitWarnings = [
/Not a git repository/,
/is outside repository/,
/no such path/,
/does not have any commits/,
/Path \'.*?\' does not exist in/,
/Path \'.*?\' exists on disk, but not in/,
/no upstream configured for branch/,
/ambiguous argument '.*?': unknown revision or path not in the working tree/
];
const GitWarnings = {
notARepository: /Not a git repository/,
outsideRepository: /is outside repository/,
noPath: /no such path/,
noCommits: /does not have any commits/,
notFound: /Path \'.*?\' does not exist in/,
foundButNotInRevision: /Path \'.*?\' exists on disk, but not in/,
headNotABranch: /HEAD does not point to a branch/,
noUpstream: /no upstream configured for branch \'(.*?)\'/,
unknownRevision: /ambiguous argument \'.*?\': unknown revision or path not in the working tree/
};
async function gitCommand(options: CommandOptions & { readonly correlationKey?: string }, ...args: any[]): Promise<string> {
try {
@ -133,7 +134,7 @@ async function gitCommandCore(options: CommandOptions & { readonly correlationKe
function gitCommandDefaultErrorHandler(ex: Error, options: CommandOptions, ...args: any[]): string {
const msg = ex && ex.toString();
if (msg) {
for (const warning of GitWarnings) {
for (const warning of Objects.values(GitWarnings)) {
if (warning.test(msg)) {
Logger.warn('git', ...args, ` cwd='${options.cwd}'`, `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
return '';
@ -526,10 +527,12 @@ export class Git {
}
catch (ex) {
const msg = ex && ex.toString();
if (/HEAD does not point to a branch/.test(msg)) return undefined;
if (/no upstream configured for branch/.test(msg)) return ex.message.split('\n')[0];
if (GitWarnings.headNotABranch.test(msg)) return undefined;
if (/ambiguous argument '.*?': unknown revision or path not in the working tree/.test(msg)) {
const result = GitWarnings.noUpstream.exec(msg);
if (result !== null) return result[1];
if (GitWarnings.unknownRevision.test(msg)) {
try {
const params = ['symbolic-ref', '-q', '--short', 'HEAD'];
const data = await gitCommandCore(opts, ...params);
@ -573,9 +576,7 @@ export class Git {
}
catch (ex) {
const msg = ex && ex.toString();
if (/Path \'.*?\' does not exist in/.test(msg) || /Path \'.*?\' exists on disk, but not in /.test(msg)) {
return undefined;
}
if (GitWarnings.notFound.test(msg) || GitWarnings.foundButNotInRevision.test(msg)) return undefined;
return gitCommandDefaultErrorHandler(ex, opts, args);
}

Laden…
Abbrechen
Speichern