mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
25
extensions/git/src/uri.ts
Normal file
25
extensions/git/src/uri.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Uri } from 'vscode';
|
||||
|
||||
export function fromGitUri(uri: Uri): { path: string; ref: string; } {
|
||||
return JSON.parse(uri.query);
|
||||
}
|
||||
|
||||
// As a mitigation for extensions like ESLint showing warnings and errors
|
||||
// for git URIs, let's change the file extension of these uris to .git.
|
||||
export function toGitUri(uri: Uri, ref: string): Uri {
|
||||
return uri.with({
|
||||
scheme: 'git',
|
||||
path: `${uri.path}.git`,
|
||||
query: JSON.stringify({
|
||||
path: uri.fsPath,
|
||||
ref
|
||||
})
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user