Skip to content

Commit 770ca47

Browse files
author
ole
authored
recovered FsUri and copy fsPath to path (#479)
* recovered FsUri and copy fsPath to path * Updated CHANGELOG.md and version
1 parent a4f940c commit 770ca47

File tree

5 files changed

+31
-11
lines changed

5 files changed

+31
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## Version 0.6.1
2+
- Fixed [#478](https://github.com/DonJayamanne/gitHistoryVSCode/issues/478)
3+
14
## Version 0.6.0
25
- Replaced express with postMessage [#469](https://github.com/DonJayamanne/gitHistoryVSCode/pull/469) [#451](https://github.com/DonJayamanne/gitHistoryVSCode/issues/451)
36
- Updated package dependencies and removed gulp [#471](https://github.com/DonJayamanne/gitHistoryVSCode/pull/471)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "githistory",
33
"displayName": "Git History",
44
"description": "View git log, file history, compare branches or commits",
5-
"version": "0.6.0",
5+
"version": "0.6.1",
66
"publisher": "donjayamanne",
77
"author": {
88
"name": "Don Jayamanne",

src/adapter/parsers/fileStat/parser.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { inject, injectable } from 'inversify';
22
import * as path from 'path';
33
import { Uri } from 'vscode';
44
import { IServiceContainer } from '../../../ioc/types';
5-
import { CommittedFile, Status } from '../../../types';
5+
import { CommittedFile, Status, FsUri } from '../../../types';
66
import { IFileStatParser, IFileStatStatusParser } from '../types';
77

88
@injectable()
@@ -137,18 +137,26 @@ export class FileStatParser implements IFileStatParser {
137137
const currentAndOriginalFile = FileStatParser.getNewAndOldFileNameFromNumStatLine(line, status)!;
138138
const oldRelativePath = currentAndOriginalFile ? currentAndOriginalFile.original : undefined;
139139
const relativePath = currentAndOriginalFile.current;
140-
const oldUri = oldRelativePath ? Uri.file(path.join(gitRootPath, oldRelativePath)) : undefined;
140+
const oldUri = oldRelativePath
141+
? (Uri.file(path.join(gitRootPath, oldRelativePath)) as FsUri)
142+
: undefined;
141143

142144
const fileInfo: CommittedFile = {
143145
additions,
144146
deletions,
145147
status,
146148
relativePath,
147149
oldRelativePath,
148-
uri: Uri.file(path.join(gitRootPath, relativePath)),
150+
uri: Uri.file(path.join(gitRootPath, relativePath)) as FsUri,
149151
oldUri,
150152
};
151153

154+
fileInfo.uri.path = fileInfo.uri.fsPath;
155+
156+
if (fileInfo.oldUri) {
157+
fileInfo.oldUri.path = fileInfo.oldUri.fsPath;
158+
}
159+
152160
return fileInfo;
153161
})
154162
.filter(commitFile => commitFile !== undefined)

src/adapter/repository/git.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Uri } from 'vscode';
66
import { IWorkspaceService } from '../../application/types/workspace';
77
import { cache } from '../../common/cache';
88
import { IServiceContainer } from '../../ioc/types';
9-
import { ActionedUser, Branch, CommittedFile, Hash, IGitService, LogEntries, LogEntry, Ref } from '../../types';
9+
import { ActionedUser, Branch, CommittedFile, Hash, IGitService, LogEntries, LogEntry, Ref, FsUri } from '../../types';
1010
import { IGitCommandExecutor } from '../exec';
1111
import { IFileStatParser, ILogParser } from '../parsers/types';
1212
import { ITEM_ENTRY_SEPARATOR, LOG_ENTRY_SEPARATOR, LOG_FORMAT_ARGS } from './constants';
@@ -251,7 +251,7 @@ export class Git implements IGitService {
251251
}
252252

253253
@cache('IGitService')
254-
public async getCommitFile(hash: string, file: Uri | string): Promise<Uri> {
254+
public async getCommitFile(hash: string, file: FsUri | string): Promise<Uri> {
255255
//const gitRootPath = await this.getGitRoot();
256256
const filePath = typeof file === 'string' ? file : file.path.toString();
257257

@@ -299,7 +299,7 @@ export class Git implements IGitService {
299299
}
300300

301301
@cache('IGitService')
302-
public async getPreviousCommitHashForFile(hash: string, file: Uri): Promise<Hash> {
302+
public async getPreviousCommitHashForFile(hash: string, file: FsUri): Promise<Hash> {
303303
const gitRootPath = await this.getGitRoot();
304304
const relativeFilePath = path.relative(gitRootPath, file.path);
305305
const args = this.gitArgsService.getPreviousCommitHashForFileArgs(hash, relativeFilePath);

src/types.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ export enum BranchSelection {
1111
Detached = 3,
1212
}
1313

14+
export type FsUri = {
15+
scheme: string;
16+
authority: string;
17+
path: string;
18+
query: string;
19+
fragment: string;
20+
fsPath: string;
21+
};
22+
1423
export enum RefType {
1524
Head,
1625
RemoteHead,
@@ -35,8 +44,8 @@ export type Branch = {
3544
};
3645

3746
export type CommittedFile = {
38-
uri: Uri;
39-
oldUri?: Uri;
47+
uri: FsUri;
48+
oldUri?: FsUri;
4049
oldRelativePath?: string;
4150
relativePath: string;
4251
status: Status;
@@ -138,10 +147,10 @@ export interface IGitService {
138147
lineNumber?: number,
139148
author?: string,
140149
): Promise<LogEntries>;
141-
getPreviousCommitHashForFile(hash: string, file: Uri): Promise<Hash>;
150+
getPreviousCommitHashForFile(hash: string, file: FsUri): Promise<Hash>;
142151
getCommit(hash: string): Promise<LogEntry | undefined>;
143152
revertCommit(hash: string): Promise<void>;
144-
getCommitFile(hash: string, file: Uri | string): Promise<Uri>;
153+
getCommitFile(hash: string, file: FsUri | string): Promise<Uri>;
145154
getDifferences(hash1: string, hash2: string): Promise<CommittedFile[]>;
146155
cherryPick(hash: string): Promise<void>;
147156
reset(hash: string, hard?: boolean): Promise<void>;

0 commit comments

Comments
 (0)