mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-15 09:35:42 -05:00
Refactors commit quick pick commands
Splits showQuickCommitDetails into showQuickCommitDetails and showQuickCommitFileDetails Adds closeUnchangedFiles command Adds openChangedFiles command Adds diffDirectory command Adds contextual description to the `go back` commands Fixes #44 by adding a warning message about Git version requirements Fixes intermittent errors when adding active line annotations Fixes intermittent errors when opening multiple files via quick picks Updates dependencies Preps v2.11.0
This commit is contained in:
@@ -91,8 +91,17 @@ export default class Git {
|
||||
return gitCommand(root, ...params, `--`, file);
|
||||
}
|
||||
|
||||
static diffDir(repoPath: string, sha1: string, sha2?: string) {
|
||||
const params = [`difftool`, `--dir-diff`, sha1];
|
||||
if (sha2) {
|
||||
params.push(sha2);
|
||||
}
|
||||
|
||||
return gitCommand(repoPath, ...params);
|
||||
}
|
||||
|
||||
static diffStatus(repoPath: string, sha1?: string, sha2?: string) {
|
||||
const params = [`diff`, `--name- status`, `-M`];
|
||||
const params = [`diff`, `--name-status`, `-M`];
|
||||
if (sha1) {
|
||||
params.push(sha1);
|
||||
}
|
||||
@@ -103,6 +112,43 @@ export default class Git {
|
||||
return gitCommand(repoPath, ...params);
|
||||
}
|
||||
|
||||
static async getVersionedFile(fileName: string, repoPath: string, sha: string) {
|
||||
const data = await Git.getVersionedFileText(fileName, repoPath, sha);
|
||||
|
||||
const ext = path.extname(fileName);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${sha}__`, postfix: ext },
|
||||
(err, destination, fd, cleanupCallback) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.log(`getVersionedFile(${fileName}, ${repoPath}, ${sha}); destination=${destination}`);
|
||||
fs.appendFile(destination, data, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(destination);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static getVersionedFileText(fileName: string, repoPath: string, sha: string) {
|
||||
const [file, root] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
sha = sha.replace('^', '');
|
||||
|
||||
if (Git.isUncommitted(sha)) return Promise.reject(new Error(`sha=${sha} is uncommitted`));
|
||||
return gitCommand(root, 'show', `${sha}:./${file}`);
|
||||
}
|
||||
|
||||
static gitInfo(): IGit {
|
||||
return git;
|
||||
}
|
||||
|
||||
static log(fileName: string, sha?: string, repoPath?: string, maxCount?: number, reverse: boolean = false) {
|
||||
const [file, root]: [string, string] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
|
||||
@@ -150,39 +196,6 @@ export default class Git {
|
||||
return gitCommand(repoPath, ...params);
|
||||
}
|
||||
|
||||
static async getVersionedFile(fileName: string, repoPath: string, sha: string) {
|
||||
const data = await Git.getVersionedFileText(fileName, repoPath, sha);
|
||||
|
||||
const ext = path.extname(fileName);
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${sha}__`, postfix: ext },
|
||||
(err, destination, fd, cleanupCallback) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.log(`getVersionedFile(${fileName}, ${repoPath}, ${sha}); destination=${destination}`);
|
||||
fs.appendFile(destination, data, err => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(destination);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
static getVersionedFileText(fileName: string, repoPath: string, sha: string) {
|
||||
const [file, root] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
sha = sha.replace('^', '');
|
||||
|
||||
if (Git.isUncommitted(sha)) return Promise.reject(new Error(`sha=${sha} is uncommitted`));
|
||||
return gitCommand(root, 'show', `${sha}:./${file}`);
|
||||
}
|
||||
|
||||
static statusFile(fileName: string, repoPath: string): Promise<string> {
|
||||
const [file, root]: [string, string] = Git.splitPath(Git.normalizePath(fileName), repoPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user