Sfoglia il codice sorgente

Fixes diff of renamed files in certain cases

main
Eric Amodio 4 anni fa
parent
commit
66304e87a7
6 ha cambiato i file con 31 aggiunte e 9 eliminazioni
  1. +2
    -0
      src/views/nodes/compareBranchNode.ts
  2. +2
    -0
      src/views/nodes/compareResultsNode.ts
  3. +13
    -3
      src/views/nodes/resultsCommitsNode.ts
  4. +6
    -2
      src/views/nodes/resultsFileNode.ts
  5. +5
    -1
      src/views/nodes/resultsFilesNode.ts
  6. +3
    -3
      src/views/nodes/statusFileNode.ts

+ 2
- 0
src/views/nodes/compareBranchNode.ts Vedi File

@ -79,6 +79,7 @@ export class CompareBranchNode extends ViewNode
{
query: this.getCommitsQuery(GitRevision.createRange(behind.ref1, behind.ref2, '..')),
comparison: behind,
direction: 'behind',
files: {
ref1: this.compareWithWorkingTree ? '' : behind.ref1,
ref2: behind.ref2,
@ -101,6 +102,7 @@ export class CompareBranchNode extends ViewNode
GitRevision.createRange(ahead.ref1, this.compareWithWorkingTree ? '' : ahead.ref2, '..'),
),
comparison: ahead,
direction: 'ahead',
files: {
ref1: ahead.ref1,
ref2: this.compareWithWorkingTree ? '' : ahead.ref2,

+ 2
- 0
src/views/nodes/compareResultsNode.ts Vedi File

@ -87,6 +87,7 @@ export class CompareResultsNode extends ViewNode {
{
query: this.getCommitsQuery(GitRevision.createRange(behind.ref1, behind.ref2, '..')),
comparison: behind,
direction: 'behind',
files: {
ref1: behind.ref1,
ref2: behind.ref2,
@ -107,6 +108,7 @@ export class CompareResultsNode extends ViewNode {
{
query: this.getCommitsQuery(GitRevision.createRange(ahead.ref1, ahead.ref2, '..')),
comparison: ahead,
direction: 'ahead',
files: {
ref1: ahead.ref1,
ref2: ahead.ref2,

+ 13
- 3
src/views/nodes/resultsCommitsNode.ts Vedi File

@ -30,6 +30,7 @@ export class ResultsCommitsNode
query: (limit: number | undefined) => Promise<CommitsQueryResults>;
comparison?: { ref1: string; ref2: string };
deferred?: boolean;
direction?: 'ahead' | 'behind';
files?: {
ref1: string;
ref2: string;
@ -73,9 +74,18 @@ export class ResultsCommitsNode
const { files } = this._results;
if (files != null) {
children.push(
new ResultsFilesNode(this.view, this, this.uri.repoPath!, files.ref1, files.ref2, files.query, {
expand: false,
}),
new ResultsFilesNode(
this.view,
this,
this.uri.repoPath!,
files.ref1,
files.ref2,
files.query,
this._results.direction,
{
expand: false,
},
),
);
}

+ 6
- 2
src/views/nodes/resultsFileNode.ts Vedi File

@ -16,6 +16,7 @@ export class ResultsFileNode extends ViewRefFileNode {
public readonly file: GitFile,
public readonly ref1: string,
public readonly ref2: string,
private readonly direction: 'ahead' | 'behind' | undefined,
) {
super(GitUri.fromFile(file, repoPath, ref1 || ref2), view, parent);
}
@ -107,12 +108,15 @@ export class ResultsFileNode extends ViewRefFileNode {
const commandArgs: DiffWithCommandArgs = {
lhs: {
sha: this.ref1,
uri: this.uri,
uri:
(this.file.status === 'R' || this.file.status === 'C') && this.direction === 'behind'
? GitUri.fromFile(this.file, this.uri.repoPath!, this.ref2, true)
: this.uri,
},
rhs: {
sha: this.ref2,
uri:
this.file.status === 'R' || this.file.status === 'C'
(this.file.status === 'R' || this.file.status === 'C') && this.direction !== 'behind'
? GitUri.fromFile(this.file, this.uri.repoPath!, this.ref2, true)
: this.uri,
},

+ 5
- 1
src/views/nodes/resultsFilesNode.ts Vedi File

@ -23,6 +23,7 @@ export class ResultsFilesNode extends ViewNode {
public readonly ref1: string,
public readonly ref2: string,
private readonly _filesQuery: () => Promise<FilesQueryResults>,
private readonly direction: 'ahead' | 'behind' | undefined,
private readonly _options: {
expand?: boolean;
} = {},
@ -41,7 +42,10 @@ export class ResultsFilesNode extends ViewNode {
if (files == null) return [];
let children: FileNode[] = [
...Iterables.map(files, s => new ResultsFileNode(this.view, this, this.repoPath, s, this.ref1, this.ref2)),
...Iterables.map(
files,
s => new ResultsFileNode(this.view, this, this.repoPath, s, this.ref1, this.ref2, this.direction),
),
];
if (this.view.config.files.layout !== ViewFilesLayout.List) {

+ 3
- 3
src/views/nodes/statusFileNode.ts Vedi File

@ -135,7 +135,7 @@ export class StatusFileNode extends ViewNode {
private _description: string | undefined;
get description() {
if (this._description === undefined) {
if (this._description == null) {
this._description = StatusFileFormatter.fromTemplate(
this.view.config.statusFileDescriptionFormat,
{
@ -152,7 +152,7 @@ export class StatusFileNode extends ViewNode {
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
if (this._folderName == null) {
this._folderName = paths.dirname(this.uri.relativePath);
}
return this._folderName;
@ -160,7 +160,7 @@ export class StatusFileNode extends ViewNode {
private _label: string | undefined;
get label() {
if (this._label === undefined) {
if (this._label == null) {
this._label = StatusFileFormatter.fromTemplate(
this.view.config.statusFileFormat,
{

Caricamento…
Annulla
Salva