Skip to content

Commit 6a6bd9e

Browse files
committed
vscode git graph with better diff
1 parent d7f43f4 commit 6a6bd9e

16 files changed

Lines changed: 13331 additions & 6 deletions

package-lock.json

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

package.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@
9696
"title": "Open File",
9797
"icon": "$(go-to-file)",
9898
"enablement": "isInDiffEditor && resourceScheme == git-graph && git-graph:codiconsSupported"
99+
},
100+
{
101+
"category": "Git Graph",
102+
"command": "git-graph.viewGitDiff",
103+
"title": "View Git Diff"
104+
},
105+
{
106+
"category": "Git Graph",
107+
"command": "git-graph.viewGitDiffForRepo",
108+
"title": "View Git Diff For Repository"
99109
}
100110
],
101111
"configuration": {
@@ -251,6 +261,10 @@
251261
"type": "boolean",
252262
"title": "View Diff"
253263
},
264+
"viewDiffInFile": {
265+
"type": "boolean",
266+
"title": "View Diff in file"
267+
},
254268
"viewFileAtThisRevision": {
255269
"type": "boolean",
256270
"title": "View File at this Revision"
@@ -1526,9 +1540,12 @@
15261540
"test-and-report-coverage": "jest --verbose --coverage"
15271541
},
15281542
"dependencies": {
1543+
"diff2html": "^3.4.16",
1544+
"hogan.js": "^3.0.2",
15291545
"iconv-lite": "0.5.0"
15301546
},
15311547
"devDependencies": {
1548+
"@types/hogan.js": "^3.0.1",
15321549
"@types/jest": "26.0.19",
15331550
"@types/node": "8.10.62",
15341551
"@types/vscode": "1.38.0",
@@ -1540,4 +1557,4 @@
15401557
"typescript": "4.0.2",
15411558
"uglify-js": "3.10.0"
15421559
}
1543-
}
1560+
}

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
@@ -8,7 +8,7 @@ import { CodeReviewData, CodeReviews, ExtensionState } from './extensionState';
88
import { GitGraphView } from './gitGraphView';
99
import { Logger } from './logger';
1010
import { RepoManager } from './repoManager';
11-
import { GitExecutable, UNABLE_TO_FIND_GIT_MSG, VsCodeVersionRequirement, abbrevCommit, abbrevText, copyToClipboard, doesVersionMeetRequirement, getExtensionVersion, getPathFromUri, getRelativeTimeDiff, getRepoName, getSortedRepositoryPaths, isPathInWorkspace, openFile, resolveToSymbolicPath, showErrorMessage, showInformationMessage } from './utils';
11+
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';
1212
import { Disposable } from './utils/disposable';
1313
import { Event } from './utils/event';
1414

@@ -56,6 +56,8 @@ export class CommandManager extends Disposable {
5656
this.registerCommand('git-graph.resumeWorkspaceCodeReview', () => this.resumeWorkspaceCodeReview());
5757
this.registerCommand('git-graph.version', () => this.version());
5858
this.registerCommand('git-graph.openFile', (arg) => this.openFile(arg));
59+
this.registerCommand('git-graph.viewGitDiff', () => this.viewGitDiff());
60+
this.registerCommand('git-graph.viewGitDiffForRepo', () => this.viewGitDiffForRepo());
5961

6062
this.registerDisposable(
6163
onDidChangeGitExecutable((gitExecutable) => {
@@ -346,6 +348,23 @@ export class CommandManager extends Disposable {
346348
}
347349

348350

351+
private viewGitDiff() {
352+
const uriPath = vscode.window.activeTextEditor?.document.uri.path;
353+
if (uriPath && vscode.workspace.workspaceFolders) {
354+
const repo = vscode.workspace.workspaceFolders[0].uri.path;
355+
const extensionPath = this.context.extensionPath;
356+
viewGitDiffByPath(extensionPath, repo, uriPath);
357+
}
358+
}
359+
360+
private viewGitDiffForRepo() {
361+
if ( vscode.workspace.workspaceFolders) {
362+
const repo = vscode.workspace.workspaceFolders[0].uri.path;
363+
const extensionPath = this.context.extensionPath;
364+
viewGitDiffForRepo(extensionPath, repo);
365+
}
366+
}
367+
349368
/* Helper Methods */
350369

351370
/**

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)