Skip to content

Commit 8b3772c

Browse files
committed
Integrate PR mhutchie#742: Diff2HTML Support and Fix Tests
2 parents 0e02fc2 + 6676762 commit 8b3772c

19 files changed

+633
-16
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* #394 New "Sticky Scroll" option for the Commit Graph.
99
* #473 Display CI/CD Status (e.g. GitHub Actions) in the graph.
1010
* #763 New "Show HEAD" button in the controls bar to scroll to the HEAD commit.
11+
* #742 New "View Diff In File" action on the File Context Menu in the Commit Details View, utilizing Diff2HTML.
1112

1213
### Español
1314
* #602 Nueva acción "Copiar Hash del Commit al Portapapeles".
@@ -17,6 +18,7 @@
1718
* #394 Nueva opción de "Desplazamiento Pegajoso" para el Gráfico de Commits.
1819
* #473 Muestra el estado de CI/CD (por ejemplo, GitHub Actions) en el gráfico.
1920
* #763 Nuevo botón "Mostrar HEAD" en la barra de controles para desplazarse al commit HEAD.
21+
* #742 Nueva acción "Ver Diff en Archivo" en el Menú Contextual de Archivos en la Vista de Detalles del Commit, utilizando Diff2HTML.
2022

2123
## 1.30.0 - 2021-04-05
2224
* #395 Added a "Force Fetch" option onto the "Fetch into Local Branch" Dialog, allowing any local branch (that's not checked out) to be reset to the remote branch. This dialog is accessed via the Remote Branch Context Menu.

package-lock.json

Lines changed: 102 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "git-graph",
33
"displayName": "Git Graph",
4-
"version": "1.30.0",
4+
"version": "1.30.1",
55
"publisher": "mhutchie",
66
"author": {
77
"name": "Michael Hutchison",
@@ -101,6 +101,16 @@
101101
"title": "Open File",
102102
"icon": "$(go-to-file)",
103103
"enablement": "isInDiffEditor && resourceScheme == git-graph && git-graph:codiconsSupported"
104+
},
105+
{
106+
"category": "Git Graph",
107+
"command": "git-graph.viewGitDiff",
108+
"title": "View Git Diff"
109+
},
110+
{
111+
"category": "Git Graph",
112+
"command": "git-graph.viewGitDiffForRepo",
113+
"title": "View Git Diff For Repository"
104114
}
105115
],
106116
"configuration": {
@@ -256,6 +266,10 @@
256266
"type": "boolean",
257267
"title": "View Diff"
258268
},
269+
"viewDiffInFile": {
270+
"type": "boolean",
271+
"title": "View Diff in file"
272+
},
259273
"viewFileAtThisRevision": {
260274
"type": "boolean",
261275
"title": "View File at this Revision"
@@ -1558,9 +1572,12 @@
15581572
"test-and-report-coverage": "jest --verbose --coverage"
15591573
},
15601574
"dependencies": {
1575+
"diff2html": "^3.4.16",
1576+
"hogan.js": "^3.0.2",
15611577
"iconv-lite": "0.5.0"
15621578
},
15631579
"devDependencies": {
1580+
"@types/hogan.js": "^3.0.1",
15641581
"@types/jest": "26.0.19",
15651582
"@types/node": "8.10.62",
15661583
"@types/react": "^17.0.0",
@@ -1574,4 +1591,4 @@
15741591
"typescript": "^4.9.5",
15751592
"uglify-js": "3.10.0"
15761593
}
1577-
}
1594+
}

resources/diff2html-ui.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/diff2html.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/highlight_11.6.0_github.min.css

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/jquery.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/commands.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { CodeReviewData, CodeReviews, ExtensionState } from './extensionState';
99
import { GitGraphView } from './gitGraphView';
1010
import { Logger } from './logger';
1111
import { RepoManager } from './repoManager';
12-
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, VsCodeVersionRequirement, abbrevCommit, abbrevText, copyToClipboard, doesVersionMeetRequirement, getExtensionVersion, getPathFromUri, getRelativeTimeDiff, getRepoName, getSortedRepositoryPaths, isPathInWorkspace, openFile, resolveToSymbolicPath, showErrorMessage, showInformationMessage } from './utils';
12+
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, VsCodeVersionRequirement, abbrevCommit, abbrevText, copyToClipboard, doesVersionMeetRequirement, getExtensionVersion, getPathFromUri, getRelativeTimeDiff, getRepoName, getSortedRepositoryPaths, isPathInWorkspace, openFile, resolveToSymbolicPath, showErrorMessage, showInformationMessage, viewGitDiffByPath, viewGitDiffForRepo} from './utils';
1313
import { Disposable } from './utils/disposable';
1414
import { Event } from './utils/event';
1515

@@ -61,6 +61,8 @@ export class CommandManager extends Disposable {
6161
this.registerCommand('git-graph.resumeWorkspaceCodeReview', () => this.resumeWorkspaceCodeReview());
6262
this.registerCommand('git-graph.version', () => this.version());
6363
this.registerCommand('git-graph.openFile', (arg) => this.openFile(arg));
64+
this.registerCommand('git-graph.viewGitDiff', () => this.viewGitDiff());
65+
this.registerCommand('git-graph.viewGitDiffForRepo', () => this.viewGitDiffForRepo());
6466

6567
this.registerDisposable(
6668
onDidChangeGitExecutable((gitExecutable) => {
@@ -358,6 +360,23 @@ export class CommandManager extends Disposable {
358360
}
359361

360362

363+
private viewGitDiff() {
364+
const uriPath = vscode.window.activeTextEditor?.document.uri.path;
365+
if (uriPath && vscode.workspace.workspaceFolders) {
366+
const repo = vscode.workspace.workspaceFolders[0].uri.path;
367+
const extensionPath = this.context.extensionPath;
368+
viewGitDiffByPath(extensionPath, repo, uriPath);
369+
}
370+
}
371+
372+
private viewGitDiffForRepo() {
373+
if ( vscode.workspace.workspaceFolders) {
374+
const repo = vscode.workspace.workspaceFolders[0].uri.path;
375+
const extensionPath = this.context.extensionPath;
376+
viewGitDiffForRepo(extensionPath, repo);
377+
}
378+
}
379+
361380
/* Helper Methods */
362381

363382
/**

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Config {
8383
const config: ContextMenuActionsVisibility = {
8484
branch: { checkout: true, rename: true, delete: true, merge: true, rebase: true, push: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true },
8585
commit: { addTag: true, createBranch: true, checkout: true, cherrypick: true, revert: true, drop: true, merge: true, rebase: true, reset: true, copyHash: true, copySubject: true },
86-
commitDetailsViewFile: { viewDiff: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true },
86+
commitDetailsViewFile: { viewDiff: true, viewDiffInFile: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true },
8787
remoteBranch: { checkout: true, delete: true, fetch: true, merge: true, pull: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true },
8888
stash: { apply: true, createBranch: true, pop: true, drop: true, copyName: true, copyHash: true },
8989
tag: { viewDetails: true, delete: true, push: true, createArchive: true, copyName: true },

0 commit comments

Comments
 (0)