mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 18:48:45 -05:00
Adds support for single files
This commit is contained in:
@@ -25,8 +25,6 @@ Provides Git CodeLens information (most recent commit, # of authors), on-demand
|
|||||||
- Provides a Git **blame history explorer** (peek style ui) to visualize the blame history of a file or block
|
- Provides a Git **blame history explorer** (peek style ui) to visualize the blame history of a file or block
|
||||||
- Provides many configuration settings to allow the **customization** of almost all features
|
- Provides many configuration settings to allow the **customization** of almost all features
|
||||||
|
|
||||||
> NOTE: GitLens only works with opened folders (not single files).
|
|
||||||
|
|
||||||
> Add `"gitlens.insiders": true` to your settings to join the insiders channel and get access to upcoming features.
|
> Add `"gitlens.insiders": true` to your settings to join the insiders channel and get access to upcoming features.
|
||||||
|
|
||||||
## Feature Previews
|
## Feature Previews
|
||||||
|
|||||||
@@ -33,14 +33,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
const gitlens = extensions.getExtension(ExtensionId);
|
const gitlens = extensions.getExtension(ExtensionId);
|
||||||
const gitlensVersion = gitlens.packageJSON.version;
|
const gitlensVersion = gitlens.packageJSON.version;
|
||||||
|
|
||||||
// Workspace not using a folder. No access to git repo.
|
const rootPath = workspace.rootPath && workspace.rootPath.replace(/\\/g, '/');
|
||||||
if (!workspace.rootPath) {
|
|
||||||
Logger.warn(`GitLens(v${gitlensVersion}) inactive: no rootPath`);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rootPath = workspace.rootPath.replace(/\\/g, '/');
|
|
||||||
Logger.log(`GitLens(v${gitlensVersion}) active: ${rootPath}`);
|
Logger.log(`GitLens(v${gitlensVersion}) active: ${rootPath}`);
|
||||||
|
|
||||||
const config = workspace.getConfiguration('').get<IConfig>('gitlens');
|
const config = workspace.getConfiguration('').get<IConfig>('gitlens');
|
||||||
@@ -48,9 +41,8 @@ export async function activate(context: ExtensionContext) {
|
|||||||
|
|
||||||
configureCssCharacters(config.blame);
|
configureCssCharacters(config.blame);
|
||||||
|
|
||||||
let repoPath: string;
|
|
||||||
try {
|
try {
|
||||||
repoPath = await Git.getRepoPath(rootPath, gitPath);
|
await Git.getGitPath(gitPath);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'Extension.activate');
|
Logger.error(ex, 'Extension.activate');
|
||||||
@@ -61,6 +53,8 @@ export async function activate(context: ExtensionContext) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const repoPath = await Git.getRepoPath(rootPath);
|
||||||
|
|
||||||
const gitVersion = Git.gitInfo().version;
|
const gitVersion = Git.gitInfo().version;
|
||||||
Logger.log(`Git version: ${gitVersion}`);
|
Logger.log(`Git version: ${gitVersion}`);
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,19 @@ export class Git {
|
|||||||
return git;
|
return git;
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getRepoPath(cwd: string, gitPath?: string) {
|
static async getGitPath(gitPath?: string) {
|
||||||
git = await findGitPath(gitPath);
|
git = await findGitPath(gitPath);
|
||||||
Logger.log(`Git found: ${git.version} @ ${git.path === 'git' ? 'PATH' : git.path}`);
|
Logger.log(`Git found: ${git.version} @ ${git.path === 'git' ? 'PATH' : git.path}`);
|
||||||
|
return git;
|
||||||
|
}
|
||||||
|
|
||||||
let data = await gitCommand(cwd, 'rev-parse', '--show-toplevel');
|
static async getRepoPath(cwd: string) {
|
||||||
data = data.replace(/\r?\n|\r/g, '').replace(/\\/g, '/');
|
if (!cwd) return '';
|
||||||
return data;
|
|
||||||
|
const data = await gitCommand(cwd, 'rev-parse', '--show-toplevel');
|
||||||
|
if (!data) return '';
|
||||||
|
|
||||||
|
return data.replace(/\r?\n|\r/g, '').replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getVersionedFile(repoPath: string, fileName: string, branchOrSha: string) {
|
static async getVersionedFile(repoPath: string, fileName: string, branchOrSha: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user