提交 429a2da4 编写于 作者: P Peng Lyu

remove unused code.

上级 2c64d63d
......@@ -3,14 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { GitProcess } from 'dugite';
import * as fs from 'fs';
import * as path from 'path';
import * as tmp from 'tmp';
import * as vscode from 'vscode';
import { GitProcess } from 'dugite';
import { Repository } from '../models/repository';
import { SlimFileChange, GitChangeType, fromStatus } from '../models/file';
export async function writeTmpFile(content: string, ext: string): Promise<string> {
return new Promise<string>((resolve, reject) => {
......@@ -30,32 +25,6 @@ export async function writeTmpFile(content: string, ext: string): Promise<string
});
}
export async function getFile(commitSha1: string, localFilePath: string): Promise<string> {
const rootDir = vscode.workspace.rootPath;
return new Promise<string>((resolve, reject) => {
if (commitSha1 === undefined) {
resolve('fileUnavailable');
return;
}
let ext = path.extname(localFilePath);
tmp.file({ postfix: ext }, async (err: any, tmpFilePath: string) => {
if (err) {
reject(err);
return;
}
try {
let data = await getFileContent(rootDir, commitSha1, localFilePath);
fs.appendFileSync(tmpFilePath, data);
resolve(tmpFilePath);
}
catch (ex) {
console.log(ex);
reject(ex);
}
});
});
}
export async function getFileContent(rootDir: string, commitSha: string, sourceFilePath: string): Promise<string> {
const result = await GitProcess.exec([
'show',
......@@ -71,29 +40,3 @@ export async function getFileContent(rootDir: string, commitSha: string, sourceF
throw error;
}
}
export async function getChangedFiles(repository: Repository, sha: string): Promise<ReadonlyArray<SlimFileChange>> {
const args = ['log', sha, '--name-status', '--format=format:', '-z', '-1'];
const result = await GitProcess.exec(args, repository.path);
const out = result.stdout;
const lines = out.split('\0');
lines.splice(-1, 1);
const files: SlimFileChange[] = [];
for (let i = 0; i < lines.length; i++) {
const statusText = lines[i];
const status = fromStatus(statusText);
let originalPath: string | undefined = undefined;
if (status === GitChangeType.RENAME || status === GitChangeType.COPY) {
originalPath = lines[++i];
}
const path = lines[++i];
files.push(new SlimFileChange(path, originalPath, status, null));
}
return files;
}
\ No newline at end of file
......@@ -16,36 +16,6 @@ export enum GitChangeType {
UNMERGED
}
export function fromStatus(status: string): GitChangeType {
switch (status) {
case 'A': return GitChangeType.ADD;
case 'C': return GitChangeType.COPY;
case 'D': return GitChangeType.DELETE;
case 'M': return GitChangeType.MODIFY;
case 'R': return GitChangeType.RENAME;
case 'T': return GitChangeType.TYPE;
case 'X': return GitChangeType.UNKNOWN;
case 'U': return GitChangeType.UNMERGED;
}
if (status.match(/R[0-9]+/)) { return GitChangeType.RENAME; }
if (status.match(/C[0-9]+/)) { return GitChangeType.COPY; }
return GitChangeType.MODIFY;
}
export class SlimFileChange {
public originalContent: string;
public content: string;
constructor(
public readonly filePath: string,
public readonly originalFilePath: string,
public readonly status: GitChangeType,
public readonly fileName: string
) { }
}
export class RichFileChange {
public blobUrl: string;
constructor(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册