Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A better diff viewer - Diff2HTML support #742

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12,811 changes: 12,811 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "git-graph",
"displayName": "Git Graph",
"version": "1.30.0",
"version": "1.30.1",
"publisher": "mhutchie",
"author": {
"name": "Michael Hutchison",
Expand Down Expand Up @@ -96,6 +96,16 @@
"title": "Open File",
"icon": "$(go-to-file)",
"enablement": "isInDiffEditor && resourceScheme == git-graph && git-graph:codiconsSupported"
},
{
"category": "Git Graph",
"command": "git-graph.viewGitDiff",
"title": "View Git Diff"
},
{
"category": "Git Graph",
"command": "git-graph.viewGitDiffForRepo",
"title": "View Git Diff For Repository"
}
],
"configuration": {
Expand Down Expand Up @@ -251,6 +261,10 @@
"type": "boolean",
"title": "View Diff"
},
"viewDiffInFile": {
"type": "boolean",
"title": "View Diff in file"
},
"viewFileAtThisRevision": {
"type": "boolean",
"title": "View File at this Revision"
Expand Down Expand Up @@ -1526,9 +1540,12 @@
"test-and-report-coverage": "jest --verbose --coverage"
},
"dependencies": {
"diff2html": "^3.4.16",
"hogan.js": "^3.0.2",
"iconv-lite": "0.5.0"
},
"devDependencies": {
"@types/hogan.js": "^3.0.1",
"@types/jest": "26.0.19",
"@types/node": "8.10.62",
"@types/vscode": "1.38.0",
Expand All @@ -1540,4 +1557,4 @@
"typescript": "4.0.2",
"uglify-js": "3.10.0"
}
}
}
1 change: 1 addition & 0 deletions resources/diff2html-ui.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/diff2html.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions resources/highlight_11.6.0_github.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions resources/jquery.min.js

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CodeReviewData, CodeReviews, ExtensionState } from './extensionState';
import { GitGraphView } from './gitGraphView';
import { Logger } from './logger';
import { RepoManager } from './repoManager';
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, VsCodeVersionRequirement, abbrevCommit, abbrevText, copyToClipboard, doesVersionMeetRequirement, getExtensionVersion, getPathFromUri, getRelativeTimeDiff, getRepoName, getSortedRepositoryPaths, isPathInWorkspace, openFile, resolveToSymbolicPath, showErrorMessage, showInformationMessage } from './utils';
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';
import { Disposable } from './utils/disposable';
import { Event } from './utils/event';

Expand Down Expand Up @@ -56,6 +56,8 @@ export class CommandManager extends Disposable {
this.registerCommand('git-graph.resumeWorkspaceCodeReview', () => this.resumeWorkspaceCodeReview());
this.registerCommand('git-graph.version', () => this.version());
this.registerCommand('git-graph.openFile', (arg) => this.openFile(arg));
this.registerCommand('git-graph.viewGitDiff', () => this.viewGitDiff());
this.registerCommand('git-graph.viewGitDiffForRepo', () => this.viewGitDiffForRepo());

this.registerDisposable(
onDidChangeGitExecutable((gitExecutable) => {
Expand Down Expand Up @@ -346,6 +348,23 @@ export class CommandManager extends Disposable {
}


private viewGitDiff() {
const uriPath = vscode.window.activeTextEditor?.document.uri.path;
if (uriPath && vscode.workspace.workspaceFolders) {
const repo = vscode.workspace.workspaceFolders[0].uri.path;
const extensionPath = this.context.extensionPath;
viewGitDiffByPath(extensionPath, repo, uriPath);
}
}

private viewGitDiffForRepo() {
if ( vscode.workspace.workspaceFolders) {
const repo = vscode.workspace.workspaceFolders[0].uri.path;
const extensionPath = this.context.extensionPath;
viewGitDiffForRepo(extensionPath, repo);
}
}

/* Helper Methods */

/**
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Config {
const config: ContextMenuActionsVisibility = {
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 },
commit: { addTag: true, createBranch: true, checkout: true, cherrypick: true, revert: true, drop: true, merge: true, rebase: true, reset: true, copyHash: true, copySubject: true },
commitDetailsViewFile: { viewDiff: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true },
commitDetailsViewFile: { viewDiff: true, viewDiffInFile: true, viewFileAtThisRevision: true, viewDiffWithWorkingFile: true, openFile: true, markAsReviewed: true, markAsNotReviewed: true, resetFileToThisRevision: true, copyAbsoluteFilePath: true, copyRelativeFilePath: true },
remoteBranch: { checkout: true, delete: true, fetch: true, merge: true, pull: true, viewIssue: true, createPullRequest: true, createArchive: true, selectInBranchesDropdown: true, unselectInBranchesDropdown: true, copyName: true },
stash: { apply: true, createBranch: true, pop: true, drop: true, copyName: true, copyHash: true },
tag: { viewDetails: true, delete: true, push: true, createArchive: true, copyName: true },
Expand Down
Loading