-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from andrei-m/global-config
Add an extension-wide global config setting
- Loading branch information
Showing
10 changed files
with
210 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as vscode from 'vscode'; | ||
import { MaybeUrlPlatform, parseMaybeUrlPlatform } from './git'; | ||
|
||
export function getDefaultUrlPlatform(): MaybeUrlPlatform { | ||
const defaultUrlPlatform = vscode.workspace.getConfiguration('git-open-in-browser').get('default-url-platform'); | ||
if (typeof defaultUrlPlatform === "string") { | ||
return parseMaybeUrlPlatform(defaultUrlPlatform); | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
const out = vscode.window.createOutputChannel("Git Open in Browser"); | ||
|
||
export function log(msg: string) { | ||
out.appendLine(msg); | ||
} | ||
|
||
export function notify(msg: string) { | ||
vscode.window.showInformationMessage(msg); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as assert from 'assert'; | ||
import { UrlParsed, UrlPlatform, resolveUrlPlatform } from '../git'; | ||
|
||
suite('resolveUrlPlatform', () => { | ||
test('git-configured setting is highest priority', () => { | ||
const gitConfigured = UrlPlatform.AzureDevOps; | ||
const url = new UrlParsed('github.com', ''); | ||
const extConfigured = UrlPlatform.Gitlab; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.AzureDevOps); | ||
}); | ||
|
||
test('well-known domain: Github', () => { | ||
const gitConfigured = null; | ||
const url = new UrlParsed('github.com', ''); | ||
const extConfigured = UrlPlatform.Gitlab; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.Github); | ||
}); | ||
|
||
test('well-known domain: Gitlab', () => { | ||
const gitConfigured = null; | ||
const url = new UrlParsed('gitlab.com', ''); | ||
const extConfigured = UrlPlatform.Stash; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.Gitlab); | ||
}); | ||
|
||
test('well-known domain: Azure for Azure DevOps', () => { | ||
const gitConfigured = null; | ||
const url = new UrlParsed('azure.com', ''); | ||
const extConfigured = UrlPlatform.Stash; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.AzureDevOps); | ||
}); | ||
|
||
test('domains are case-insentive', () => { | ||
const gitConfigured = null; | ||
const url = new UrlParsed('AzuRE.com', ''); | ||
const extConfigured = UrlPlatform.Stash; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.AzureDevOps); | ||
}); | ||
|
||
test('fall back to the extension-configured default', () => { | ||
const gitConfigured = null; | ||
const url = new UrlParsed('example.org', ''); | ||
const extConfigured = UrlPlatform.Stash; | ||
|
||
const result = resolveUrlPlatform(gitConfigured, url, extConfigured); | ||
assert.strictEqual(result, UrlPlatform.Stash); | ||
}); | ||
}); |
Oops, something went wrong.