mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-12 11:08:34 -05:00
Compare commits
25 Commits
v5.0.0-alp
...
v5.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9464f7e79f | ||
|
|
77ae37c54c | ||
|
|
e20ec552b7 | ||
|
|
f911447c5e | ||
|
|
38c44c808d | ||
|
|
655afb358e | ||
|
|
21e0963600 | ||
|
|
62580da702 | ||
|
|
6b97c107eb | ||
|
|
92b57580b8 | ||
|
|
e400f27c84 | ||
|
|
4221e06ae3 | ||
|
|
a2dc65c044 | ||
|
|
4102bdd471 | ||
|
|
d420d82ab2 | ||
|
|
260874fa1d | ||
|
|
9d83fbcacb | ||
|
|
a50f04c569 | ||
|
|
df0599a832 | ||
|
|
f05d236e79 | ||
|
|
1b7610857a | ||
|
|
04d2c00ebf | ||
|
|
ece34dba32 | ||
|
|
68fcbf713d | ||
|
|
e192c547b1 |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
|
|
||||||
## [5.0.0-alpha.2] - 2017-09-03
|
## [5.0.0-beta.2] - 2017-09-12
|
||||||
### Added
|
### Added
|
||||||
- Adds an all-new `GitLens` custom view to the Explorer activity
|
- Adds an all-new `GitLens` custom view to the Explorer activity
|
||||||
|
|
||||||
@@ -57,6 +57,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|||||||
- Quickly switch between views using the `Switch to Repository View` or `Switch to History View` commands
|
- Quickly switch between views using the `Switch to Repository View` or `Switch to History View` commands
|
||||||
- Provides toolbar commands to `Search Commits`, `Switch to Repository View` or `Switch to History View`, and `Refresh`
|
- Provides toolbar commands to `Search Commits`, `Switch to Repository View` or `Switch to History View`, and `Refresh`
|
||||||
|
|
||||||
|
- Adds command-links to the `details` hover annotation
|
||||||
|
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
|
- Adds command-links to the `changes` hover annotation
|
||||||
|
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
|
||||||
|
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
|
- Adds support for custom remote services - see [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
|
||||||
|
- Adds support for the Bitbucket Server (previously called Stash) remote service - see [#120](https://github.com/eamodio/vscode-gitlens/issues/120)
|
||||||
|
- Adds `Compare File Revisions` command (`gitlens.diffWith`) - compares the specified file revisions
|
||||||
- Adds `Open Branches in Remote` command (`gitlens.openBranchesInRemote`) - opens the branches in the supported remote service
|
- Adds `Open Branches in Remote` command (`gitlens.openBranchesInRemote`) - opens the branches in the supported remote service
|
||||||
- Adds `Stash Changes` command (`gitlens.stashSave`) to the source control group context menu -- can now stash a group of files
|
- Adds `Stash Changes` command (`gitlens.stashSave`) to the source control group context menu -- can now stash a group of files
|
||||||
- Adds `Stash Changes` command (`gitlens.stashSave`) to the source control resource context menu -- can now stash individual files (works with multi-select too!)
|
- Adds `Stash Changes` command (`gitlens.stashSave`) to the source control resource context menu -- can now stash individual files (works with multi-select too!)
|
||||||
@@ -85,7 +93,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|||||||
- Removes the seeding of the commit search command from the clipboard
|
- Removes the seeding of the commit search command from the clipboard
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fixes an issue where double hover annotations could be shown on blank lines
|
||||||
- Fixes an issue where remote branches couldn't be opened properly in their remote service
|
- Fixes an issue where remote branches couldn't be opened properly in their remote service
|
||||||
|
- Fixes [#130](https://github.com/eamodio/vscode-gitlens/issues/130) - First-run "Thank you for choosing GitLens! [...]" info message shown on every start up
|
||||||
|
- Fixes [#120](https://github.com/eamodio/vscode-gitlens/issues/120) - Feature Request: "Open in Remote" support for custom repositories
|
||||||
|
- Fixes an issue where sometimes diffs (via branch name) wouldn't open properly
|
||||||
|
- Fixes an issue where remotes are queried more than once on startup
|
||||||
|
|
||||||
## [4.4.3] - 2017-08-30
|
## [4.4.3] - 2017-08-30
|
||||||
## Fixed
|
## Fixed
|
||||||
@@ -157,7 +170,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
|
|||||||
|
|
||||||
## [4.2.0] - 2017-06-27
|
## [4.2.0] - 2017-06-27
|
||||||
## Added
|
## Added
|
||||||
- Adds `Compare File with Revision...` command (`gitlens.diffWithRevision`) - compare the active file with the selected revision of the same file
|
- Adds `Compare File with Revision...` command (`gitlens.diffWithRevision`) - compares the active file with the selected revision of the same file
|
||||||
- Adds `Open Changed Files` command (`gitlens.openChangedFiles`) to the source control group context menu
|
- Adds `Open Changed Files` command (`gitlens.openChangedFiles`) to the source control group context menu
|
||||||
- Adds `Close Unchanged Files` command (`gitlens.closeUnchangedFiles`) to the source control group context menu
|
- Adds `Close Unchanged Files` command (`gitlens.closeUnchangedFiles`) to the source control group context menu
|
||||||
- Adds `Open File in Remote` command (`gitlens.openFileInRemote`) to the source control resource context menu
|
- Adds `Open File in Remote` command (`gitlens.openFileInRemote`) to the source control resource context menu
|
||||||
|
|||||||
14
README.md
14
README.md
@@ -21,7 +21,10 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||

|

|
||||||
- Contains the author, date, and message of the line's most recent commit, by [default](#line-blame-annotation-settings)
|
- Contains the author, date, and message of the line's most recent commit, by [default](#line-blame-annotation-settings)
|
||||||
- Adds a `details` hover annotation to the current line annotation, which provides more commit details ([optional](#line-blame-annotation-settings), on by default)
|
- Adds a `details` hover annotation to the current line annotation, which provides more commit details ([optional](#line-blame-annotation-settings), on by default)
|
||||||
|
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
- Adds a `changes` (diff) hover annotation to the current line annotation, which provides **instant** access to the line's previous version ([optional](#line-blame-annotation-settings), on by default)
|
- Adds a `changes` (diff) hover annotation to the current line annotation, which provides **instant** access to the line's previous version ([optional](#line-blame-annotation-settings), on by default)
|
||||||
|
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
|
||||||
|
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@@ -31,6 +34,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||
- Choose between `gutter` (default) and `hover` [annotation styles](#file-blame-annotation-settings)
|
- Choose between `gutter` (default) and `hover` [annotation styles](#file-blame-annotation-settings)
|
||||||
- Contains the commit message and date, by [default](#file-blame-annotation-settings)
|
- Contains the commit message and date, by [default](#file-blame-annotation-settings)
|
||||||
- Adds a `details` hover annotation to the line's annotation, which provides more commit details ([optional](#file-blame-annotation-settings), on by default)
|
- Adds a `details` hover annotation to the line's annotation, which provides more commit details ([optional](#file-blame-annotation-settings), on by default)
|
||||||
|
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
- Adds a `heatmap` (age) indicator to the gutter annotations (on right edge by [default](#file-blame-annotation-settings)), which provides an easy, at-a-glance way to tell the age of a line ([optional](#file-blame-annotation-settings), on by default)
|
- Adds a `heatmap` (age) indicator to the gutter annotations (on right edge by [default](#file-blame-annotation-settings)), which provides an easy, at-a-glance way to tell the age of a line ([optional](#file-blame-annotation-settings), on by default)
|
||||||
- Indicator ranges from bright yellow (newer) to dark brown (older)
|
- Indicator ranges from bright yellow (newer) to dark brown (older)
|
||||||
- Press `Escape` to quickly toggle the annotations off
|
- Press `Escape` to quickly toggle the annotations off
|
||||||
@@ -61,7 +65,10 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||
- Adds on-demand, [customizable](#file-recent-changes-annotation-settings) and [themeable](#theme-settings), **recent changes annotations** of the whole file
|
- Adds on-demand, [customizable](#file-recent-changes-annotation-settings) and [themeable](#theme-settings), **recent changes annotations** of the whole file
|
||||||
- Highlights all of lines changed in the most recent commit
|
- Highlights all of lines changed in the most recent commit
|
||||||
- Adds a `details` hover annotation to each line, which provides more commit details ([optional](#file-blame-annotation-settings), on by default)
|
- Adds a `details` hover annotation to each line, which provides more commit details ([optional](#file-blame-annotation-settings), on by default)
|
||||||
|
- Clicking the commit id will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
- Adds a `changes` (diff) hover annotation to each line, which provides **instant** access to the line's previous version ([optional](#file-recent-changes-annotation-settings), on by default)
|
- Adds a `changes` (diff) hover annotation to each line, which provides **instant** access to the line's previous version ([optional](#file-recent-changes-annotation-settings), on by default)
|
||||||
|
- Clicking on `Changes` will run the `Compare File Revisions` command (`gitlens.diffWith`)
|
||||||
|
- Clicking the current and previous commit ids will run the `Show Commit Details` command (`gitlens.showQuickCommitDetails`)
|
||||||
- Press `Escape` to quickly toggle the annotations off
|
- Press `Escape` to quickly toggle the annotations off
|
||||||
|
|
||||||
- Adds `Toggle Recent File Changes Annotations` command (`gitlens.toggleFileRecentChanges`) to toggle the recent changes annotations on and off
|
- Adds `Toggle Recent File Changes Annotations` command (`gitlens.toggleFileRecentChanges`) to toggle the recent changes annotations on and off
|
||||||
@@ -165,6 +172,7 @@ GitLens provides an unobtrusive blame annotation at the end of the current line,
|
|||||||
- Adds a `Search Commits` command (`gitlens.showCommitSearch`) with a shortcut of `alt+/` to search for commits by message, author, file(s), or commit id
|
- Adds a `Search Commits` command (`gitlens.showCommitSearch`) with a shortcut of `alt+/` to search for commits by message, author, file(s), or commit id
|
||||||
|
|
||||||
- Adds commands to open files, commits, branches, and the repository in the supported remote services, currently **BitBucket, GitHub, GitLab, and Visual Studio Team Services** — only available if a Git upstream service is configured in the repository
|
- Adds commands to open files, commits, branches, and the repository in the supported remote services, currently **BitBucket, GitHub, GitLab, and Visual Studio Team Services** — only available if a Git upstream service is configured in the repository
|
||||||
|
- Also supports [custom](#custom-remote-settings) remote services, such as **BitBucket, Bitbucket Server (previously called Stash), GitHub, GitLab**
|
||||||
- `Open Branches in Remote` command (`gitlens.openBranchesInRemote`) — opens the branches in the supported remote service
|
- `Open Branches in Remote` command (`gitlens.openBranchesInRemote`) — opens the branches in the supported remote service
|
||||||
- `Open Branch in Remote` command (`gitlens.openBranchInRemote`) — opens the current branch commits in the supported remote service
|
- `Open Branch in Remote` command (`gitlens.openBranchInRemote`) — opens the current branch commits in the supported remote service
|
||||||
- `Open Commit in Remote` command (`gitlens.openCommitInRemote`) — opens the commit revision of the active line in the supported remote service
|
- `Open Commit in Remote` command (`gitlens.openCommitInRemote`) — opens the commit revision of the active line in the supported remote service
|
||||||
@@ -343,6 +351,12 @@ GitLens is highly customizable and provides many configuration settings to allow
|
|||||||
|`gitlens.gitExplorer.stashFormat`|Specifies the format of stashed changes in the `GitLens` custom view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|
|`gitlens.gitExplorer.stashFormat`|Specifies the format of stashed changes in the `GitLens` custom view<br />Available tokens<br /> ${id} - commit id<br /> ${author} - commit author<br /> ${message} - commit message<br /> ${ago} - relative commit date (e.g. 1 day ago)<br /> ${date} - formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br /> ${authorAgo} - commit author, relative commit date<br />See https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting for advanced formatting
|
||||||
|`gitlens.gitExplorer.stashFileFormat`|Specifies the format of a stashed file in the `GitLens` custom view<br />Available tokens<br /> ${file} - file name<br /> ${filePath} - file name and path<br /> ${path} - file path
|
|`gitlens.gitExplorer.stashFileFormat`|Specifies the format of a stashed file in the `GitLens` custom view<br />Available tokens<br /> ${file} - file name<br /> ${filePath} - file name and path<br /> ${path} - file path
|
||||||
|
|
||||||
|
### Custom Remotes Settings
|
||||||
|
|
||||||
|
|Name | Description
|
||||||
|
|-----|------------
|
||||||
|
|`gitlens.remotes`|Specifies the custom remote services (code-hosting)"
|
||||||
|
|
||||||
### Status Bar Settings
|
### Status Bar Settings
|
||||||
|
|
||||||
|Name | Description
|
|Name | Description
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="22px">
|
<svg width="16" height="22" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path fill="#C5C5C5" d="m14.687501,11.955358l-1.079554,-6.821251c-0.076429,-0.458572 -0.477679,-0.821607 -0.955357,-0.821607l-9.30518,0c-0.477679,0 -0.878929,0.363036 -0.955357,0.821607l-1.079554,6.821251l0,4.776787c0,0.525447 0.429911,0.955357 0.955357,0.955357l11.464288,0c0.525447,0 0.955357,-0.429911 0.955357,-0.955357l0,-4.776787l0,0zm-3.133572,0.525447l-0.420357,0.850268c-0.162411,0.324821 -0.496786,0.535 -0.869375,0.535l-4.547501,0c-0.363036,0 -0.687857,-0.210179 -0.850268,-0.525447l-0.420357,-0.869375c-0.162411,-0.315268 -0.496786,-0.525447 -0.850268,-0.525447l-1.327947,0l0.955357,-6.687501l9.553573,0l0.955357,6.687501l-1.318393,0c-0.372589,0 -0.697411,0.210179 -0.869375,0.525447l0.009554,0.009554z" />
|
<path fill="#C5C5C5" d="m14.687501,11.955358l-1.079554,-6.821251c-0.076429,-0.458572 -0.477679,-0.821607 -0.955357,-0.821607l-9.30518,0c-0.477679,0 -0.878929,0.363036 -0.955357,0.821607l-1.079554,6.821251l0,4.776787c0,0.525447 0.429911,0.955357 0.955357,0.955357l11.464288,0c0.525447,0 0.955357,-0.429911 0.955357,-0.955357l0,-4.776787l0,0zm-3.133572,0.525447l-0.420357,0.850268c-0.162411,0.324821 -0.496786,0.535 -0.869375,0.535l-4.547501,0c-0.363036,0 -0.687857,-0.210179 -0.850268,-0.525447l-0.420357,-0.869375c-0.162411,-0.315268 -0.496786,-0.525447 -0.850268,-0.525447l-1.327947,0l0.955357,-6.687501l9.553573,0l0.955357,6.687501l-1.318393,0c-0.372589,0 -0.697411,0.210179 -0.869375,0.525447l0.009554,0.009554z" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 846 B |
4
images/dark/icon-sync.svg
Normal file
4
images/dark/icon-sync.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg width="16" height="22" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill="#C5C5C5" d="m12.24,10.4c0.19,1.28 -0.2,2.62 -1.2,3.6c-1.47,1.45 -3.74,1.63 -5.41,0.54l1.17,-1.14l-4.3,-0.6l0.6,4.2l1.31,-1.26c2.36,1.74 5.7,1.57 7.84,-0.54c1.24,-1.23 1.81,-2.85 1.74,-4.46l-1.75,-0.34l0,0zm-7.28,-2.4c1.47,-1.45 3.74,-1.63 5.41,-0.54l-1.17,1.14l4.3,0.6l-0.6,-4.2l-1.31,1.26c-2.36,-1.74 -5.7,-1.57 -7.85,0.54c-1.24,1.23 -1.8,2.85 -1.73,4.46l1.75,0.35c-0.19,-1.28 0.2,-2.63 1.2,-3.61l0,0z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 546 B |
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="22px">
|
<svg width="16" height="22" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path fill="#424242" d="m14.687501,11.955358l-1.079554,-6.821251c-0.076429,-0.458572 -0.477679,-0.821607 -0.955357,-0.821607l-9.30518,0c-0.477679,0 -0.878929,0.363036 -0.955357,0.821607l-1.079554,6.821251l0,4.776787c0,0.525447 0.429911,0.955357 0.955357,0.955357l11.464288,0c0.525447,0 0.955357,-0.429911 0.955357,-0.955357l0,-4.776787l0,0zm-3.133572,0.525447l-0.420357,0.850268c-0.162411,0.324821 -0.496786,0.535 -0.869375,0.535l-4.547501,0c-0.363036,0 -0.687857,-0.210179 -0.850268,-0.525447l-0.420357,-0.869375c-0.162411,-0.315268 -0.496786,-0.525447 -0.850268,-0.525447l-1.327947,0l0.955357,-6.687501l9.553573,0l0.955357,6.687501l-1.318393,0c-0.372589,0 -0.697411,0.210179 -0.869375,0.525447l0.009554,0.009554z" />
|
<path fill="#424242" d="m14.687501,11.955358l-1.079554,-6.821251c-0.076429,-0.458572 -0.477679,-0.821607 -0.955357,-0.821607l-9.30518,0c-0.477679,0 -0.878929,0.363036 -0.955357,0.821607l-1.079554,6.821251l0,4.776787c0,0.525447 0.429911,0.955357 0.955357,0.955357l11.464288,0c0.525447,0 0.955357,-0.429911 0.955357,-0.955357l0,-4.776787l0,0zm-3.133572,0.525447l-0.420357,0.850268c-0.162411,0.324821 -0.496786,0.535 -0.869375,0.535l-4.547501,0c-0.363036,0 -0.687857,-0.210179 -0.850268,-0.525447l-0.420357,-0.869375c-0.162411,-0.315268 -0.496786,-0.525447 -0.850268,-0.525447l-1.327947,0l0.955357,-6.687501l9.553573,0l0.955357,6.687501l-1.318393,0c-0.372589,0 -0.697411,0.210179 -0.869375,0.525447l0.009554,0.009554z" />
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 846 B |
4
images/light/icon-sync.svg
Normal file
4
images/light/icon-sync.svg
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg width="16" height="22" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path fill="#424242" d="m12.24,10.4c0.19,1.28 -0.2,2.62 -1.2,3.6c-1.47,1.45 -3.74,1.63 -5.41,0.54l1.17,-1.14l-4.3,-0.6l0.6,4.2l1.31,-1.26c2.36,1.74 5.7,1.57 7.84,-0.54c1.24,-1.23 1.81,-2.85 1.74,-4.46l-1.75,-0.34l0,0zm-7.28,-2.4c1.47,-1.45 3.74,-1.63 5.41,-0.54l-1.17,1.14l4.3,0.6l-0.6,-4.2l-1.31,1.26c-2.36,-1.74 -5.7,-1.57 -7.85,0.54c-1.24,1.23 -1.8,2.85 -1.73,4.46l1.75,0.35c-0.19,-1.28 0.2,-2.63 1.2,-3.61l0,0z" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 546 B |
65
package-lock.json
generated
65
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitlens",
|
"name": "gitlens",
|
||||||
"version": "5.0.0-alpha.2",
|
"version": "5.0.0-beta.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -16,19 +16,19 @@
|
|||||||
"integrity": "sha1-qjuL2ivlErGuCgV7lC6GnDcKVWk=",
|
"integrity": "sha1-qjuL2ivlErGuCgV7lC6GnDcKVWk=",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/node": "8.0.26"
|
"@types/node": "8.0.28"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/mocha": {
|
"@types/mocha": {
|
||||||
"version": "2.2.42",
|
"version": "2.2.43",
|
||||||
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.42.tgz",
|
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.43.tgz",
|
||||||
"integrity": "sha512-b6gVDoxEbAQGwbV7gSzeFw/hy3/eEAokztktdzl4bHvGgb9K5zW4mVQDlVYch2w31m8t/J7L2iqhQvz3r5edCQ==",
|
"integrity": "sha512-xNlAmH+lRJdUMXClMTI9Y0pRqIojdxfm7DHsIxoB2iTzu3fnPmSMEN8SsSx0cdwV36d02PWCWaDUoZPDSln+xw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "8.0.26",
|
"version": "8.0.28",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.26.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.28.tgz",
|
||||||
"integrity": "sha512-wbKN0MB4XsjdnSE04HiCzLoBDirGCM6zXrqavSj44nZnPFYpnrTF64E9O6Xmf0ca/IuKK/BHUcXwMiwk92gW6Q==",
|
"integrity": "sha512-HupkFXEv3O3KSzcr3Ylfajg0kaerBg1DyaZzRBBQfrU3NN1mTBRE7sCveqHwXLS5Yrjvww8qFzkzYQQakG9FuQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/tmp": {
|
"@types/tmp": {
|
||||||
@@ -348,7 +348,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/copy-paste/-/copy-paste-1.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/copy-paste/-/copy-paste-1.3.0.tgz",
|
||||||
"integrity": "sha1-p+bEocKP3t8rCB5yuX3y75X0ce0=",
|
"integrity": "sha1-p+bEocKP3t8rCB5yuX3y75X0ce0=",
|
||||||
"requires": {
|
"requires": {
|
||||||
"iconv-lite": "0.4.18",
|
"iconv-lite": "0.4.19",
|
||||||
"sync-exec": "0.6.2"
|
"sync-exec": "0.6.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1248,6 +1248,12 @@
|
|||||||
"sntp": "1.0.9"
|
"sntp": "1.0.9"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"he": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
|
||||||
|
"integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"hoek": {
|
"hoek": {
|
||||||
"version": "2.16.3",
|
"version": "2.16.3",
|
||||||
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
"resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz",
|
||||||
@@ -1266,9 +1272,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"iconv-lite": {
|
"iconv-lite": {
|
||||||
"version": "0.4.18",
|
"version": "0.4.19",
|
||||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.18.tgz",
|
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
|
||||||
"integrity": "sha512-sr1ZQph3UwHTR0XftSbK85OvBbxe/abLGzEnPENCQwmHf7sck8Oyu4ob3LgBxWWxRoM+QszeUyl7jbqapu2TqA=="
|
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
|
||||||
},
|
},
|
||||||
"ignore": {
|
"ignore": {
|
||||||
"version": "3.3.5",
|
"version": "3.3.5",
|
||||||
@@ -1788,9 +1794,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"mocha": {
|
"mocha": {
|
||||||
"version": "3.5.0",
|
"version": "3.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.2.tgz",
|
||||||
"integrity": "sha512-pIU2PJjrPYvYRqVpjXzj76qltO9uBYI7woYAMoxbSefsa+vqAfptjoeevd6bUgwD0mPIO+hv9f7ltvsNreL2PA==",
|
"integrity": "sha512-iH5zl7afRZl1GvD0pnrRlazgc9Z/o34pXWmTFi8xNIMFKXgNL1SoBTDDb9sJfbV/sJV/j8X+0gvwY1QS1He7Nw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"browser-stdout": "1.3.0",
|
"browser-stdout": "1.3.0",
|
||||||
@@ -1800,6 +1806,7 @@
|
|||||||
"escape-string-regexp": "1.0.5",
|
"escape-string-regexp": "1.0.5",
|
||||||
"glob": "7.1.1",
|
"glob": "7.1.1",
|
||||||
"growl": "1.9.2",
|
"growl": "1.9.2",
|
||||||
|
"he": "1.1.1",
|
||||||
"json3": "3.3.2",
|
"json3": "3.3.2",
|
||||||
"lodash.create": "3.1.1",
|
"lodash.create": "3.1.1",
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
@@ -2234,9 +2241,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"source-map-support": {
|
"source-map-support": {
|
||||||
"version": "0.4.16",
|
"version": "0.4.18",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.16.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz",
|
||||||
"integrity": "sha512-A6vlydY7H/ljr4L2UOhDSajQdZQ6dMD7cLH0pzwcmwLyc9u8PNI4WGtnfDDzX7uzGL6c/T+ORL97Zlh+S4iOrg==",
|
"integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"source-map": "0.5.7"
|
"source-map": "0.5.7"
|
||||||
@@ -2327,15 +2334,6 @@
|
|||||||
"integrity": "sha1-l+mNj6TRBdYqJpHR3AfoINuN/E8=",
|
"integrity": "sha1-l+mNj6TRBdYqJpHR3AfoINuN/E8=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"string_decoder": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"safe-buffer": "5.1.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "2.1.1",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
|
||||||
@@ -2345,6 +2343,15 @@
|
|||||||
"strip-ansi": "4.0.0"
|
"strip-ansi": "4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"string_decoder": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"safe-buffer": "5.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"stringstream": {
|
"stringstream": {
|
||||||
"version": "0.0.5",
|
"version": "0.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz",
|
||||||
@@ -2707,10 +2714,10 @@
|
|||||||
"gulp-symdest": "1.1.0",
|
"gulp-symdest": "1.1.0",
|
||||||
"gulp-untar": "0.0.6",
|
"gulp-untar": "0.0.6",
|
||||||
"gulp-vinyl-zip": "1.4.0",
|
"gulp-vinyl-zip": "1.4.0",
|
||||||
"mocha": "3.5.0",
|
"mocha": "3.5.2",
|
||||||
"request": "2.81.0",
|
"request": "2.81.0",
|
||||||
"semver": "5.4.1",
|
"semver": "5.4.1",
|
||||||
"source-map-support": "0.4.16",
|
"source-map-support": "0.4.18",
|
||||||
"url-parse": "1.1.9",
|
"url-parse": "1.1.9",
|
||||||
"vinyl-source-stream": "1.1.0"
|
"vinyl-source-stream": "1.1.0"
|
||||||
}
|
}
|
||||||
|
|||||||
54
package.json
54
package.json
@@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "gitlens",
|
"name": "gitlens",
|
||||||
"version": "5.0.0-alpha.2",
|
"version": "5.0.0-beta.2",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Eric Amodio",
|
"name": "Eric Amodio",
|
||||||
"email": "eamodio@gmail.com"
|
"email": "eamodio@gmail.com"
|
||||||
},
|
},
|
||||||
"publisher": "eamodio",
|
"publisher": "eamodio",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.15.0"
|
"vscode": "^1.16.0"
|
||||||
},
|
},
|
||||||
"license": "SEE LICENSE IN LICENSE",
|
"license": "SEE LICENSE IN LICENSE",
|
||||||
"displayName": "Git Lens \u2014 git blame annotations, code lens, and more",
|
"displayName": "Git Lens \u2014 git blame annotations, code lens, and more",
|
||||||
@@ -447,6 +447,35 @@
|
|||||||
],
|
],
|
||||||
"description": "Specifies the starting view (mode) of the `GitLens` custom view\n `history` - shows the commit history of the active file\n `repository` - shows a repository explorer"
|
"description": "Specifies the starting view (mode) of the `GitLens` custom view\n `history` - shows the commit history of the active file\n `repository` - shows a repository explorer"
|
||||||
},
|
},
|
||||||
|
"gitlens.remotes": {
|
||||||
|
"type": "array",
|
||||||
|
"default": null,
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"domain"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"Bitbucket",
|
||||||
|
"BitbucketServer",
|
||||||
|
"GitHub",
|
||||||
|
"GitLab"
|
||||||
|
],
|
||||||
|
"description": "Specifies the type of the custom remote service\n `Bitbucket`, `BitbucketServer`, `GitHub`, or `GitLab`"
|
||||||
|
},
|
||||||
|
"domain": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Specifies the domain name of the custom remote service"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"uniqueItems": true,
|
||||||
|
"description": "Specifies the custom remote services (code-hosting)"
|
||||||
|
},
|
||||||
"gitlens.statusBar.enabled": {
|
"gitlens.statusBar.enabled": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
@@ -784,6 +813,11 @@
|
|||||||
"title": "Directory Compare",
|
"title": "Directory Compare",
|
||||||
"category": "GitLens"
|
"category": "GitLens"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.diffWith",
|
||||||
|
"title": "Compare File Revisions",
|
||||||
|
"category": "GitLens"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.diffWithBranch",
|
"command": "gitlens.diffWithBranch",
|
||||||
"title": "Compare File with Branch...",
|
"title": "Compare File with Branch...",
|
||||||
@@ -1077,6 +1111,10 @@
|
|||||||
"command": "gitlens.diffDirectory",
|
"command": "gitlens.diffDirectory",
|
||||||
"when": "gitlens:enabled"
|
"when": "gitlens:enabled"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.diffWith",
|
||||||
|
"when": "false"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.diffWithBranch",
|
"command": "gitlens.diffWithBranch",
|
||||||
"when": "gitlens:isTracked"
|
"when": "gitlens:isTracked"
|
||||||
@@ -1488,12 +1526,12 @@
|
|||||||
"view/item/context": [
|
"view/item/context": [
|
||||||
{
|
{
|
||||||
"command": "gitlens.openBranchesInRemote",
|
"command": "gitlens.openBranchesInRemote",
|
||||||
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches",
|
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branches:remote",
|
||||||
"group": "1_gitlens@1"
|
"group": "1_gitlens@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"command": "gitlens.openBranchInRemote",
|
"command": "gitlens.openBranchInRemote",
|
||||||
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history",
|
"when": "gitlens:enabled && gitlens:hasRemotes && view == gitlens.gitExplorer && viewItem == gitlens:branch-history:remote",
|
||||||
"group": "1_gitlens@1"
|
"group": "1_gitlens@1"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -1787,7 +1825,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"applicationinsights": "0.21.0",
|
"applicationinsights": "0.21.0",
|
||||||
"copy-paste": "1.3.0",
|
"copy-paste": "1.3.0",
|
||||||
"iconv-lite": "0.4.18",
|
"iconv-lite": "0.4.19",
|
||||||
"ignore": "3.3.5",
|
"ignore": "3.3.5",
|
||||||
"lodash.debounce": "4.0.8",
|
"lodash.debounce": "4.0.8",
|
||||||
"lodash.escaperegexp": "4.1.2",
|
"lodash.escaperegexp": "4.1.2",
|
||||||
@@ -1801,10 +1839,10 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/copy-paste": "1.1.30",
|
"@types/copy-paste": "1.1.30",
|
||||||
"@types/iconv-lite": "0.0.1",
|
"@types/iconv-lite": "0.0.1",
|
||||||
"@types/mocha": "2.2.42",
|
"@types/mocha": "2.2.43",
|
||||||
"@types/node": "8.0.26",
|
"@types/node": "8.0.28",
|
||||||
"@types/tmp": "0.0.33",
|
"@types/tmp": "0.0.33",
|
||||||
"mocha": "3.5.0",
|
"mocha": "3.5.2",
|
||||||
"tslint": "5.7.0",
|
"tslint": "5.7.0",
|
||||||
"typescript": "2.5.2",
|
"typescript": "2.5.2",
|
||||||
"vscode": "1.1.5"
|
"vscode": "1.1.5"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Strings } from '../system';
|
import { Strings } from '../system';
|
||||||
import { DecorationInstanceRenderOptions, DecorationOptions, ThemableDecorationRenderOptions } from 'vscode';
|
import { DecorationInstanceRenderOptions, DecorationOptions, MarkdownString, ThemableDecorationRenderOptions } from 'vscode';
|
||||||
|
import { DiffWithCommand, ShowQuickCommitDetailsCommand } from '../commands';
|
||||||
import { IThemeConfig, themeDefaults } from '../configuration';
|
import { IThemeConfig, themeDefaults } from '../configuration';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { CommitFormatter, GitCommit, GitDiffChunkLine, GitService, GitUri, ICommitFormatOptions } from '../gitService';
|
import { CommitFormatter, GitCommit, GitDiffChunkLine, GitService, GitUri, ICommitFormatOptions } from '../gitService';
|
||||||
@@ -47,7 +48,7 @@ export class Annotations {
|
|||||||
return '#793738';
|
return '#793738';
|
||||||
}
|
}
|
||||||
|
|
||||||
static getHoverMessage(commit: GitCommit, dateFormat: string | null): string | string[] {
|
static getHoverMessage(commit: GitCommit, dateFormat: string | null): MarkdownString {
|
||||||
if (dateFormat === null) {
|
if (dateFormat === null) {
|
||||||
dateFormat = 'MMMM Do, YYYY h:MMa';
|
dateFormat = 'MMMM Do, YYYY h:MMa';
|
||||||
}
|
}
|
||||||
@@ -63,16 +64,21 @@ export class Annotations {
|
|||||||
.replace(/\n/g, ' \n');
|
.replace(/\n/g, ' \n');
|
||||||
message = `\n\n> ${message}`;
|
message = `\n\n> ${message}`;
|
||||||
}
|
}
|
||||||
return `\`${commit.shortSha}\` __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format(dateFormat)})_${message}`;
|
|
||||||
|
const markdown = new MarkdownString(`[\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.sha)}) __${commit.author}__, ${moment(commit.date).fromNow()} _(${moment(commit.date).format(dateFormat)})_${message}`);
|
||||||
|
markdown.isTrusted = true;
|
||||||
|
return markdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
static getHoverDiffMessage(commit: GitCommit, chunkLine: GitDiffChunkLine | undefined): string | undefined {
|
static getHoverDiffMessage(commit: GitCommit, chunkLine: GitDiffChunkLine | undefined): MarkdownString | undefined {
|
||||||
if (chunkLine === undefined) return undefined;
|
if (chunkLine === undefined) return undefined;
|
||||||
|
|
||||||
const codeDiff = this._getCodeDiff(chunkLine);
|
const codeDiff = this._getCodeDiff(chunkLine);
|
||||||
return commit.isUncommitted
|
const markdown = new MarkdownString(commit.isUncommitted
|
||||||
? `\`Changes\` ${GlyphChars.Dash} _uncommitted_\n${codeDiff}`
|
? `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(commit)}) ${GlyphChars.Dash} _uncommitted_\n${codeDiff}`
|
||||||
: `\`Changes\` ${GlyphChars.Dash} \`${commit.previousShortSha}\` ${GlyphChars.ArrowLeftRight} \`${commit.shortSha}\`\n${codeDiff}`;
|
: `[\`Changes\`](${DiffWithCommand.getMarkdownCommandArgs(commit)}) ${GlyphChars.Dash} [\`${commit.previousShortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.previousSha!)}) ${GlyphChars.ArrowLeftRight} [\`${commit.shortSha}\`](${ShowQuickCommitDetailsCommand.getMarkdownCommandArgs(commit.sha)})\n${codeDiff}`);
|
||||||
|
markdown.isTrusted = true;
|
||||||
|
return markdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static _getCodeDiff(chunkLine: GitDiffChunkLine): string {
|
private static _getCodeDiff(chunkLine: GitDiffChunkLine): string {
|
||||||
@@ -181,7 +187,10 @@ export class Annotations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static trailing(commit: GitCommit, format: string, dateFormat: string | null, cfgTheme: IThemeConfig): DecorationOptions {
|
static trailing(commit: GitCommit, format: string, dateFormat: string | null, cfgTheme: IThemeConfig): DecorationOptions {
|
||||||
const message = CommitFormatter.fromTemplate(format, commit, dateFormat);
|
const message = CommitFormatter.fromTemplate(format, commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dateFormat: dateFormat
|
||||||
|
} as ICommitFormatOptions);
|
||||||
return {
|
return {
|
||||||
renderOptions: {
|
renderOptions: {
|
||||||
after: {
|
after: {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { DecorationOptions, ExtensionContext, Position, Range, TextEditor, TextEditorDecorationType } from 'vscode';
|
import { DecorationOptions, ExtensionContext, MarkdownString, Position, Range, TextEditor, TextEditorDecorationType } from 'vscode';
|
||||||
import { Annotations, endOfLineIndex } from './annotations';
|
import { Annotations, endOfLineIndex } from './annotations';
|
||||||
import { FileAnnotationType } from './annotationController';
|
import { FileAnnotationType } from './annotationController';
|
||||||
import { AnnotationProviderBase } from './annotationProvider';
|
import { AnnotationProviderBase } from './annotationProvider';
|
||||||
@@ -48,7 +48,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
|
|||||||
} as DecorationOptions);
|
} as DecorationOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
let message: string | undefined = undefined;
|
let message: MarkdownString | undefined = undefined;
|
||||||
if (cfg.hover.changes) {
|
if (cfg.hover.changes) {
|
||||||
message = Annotations.getHoverDiffMessage(commit, line);
|
message = Annotations.getHoverDiffMessage(commit, line);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ export * from './commands/copyShaToClipboard';
|
|||||||
export * from './commands/diffDirectory';
|
export * from './commands/diffDirectory';
|
||||||
export * from './commands/diffLineWithPrevious';
|
export * from './commands/diffLineWithPrevious';
|
||||||
export * from './commands/diffLineWithWorking';
|
export * from './commands/diffLineWithWorking';
|
||||||
|
export * from './commands/diffWith';
|
||||||
export * from './commands/diffWithBranch';
|
export * from './commands/diffWithBranch';
|
||||||
export * from './commands/diffWithNext';
|
export * from './commands/diffWithNext';
|
||||||
export * from './commands/diffWithPrevious';
|
export * from './commands/diffWithPrevious';
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export type Commands =
|
|||||||
'gitlens.copyMessageToClipboard' |
|
'gitlens.copyMessageToClipboard' |
|
||||||
'gitlens.copyShaToClipboard' |
|
'gitlens.copyShaToClipboard' |
|
||||||
'gitlens.diffDirectory' |
|
'gitlens.diffDirectory' |
|
||||||
|
'gitlens.diffWith' |
|
||||||
'gitlens.diffWithBranch' |
|
'gitlens.diffWithBranch' |
|
||||||
'gitlens.diffWithNext' |
|
'gitlens.diffWithNext' |
|
||||||
'gitlens.diffWithPrevious' |
|
'gitlens.diffWithPrevious' |
|
||||||
@@ -52,6 +53,7 @@ export const Commands = {
|
|||||||
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
CopyMessageToClipboard: 'gitlens.copyMessageToClipboard' as Commands,
|
||||||
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
|
CopyShaToClipboard: 'gitlens.copyShaToClipboard' as Commands,
|
||||||
DiffDirectory: 'gitlens.diffDirectory' as Commands,
|
DiffDirectory: 'gitlens.diffDirectory' as Commands,
|
||||||
|
DiffWith: 'gitlens.diffWith' as Commands,
|
||||||
DiffWithBranch: 'gitlens.diffWithBranch' as Commands,
|
DiffWithBranch: 'gitlens.diffWithBranch' as Commands,
|
||||||
DiffWithNext: 'gitlens.diffWithNext' as Commands,
|
DiffWithNext: 'gitlens.diffWithNext' as Commands,
|
||||||
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
DiffWithPrevious: 'gitlens.diffWithPrevious' as Commands,
|
||||||
@@ -166,6 +168,10 @@ function isTextEditor(editor: any): editor is TextEditor {
|
|||||||
|
|
||||||
export abstract class Command extends Disposable {
|
export abstract class Command extends Disposable {
|
||||||
|
|
||||||
|
static getMarkdownCommandArgsCore<T>(command: Commands, args: T): string {
|
||||||
|
return `command:${command}?${encodeURIComponent(JSON.stringify(args))}`;
|
||||||
|
}
|
||||||
|
|
||||||
protected readonly contextParsingOptions: CommandContextParsingOptions = { editor: false, uri: false };
|
protected readonly contextParsingOptions: CommandContextParsingOptions = { editor: false, uri: false };
|
||||||
|
|
||||||
private _disposable: Disposable;
|
private _disposable: Disposable;
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, GlyphChars } from '../constants';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { DiffWithPreviousCommandArgs } from './diffWithPrevious';
|
|
||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface DiffLineWithPreviousCommandArgs {
|
export interface DiffLineWithPreviousCommandArgs {
|
||||||
commit?: GitCommit;
|
commit?: GitCommit;
|
||||||
|
|
||||||
line?: number;
|
line?: number;
|
||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
@@ -43,56 +41,26 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
|
|
||||||
args.commit = blame.commit;
|
args.commit = blame.commit;
|
||||||
|
|
||||||
// If we don't have a sha or the current commit matches the blame, show the previous
|
|
||||||
if (gitUri.sha === undefined || gitUri.sha === args.commit.sha) {
|
|
||||||
return commands.executeCommand(Commands.DiffWithPrevious, new GitUri(uri, args.commit), {
|
|
||||||
line: args.line,
|
|
||||||
showOptions: args.showOptions
|
|
||||||
} as DiffWithPreviousCommandArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the line is uncommitted, find the previous commit and treat it as a DiffWithWorking
|
|
||||||
if (args.commit.isUncommitted) {
|
|
||||||
uri = args.commit.uri;
|
|
||||||
args.commit = new GitCommit(args.commit.type, args.commit.repoPath, args.commit.previousSha!, args.commit.previousFileName!, args.commit.author, args.commit.date, args.commit.message);
|
|
||||||
args.line = (blame.line.line + 1) + gitUri.offset;
|
|
||||||
|
|
||||||
return commands.executeCommand(Commands.DiffWithWorking, uri, {
|
|
||||||
commit: args.commit,
|
|
||||||
line: args.line,
|
|
||||||
showOptions: args.showOptions
|
|
||||||
} as DiffWithWorkingCommandArgs);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'DiffWithPreviousLineCommand', `getBlameForLine(${blameline})`);
|
Logger.error(ex, 'DiffLineWithPreviousCommand', `getBlameForLine(${blameline})`);
|
||||||
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
const [rhs, lhs] = await Promise.all([
|
repoPath: args.commit.repoPath,
|
||||||
this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha!),
|
lhs: {
|
||||||
this.git.getVersionedFile(args.commit.repoPath, args.commit.uri.fsPath, args.commit.sha)
|
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.fakeSha,
|
||||||
]);
|
uri: args.commit.previousUri
|
||||||
|
},
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
rhs: {
|
||||||
if (args.showOptions === undefined) {
|
sha: args.commit.sha,
|
||||||
args.showOptions = {};
|
uri: args.commit.uri
|
||||||
}
|
},
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
line: args.line,
|
||||||
}
|
showOptions: args.showOptions
|
||||||
|
};
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
Uri.file(lhs),
|
|
||||||
Uri.file(rhs),
|
|
||||||
`${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)} (${gitUri.shortSha})`,
|
|
||||||
args.showOptions);
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Logger.error(ex, 'DiffWithPreviousLineCommand', 'getVersionedFile');
|
|
||||||
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export interface DiffLineWithWorkingCommandArgs {
|
export interface DiffLineWithWorkingCommandArgs {
|
||||||
commit?: GitCommit;
|
commit?: GitCommit;
|
||||||
|
|
||||||
line?: number;
|
line?: number;
|
||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,19 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return commands.executeCommand(Commands.DiffWithWorking, uri, args as DiffWithWorkingCommandArgs);
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
|
repoPath: args.commit.repoPath,
|
||||||
|
lhs: {
|
||||||
|
sha: args.commit.sha,
|
||||||
|
uri: args.commit.uri
|
||||||
|
},
|
||||||
|
rhs: {
|
||||||
|
sha: '',
|
||||||
|
uri: args.commit.uri
|
||||||
|
},
|
||||||
|
line: args.line,
|
||||||
|
showOptions: args.showOptions
|
||||||
|
};
|
||||||
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
150
src/commands/diffWith.ts
Normal file
150
src/commands/diffWith.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
'use strict';
|
||||||
|
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
|
import { ActiveEditorCommand, Commands } from './common';
|
||||||
|
import { BuiltInCommands, GlyphChars } from '../constants';
|
||||||
|
import { GitCommit, GitService } from '../gitService';
|
||||||
|
import { Logger } from '../logger';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export interface DiffWithCommandArgsRevision {
|
||||||
|
sha: string;
|
||||||
|
uri: Uri;
|
||||||
|
title?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DiffWithCommandArgs {
|
||||||
|
lhs?: DiffWithCommandArgsRevision;
|
||||||
|
rhs?: DiffWithCommandArgsRevision;
|
||||||
|
repoPath?: string;
|
||||||
|
|
||||||
|
line?: number;
|
||||||
|
showOptions?: TextDocumentShowOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DiffWithCommand extends ActiveEditorCommand {
|
||||||
|
|
||||||
|
static getMarkdownCommandArgs(args: DiffWithCommandArgs): string;
|
||||||
|
static getMarkdownCommandArgs(commit1: GitCommit, commit2: GitCommit): string;
|
||||||
|
static getMarkdownCommandArgs(argsOrCommit1: DiffWithCommandArgs | GitCommit, commit2?: GitCommit): string {
|
||||||
|
let args = argsOrCommit1;
|
||||||
|
if (argsOrCommit1 instanceof GitCommit) {
|
||||||
|
const commit1 = argsOrCommit1;
|
||||||
|
|
||||||
|
if (commit2 === undefined) {
|
||||||
|
if (commit1.isUncommitted) {
|
||||||
|
args = {
|
||||||
|
repoPath: commit1.repoPath,
|
||||||
|
lhs: {
|
||||||
|
sha: 'HEAD',
|
||||||
|
uri: commit1.uri
|
||||||
|
},
|
||||||
|
rhs: {
|
||||||
|
sha: '',
|
||||||
|
uri: commit1.uri
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args = {
|
||||||
|
repoPath: commit1.repoPath,
|
||||||
|
lhs: {
|
||||||
|
sha: commit1.previousSha!,
|
||||||
|
uri: commit1.previousUri!
|
||||||
|
},
|
||||||
|
rhs: {
|
||||||
|
sha: commit1.sha,
|
||||||
|
uri: commit1.uri
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args = {
|
||||||
|
repoPath: commit1.repoPath,
|
||||||
|
lhs: {
|
||||||
|
sha: commit1.sha,
|
||||||
|
uri: commit1.uri
|
||||||
|
},
|
||||||
|
rhs: {
|
||||||
|
sha: commit2.sha,
|
||||||
|
uri: commit2.uri
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getMarkdownCommandArgsCore<DiffWithCommandArgs>(Commands.DiffWith, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(private git: GitService) {
|
||||||
|
super(Commands.DiffWith);
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute(editor?: TextEditor, uri?: Uri, args: DiffWithCommandArgs = {}): Promise<any> {
|
||||||
|
args = { ...args };
|
||||||
|
if (args.repoPath === undefined || args.lhs === undefined || args.rhs === undefined) return undefined;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const [lhs, rhs] = await Promise.all([
|
||||||
|
args.lhs.sha !== '' && !GitService.isUncommitted(args.lhs.sha)
|
||||||
|
? this.git.getVersionedFile(args.repoPath, args.lhs.uri.fsPath, args.lhs.sha)
|
||||||
|
: args.lhs.uri.fsPath,
|
||||||
|
args.rhs.sha !== '' && !GitService.isUncommitted(args.rhs.sha)
|
||||||
|
? this.git.getVersionedFile(args.repoPath, args.rhs.uri.fsPath, args.rhs.sha)
|
||||||
|
: args.rhs.uri.fsPath
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (args.line !== undefined && args.line !== 0) {
|
||||||
|
if (args.showOptions === undefined) {
|
||||||
|
args.showOptions = {};
|
||||||
|
}
|
||||||
|
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
let lhsPrefix = '';
|
||||||
|
if (lhs === undefined) {
|
||||||
|
lhsPrefix = 'deleted in ';
|
||||||
|
}
|
||||||
|
else if (args.rhs.sha === GitService.fakeSha) {
|
||||||
|
lhsPrefix = 'added in ';
|
||||||
|
}
|
||||||
|
|
||||||
|
let rhsPrefix = '';
|
||||||
|
if (rhs === undefined) {
|
||||||
|
rhsPrefix = 'deleted in ';
|
||||||
|
}
|
||||||
|
else if (args.lhs.sha === GitService.fakeSha) {
|
||||||
|
rhsPrefix = 'added in ';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.lhs.title === undefined && args.lhs.sha !== GitService.fakeSha) {
|
||||||
|
args.lhs.title = (args.lhs.sha === '' || GitService.isUncommitted(args.lhs.sha))
|
||||||
|
? `${path.basename(args.lhs.uri.fsPath)}`
|
||||||
|
: `${path.basename(args.lhs.uri.fsPath)} (${lhsPrefix}${GitService.shortenSha(args.lhs.sha)})`;
|
||||||
|
}
|
||||||
|
if (args.rhs.title === undefined && args.rhs.sha !== GitService.fakeSha) {
|
||||||
|
args.rhs.title = (args.rhs.sha === '' || GitService.isUncommitted(args.rhs.sha))
|
||||||
|
? `${path.basename(args.rhs.uri.fsPath)}`
|
||||||
|
: `${path.basename(args.rhs.uri.fsPath)} (${rhsPrefix}${GitService.shortenSha(args.rhs.sha)})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = (args.lhs.title !== undefined && args.rhs.title !== undefined)
|
||||||
|
? `${args.lhs.title} ${GlyphChars.ArrowLeftRight} ${args.rhs.title}`
|
||||||
|
: args.lhs.title || args.rhs.title;
|
||||||
|
|
||||||
|
return await commands.executeCommand(BuiltInCommands.Diff,
|
||||||
|
lhs === undefined
|
||||||
|
? GitService.toGitContentUri(GitService.fakeSha, args.lhs.uri.fsPath, args.repoPath)
|
||||||
|
: Uri.file(lhs),
|
||||||
|
rhs === undefined
|
||||||
|
? GitService.toGitContentUri(GitService.fakeSha, args.rhs.uri.fsPath, args.repoPath)
|
||||||
|
: Uri.file(rhs),
|
||||||
|
title,
|
||||||
|
args.showOptions);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
Logger.error(ex, 'DiffWithCommand', 'getVersionedFile');
|
||||||
|
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextDocumentShowOptions, TextEditor, Uri } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@@ -42,25 +42,20 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
|||||||
const branch = pick.branch.name;
|
const branch = pick.branch.name;
|
||||||
if (branch === undefined) return undefined;
|
if (branch === undefined) return undefined;
|
||||||
|
|
||||||
try {
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
const compare = await this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, branch);
|
repoPath: gitUri.repoPath,
|
||||||
|
lhs: {
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
sha: pick.branch.remote ? `remotes/${branch}` : branch,
|
||||||
if (args.showOptions === undefined) {
|
uri: gitUri as Uri,
|
||||||
args.showOptions = {};
|
title: `${path.basename(gitUri.fsPath)} (${branch})`
|
||||||
}
|
},
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
rhs: {
|
||||||
}
|
sha: '',
|
||||||
|
uri: gitUri as Uri
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
},
|
||||||
Uri.file(compare),
|
line: args.line,
|
||||||
gitUri.fileUri(),
|
showOptions: args.showOptions
|
||||||
`${path.basename(gitUri.fsPath)} (${branch}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)}`,
|
};
|
||||||
args.showOptions);
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Logger.error(ex, 'DiffWithBranchCommand', 'getVersionedFile');
|
|
||||||
return window.showErrorMessage(`Unable to open branch compare. See output channel for more details`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,16 +2,16 @@
|
|||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, GlyphChars } from '../constants';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { GitLogCommit, GitService, GitUri } from '../gitService';
|
import { GitLogCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface DiffWithNextCommandArgs {
|
export interface DiffWithNextCommandArgs {
|
||||||
commit?: GitLogCommit;
|
commit?: GitLogCommit;
|
||||||
line?: number;
|
|
||||||
range?: Range;
|
range?: Range;
|
||||||
|
|
||||||
|
line?: number;
|
||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,28 +54,19 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
if (args.commit.nextSha === undefined) return commands.executeCommand(Commands.DiffWithWorking, uri);
|
if (args.commit.nextSha === undefined) return commands.executeCommand(Commands.DiffWithWorking, uri);
|
||||||
|
|
||||||
try {
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
const [rhs, lhs] = await Promise.all([
|
repoPath: args.commit.repoPath,
|
||||||
this.git.getVersionedFile(args.commit.repoPath, args.commit.nextUri.fsPath, args.commit.nextSha),
|
lhs: {
|
||||||
this.git.getVersionedFile(args.commit.repoPath, args.commit.uri.fsPath, args.commit.sha)
|
sha: args.commit.sha,
|
||||||
]);
|
uri: args.commit.uri
|
||||||
|
},
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
rhs: {
|
||||||
if (args.showOptions === undefined) {
|
sha: args.commit.nextSha,
|
||||||
args.showOptions = {};
|
uri: args.commit.nextUri
|
||||||
}
|
},
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
line: args.line,
|
||||||
}
|
showOptions: args.showOptions
|
||||||
|
};
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
Uri.file(lhs),
|
|
||||||
Uri.file(rhs),
|
|
||||||
`${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(args.commit.nextUri.fsPath)} (${args.commit.nextShortSha})`,
|
|
||||||
args.showOptions);
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Logger.error(ex, 'DiffWithNextCommand', 'getVersionedFile');
|
|
||||||
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,22 +2,18 @@
|
|||||||
import { Iterables } from '../system';
|
import { Iterables } from '../system';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, FakeSha, GlyphChars } from '../constants';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface DiffWithPreviousCommandArgs {
|
export interface DiffWithPreviousCommandArgs {
|
||||||
commit?: GitCommit;
|
commit?: GitCommit;
|
||||||
line?: number;
|
|
||||||
range?: Range;
|
range?: Range;
|
||||||
showOptions?: TextDocumentShowOptions;
|
|
||||||
|
|
||||||
allowMissingPrevious?: boolean;
|
line?: number;
|
||||||
leftTitlePrefix?: string;
|
showOptions?: TextDocumentShowOptions;
|
||||||
rightTitlePrefix?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||||
@@ -40,6 +36,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
||||||
|
if (sha === GitService.fakeSha) return Messages.showCommitHasNoPreviousCommitWarningMessage();
|
||||||
|
|
||||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, sha, { maxCount: 2, range: args.range!, skipMerges: true });
|
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, sha, { maxCount: 2, range: args.range!, skipMerges: true });
|
||||||
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
@@ -47,7 +44,9 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||||
|
|
||||||
// If the sha is missing and the file is uncommitted, then treat it as a DiffWithWorking
|
// If the sha is missing and the file is uncommitted, then treat it as a DiffWithWorking
|
||||||
if (gitUri.sha === undefined && await this.git.isFileUncommitted(gitUri)) return commands.executeCommand(Commands.DiffWithWorking, uri, { commit: args.commit, showOptions: args.showOptions } as DiffWithWorkingCommandArgs);
|
if (gitUri.sha === undefined && await this.git.isFileUncommitted(gitUri)) {
|
||||||
|
return commands.executeCommand(Commands.DiffWithWorking, uri, { commit: args.commit, showOptions: args.showOptions } as DiffWithWorkingCommandArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
|
Logger.error(ex, 'DiffWithPreviousCommand', `getLogForFile(${gitUri.repoPath}, ${gitUri.fsPath})`);
|
||||||
@@ -55,32 +54,19 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.commit.previousSha === undefined && !args.allowMissingPrevious) return Messages.showCommitHasNoPreviousCommitWarningMessage(args.commit);
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
|
repoPath: args.commit.repoPath,
|
||||||
try {
|
lhs: {
|
||||||
const [rhs, lhs] = await Promise.all([
|
sha: args.commit.previousSha !== undefined ? args.commit.previousSha : GitService.fakeSha,
|
||||||
this.git.getVersionedFile(args.commit.repoPath, args.commit.uri.fsPath, args.commit.sha),
|
uri: args.commit.previousUri
|
||||||
this.git.getVersionedFile(args.commit.repoPath, args.commit.previousUri.fsPath, args.commit.previousSha === undefined ? FakeSha : args.commit.previousSha)
|
},
|
||||||
]);
|
rhs: {
|
||||||
|
sha: args.commit.sha,
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
uri: args.commit.uri
|
||||||
if (args.showOptions === undefined) {
|
},
|
||||||
args.showOptions = {};
|
line: args.line,
|
||||||
}
|
showOptions: args.showOptions
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
};
|
||||||
}
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
|
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
|
||||||
Uri.file(lhs),
|
|
||||||
Uri.file(rhs),
|
|
||||||
args.commit.previousShortSha === undefined
|
|
||||||
? `${path.basename(args.commit.uri.fsPath)} (${args.rightTitlePrefix || ''}${args.commit.shortSha})`
|
|
||||||
: `${path.basename(args.commit.previousUri.fsPath)} (${args.leftTitlePrefix || ''}${args.commit.previousShortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(args.commit.uri.fsPath)} (${args.rightTitlePrefix || ''}${args.commit.shortSha})`,
|
|
||||||
args.showOptions);
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Logger.error(ex, 'DiffWithPreviousCommand', 'getVersionedFile');
|
|
||||||
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, GlyphChars } from '../constants';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface DiffWithRevisionCommandArgs {
|
export interface DiffWithRevisionCommandArgs {
|
||||||
line?: number;
|
|
||||||
maxCount?: number;
|
maxCount?: number;
|
||||||
|
|
||||||
|
line?: number;
|
||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,24 +46,24 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
if (pick instanceof CommandQuickPickItem) return pick.execute();
|
||||||
|
|
||||||
const compare = await this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, pick.commit.sha);
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
|
repoPath: gitUri.repoPath,
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
lhs: {
|
||||||
if (args.showOptions === undefined) {
|
sha: pick.commit.sha,
|
||||||
args.showOptions = {};
|
uri: gitUri as Uri
|
||||||
}
|
},
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
rhs: {
|
||||||
}
|
sha: '',
|
||||||
|
uri: gitUri as Uri
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
},
|
||||||
Uri.file(compare),
|
line: args.line,
|
||||||
gitUri.fileUri(),
|
showOptions: args.showOptions
|
||||||
`${path.basename(gitUri.fsPath)} (${pick.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(gitUri.fsPath)}`,
|
};
|
||||||
args.showOptions);
|
return await commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'DiffWithRevisionCommand', 'getVersionedFile');
|
Logger.error(ex, 'DiffWithRevisionCommand');
|
||||||
return window.showErrorMessage(`Unable to open history compare. See output channel for more details`);
|
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { commands, Range, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { BuiltInCommands, GlyphChars } from '../constants';
|
import { DiffWithCommandArgs } from './diffWith';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { Messages } from '../messages';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export interface DiffWithWorkingCommandArgs {
|
export interface DiffWithWorkingCommandArgs {
|
||||||
commit?: GitCommit;
|
commit?: GitCommit;
|
||||||
|
|
||||||
line?: number;
|
line?: number;
|
||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
@@ -48,25 +48,19 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
|||||||
const workingFileName = await this.git.findWorkingFileName(gitUri.repoPath, gitUri.fsPath);
|
const workingFileName = await this.git.findWorkingFileName(gitUri.repoPath, gitUri.fsPath);
|
||||||
if (workingFileName === undefined) return undefined;
|
if (workingFileName === undefined) return undefined;
|
||||||
|
|
||||||
try {
|
const diffArgs: DiffWithCommandArgs = {
|
||||||
const compare = await this.git.getVersionedFile(args.commit.repoPath, args.commit.uri.fsPath, args.commit.sha);
|
repoPath: args.commit.repoPath,
|
||||||
|
lhs: {
|
||||||
if (args.line !== undefined && args.line !== 0) {
|
sha: args.commit.sha,
|
||||||
if (args.showOptions === undefined) {
|
uri: args.commit.uri
|
||||||
args.showOptions = {};
|
},
|
||||||
}
|
rhs: {
|
||||||
args.showOptions.selection = new Range(args.line, 0, args.line, 0);
|
sha: '',
|
||||||
}
|
uri: args.commit.uri
|
||||||
|
},
|
||||||
await commands.executeCommand(BuiltInCommands.Diff,
|
line: args.line,
|
||||||
Uri.file(compare),
|
showOptions: args.showOptions
|
||||||
Uri.file(path.resolve(gitUri.repoPath, workingFileName)),
|
};
|
||||||
`${path.basename(args.commit.uri.fsPath)} (${args.commit.shortSha}) ${GlyphChars.ArrowLeftRight} ${path.basename(workingFileName)}`,
|
return commands.executeCommand(Commands.DiffWith, diffArgs);
|
||||||
args.showOptions);
|
|
||||||
}
|
|
||||||
catch (ex) {
|
|
||||||
Logger.error(ex, 'DiffWithWorkingCommand', 'getVersionedFile');
|
|
||||||
return window.showErrorMessage(`Unable to open compare. See output channel for more details`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,10 +22,8 @@ export class OpenBranchInRemoteCommand extends ActiveEditorCommand {
|
|||||||
protected async preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}): Promise<any> {
|
protected async preExecute(context: CommandContext, args: OpenBranchInRemoteCommandArgs = {}): Promise<any> {
|
||||||
if (isCommandViewContextWithBranch(context)) {
|
if (isCommandViewContextWithBranch(context)) {
|
||||||
args = { ...args };
|
args = { ...args };
|
||||||
|
|
||||||
args.branch = context.node.branch.name;
|
args.branch = context.node.branch.name;
|
||||||
args.remote = context.node.branch.getRemote();
|
args.remote = context.node.branch.getRemote();
|
||||||
return this.execute(context.editor, context.uri, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.execute(context.editor, context.uri, args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export class OpenBranchesInRemoteCommand extends ActiveEditorCommand {
|
|||||||
if (isCommandViewContextWithRemote(context)) {
|
if (isCommandViewContextWithRemote(context)) {
|
||||||
args = { ...args };
|
args = { ...args };
|
||||||
args.remote = context.node.remote.name;
|
args.remote = context.node.remote.name;
|
||||||
return this.execute(context.editor, context.uri, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.execute(context.editor, context.uri, args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
|||||||
super(Commands.OpenFileInRemote);
|
super(Commands.OpenFileInRemote);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async preExecute(context: CommandContext, args: OpenFileInRemoteCommandArgs = {}): Promise<any> {
|
protected async preExecute(context: CommandContext, args: OpenFileInRemoteCommandArgs = { range: true }): Promise<any> {
|
||||||
if (isCommandViewContextWithCommit(context)) {
|
if (isCommandViewContextWithCommit(context)) {
|
||||||
args = { ...args };
|
args = { ...args };
|
||||||
args.range = false;
|
args.range = false;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Strings } from '../system';
|
|||||||
import { TextEditor, Uri, window } from 'vscode';
|
import { TextEditor, Uri, window } from 'vscode';
|
||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { GitLogCommit, GitRemote, RemoteResource } from '../gitService';
|
import { GitLogCommit, GitRemote, GitService, RemoteResource } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, OpenRemoteCommandQuickPickItem, RemotesQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'commit':
|
case 'commit':
|
||||||
const shortSha = args.resource.sha.substring(0, 8);
|
const shortSha = GitService.shortenSha(args.resource.sha);
|
||||||
placeHolder = `open commit ${shortSha} in${GlyphChars.Ellipsis}`;
|
placeHolder = `open commit ${shortSha} in${GlyphChars.Ellipsis}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const shortFileSha = args.resource.sha === undefined ? '' : args.resource.sha.substring(0, 8);
|
const shortFileSha = args.resource.sha === undefined ? '' : GitService.shortenSha(args.resource.sha);
|
||||||
const shaSuffix = shortFileSha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${shortFileSha}` : '';
|
const shaSuffix = shortFileSha ? ` ${Strings.pad(GlyphChars.Dot, 1, 1)} ${shortFileSha}` : '';
|
||||||
|
|
||||||
placeHolder = `open ${args.resource.fileName}${shaSuffix} in${GlyphChars.Ellipsis}`;
|
placeHolder = `open ${args.resource.fileName}${shaSuffix} in${GlyphChars.Ellipsis}`;
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export class OpenRepoInRemoteCommand extends ActiveEditorCommand {
|
|||||||
if (isCommandViewContextWithRemote(context)) {
|
if (isCommandViewContextWithRemote(context)) {
|
||||||
args = { ...args };
|
args = { ...args };
|
||||||
args.remote = context.node.remote.name;
|
args.remote = context.node.remote.name;
|
||||||
return this.execute(context.editor, context.uri, args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.execute(context.editor, context.uri, args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
|
|||||||
@@ -20,20 +20,29 @@ export interface ShowQuickCommitDetailsCommandArgs {
|
|||||||
|
|
||||||
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
|
static getMarkdownCommandArgs(sha: string): string;
|
||||||
|
static getMarkdownCommandArgs(args: ShowQuickCommitDetailsCommandArgs): string;
|
||||||
|
static getMarkdownCommandArgs(argsOrSha: ShowQuickCommitDetailsCommandArgs | string): string {
|
||||||
|
const args = typeof argsOrSha === 'string'
|
||||||
|
? { sha: argsOrSha }
|
||||||
|
: argsOrSha;
|
||||||
|
return super.getMarkdownCommandArgsCore<ShowQuickCommitDetailsCommandArgs>(Commands.ShowQuickCommitDetails, args);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private git: GitService) {
|
constructor(private git: GitService) {
|
||||||
super(Commands.ShowQuickCommitDetails);
|
super(Commands.ShowQuickCommitDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async preExecute(context: CommandContext, ...args: any[]): Promise<any> {
|
protected async preExecute(context: CommandContext, args: ShowQuickCommitDetailsCommandArgs = {}): Promise<any> {
|
||||||
if (context.type === 'view') {
|
if (context.type === 'view') {
|
||||||
|
args = { ...args };
|
||||||
|
args.sha = context.node.uri.sha;
|
||||||
|
|
||||||
if (isCommandViewContextWithCommit(context)) {
|
if (isCommandViewContextWithCommit(context)) {
|
||||||
args = [{ sha: context.node.uri.sha, commit: context.node.commit }];
|
args.commit = context.node.commit;
|
||||||
}
|
|
||||||
else {
|
|
||||||
args = [{ sha: context.node.uri.sha }];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.execute(context.editor, context.uri, ...args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) {
|
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitDetailsCommandArgs = {}) {
|
||||||
|
|||||||
@@ -20,20 +20,29 @@ export interface ShowQuickCommitFileDetailsCommandArgs {
|
|||||||
|
|
||||||
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand {
|
export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand {
|
||||||
|
|
||||||
|
static getMarkdownCommandArgs(sha: string): string;
|
||||||
|
static getMarkdownCommandArgs(args: ShowQuickCommitFileDetailsCommandArgs): string;
|
||||||
|
static getMarkdownCommandArgs(argsOrSha: ShowQuickCommitFileDetailsCommandArgs | string): string {
|
||||||
|
const args = typeof argsOrSha === 'string'
|
||||||
|
? { sha: argsOrSha }
|
||||||
|
: argsOrSha;
|
||||||
|
return super.getMarkdownCommandArgsCore<ShowQuickCommitFileDetailsCommandArgs>(Commands.ShowQuickCommitFileDetails, args);
|
||||||
|
}
|
||||||
|
|
||||||
constructor(private git: GitService) {
|
constructor(private git: GitService) {
|
||||||
super(Commands.ShowQuickCommitFileDetails);
|
super(Commands.ShowQuickCommitFileDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async preExecute(context: CommandContext, ...args: any[]): Promise<any> {
|
protected async preExecute(context: CommandContext, args: ShowQuickCommitFileDetailsCommandArgs = {}): Promise<any> {
|
||||||
if (context.type === 'view') {
|
if (context.type === 'view') {
|
||||||
|
args = { ...args };
|
||||||
|
args.sha = context.node.uri.sha;
|
||||||
|
|
||||||
if (isCommandViewContextWithCommit(context)) {
|
if (isCommandViewContextWithCommit(context)) {
|
||||||
args = [{ sha: context.node.uri.sha, commit: context.node.commit }];
|
args.commit = context.node.commit;
|
||||||
}
|
|
||||||
else {
|
|
||||||
args = [{ sha: context.node.uri.sha }];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.execute(context.editor, context.uri, ...args);
|
return this.execute(context.editor, context.uri, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitFileDetailsCommandArgs = {}) {
|
async execute(editor?: TextEditor, uri?: Uri, args: ShowQuickCommitFileDetailsCommandArgs = {}) {
|
||||||
@@ -95,7 +104,7 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
|||||||
args.commit.workingFileName = workingFileName;
|
args.commit.workingFileName = workingFileName;
|
||||||
args.commit.workingFileName = await this.git.findWorkingFileName(args.commit);
|
args.commit.workingFileName = await this.git.findWorkingFileName(args.commit);
|
||||||
|
|
||||||
const shortSha = args.sha!.substring(0, 8);
|
const shortSha = GitService.shortenSha(args.sha!);
|
||||||
|
|
||||||
if (args.goBackCommand === undefined) {
|
if (args.goBackCommand === undefined) {
|
||||||
// Create a command to get back to the commit details
|
// Create a command to get back to the commit details
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class StashApplyCommand extends Command {
|
|||||||
return this.execute(args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.preExecute(context, args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(args: StashApplyCommandArgs = { confirm: true, deleteAfter: false }) {
|
async execute(args: StashApplyCommandArgs = { confirm: true, deleteAfter: false }) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class StashDeleteCommand extends Command {
|
|||||||
return this.execute(args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.preExecute(context, args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(args: StashDeleteCommandArgs = { confirm: true }) {
|
async execute(args: StashDeleteCommandArgs = { confirm: true }) {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ export class StashSaveCommand extends Command {
|
|||||||
return this.execute(args);
|
return this.execute(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(args: StashSaveCommandArgs = { }) {
|
async execute(args: StashSaveCommandArgs = {}) {
|
||||||
if (!this.git.repoPath) return undefined;
|
if (!this.git.repoPath) return undefined;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import { OutputLevel } from './logger';
|
|||||||
|
|
||||||
export { ExtensionKey } from './constants';
|
export { ExtensionKey } from './constants';
|
||||||
|
|
||||||
export type CodeLensCommand = 'gitlens.toggleFileBlame' |
|
export type CodeLensCommand =
|
||||||
|
'gitlens.toggleFileBlame' |
|
||||||
'gitlens.showBlameHistory' |
|
'gitlens.showBlameHistory' |
|
||||||
'gitlens.showFileHistory' |
|
'gitlens.showFileHistory' |
|
||||||
'gitlens.diffWithPrevious' |
|
'gitlens.diffWithPrevious' |
|
||||||
@@ -41,7 +42,19 @@ export const LineHighlightLocations = {
|
|||||||
OverviewRuler: 'overviewRuler' as LineHighlightLocations
|
OverviewRuler: 'overviewRuler' as LineHighlightLocations
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StatusBarCommand = 'gitlens.toggleFileBlame' |
|
export type CustomRemoteType =
|
||||||
|
'Bitbucket' |
|
||||||
|
'GitHub' |
|
||||||
|
'GitLab';
|
||||||
|
export const CustomRemoteType = {
|
||||||
|
Bitbucket: 'Bitbucket' as CustomRemoteType,
|
||||||
|
BitbucketServer: 'BitbucketServer' as CustomRemoteType,
|
||||||
|
GitHub: 'GitHub' as CustomRemoteType,
|
||||||
|
GitLab: 'GitLab' as CustomRemoteType
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StatusBarCommand =
|
||||||
|
'gitlens.toggleFileBlame' |
|
||||||
'gitlens.showBlameHistory' |
|
'gitlens.showBlameHistory' |
|
||||||
'gitlens.showFileHistory' |
|
'gitlens.showFileHistory' |
|
||||||
'gitlens.toggleCodeLens' |
|
'gitlens.toggleCodeLens' |
|
||||||
@@ -119,6 +132,11 @@ export interface ICodeLensLanguageLocation {
|
|||||||
customSymbols?: string[];
|
customSymbols?: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IRemotesConfig {
|
||||||
|
type: CustomRemoteType;
|
||||||
|
domain: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface IThemeConfig {
|
export interface IThemeConfig {
|
||||||
annotations: {
|
annotations: {
|
||||||
file: {
|
file: {
|
||||||
@@ -307,6 +325,8 @@ export interface IConfig {
|
|||||||
// dateFormat: string | null;
|
// dateFormat: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
remotes: IRemotesConfig[];
|
||||||
|
|
||||||
statusBar: {
|
statusBar: {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
alignment: 'left' | 'right';
|
alignment: 'left' | 'right';
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ export const QualifiedExtensionId = `eamodio.${ExtensionId}`;
|
|||||||
|
|
||||||
export const ApplicationInsightsKey = 'a9c302f8-6483-4d01-b92c-c159c799c679';
|
export const ApplicationInsightsKey = 'a9c302f8-6483-4d01-b92c-c159c799c679';
|
||||||
|
|
||||||
export const FakeSha = 'ffffffffffffffffffffffffffffffffffffffff';
|
|
||||||
|
|
||||||
export type BuiltInCommands = 'cursorMove' |
|
export type BuiltInCommands = 'cursorMove' |
|
||||||
'editor.action.showReferences' |
|
'editor.action.showReferences' |
|
||||||
'editor.action.toggleRenderWhitespace' |
|
'editor.action.toggleRenderWhitespace' |
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Commands } from './commands';
|
|||||||
import { TextEditorComparer } from './comparers';
|
import { TextEditorComparer } from './comparers';
|
||||||
import { IConfig, StatusBarCommand } from './configuration';
|
import { IConfig, StatusBarCommand } from './configuration';
|
||||||
import { DocumentSchemes, ExtensionKey } from './constants';
|
import { DocumentSchemes, ExtensionKey } from './constants';
|
||||||
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitCommitLine, GitContextTracker, GitService, GitUri } from './gitService';
|
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitCommitLine, GitContextTracker, GitService, GitUri, ICommitFormatOptions } from './gitService';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
|
|
||||||
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
||||||
@@ -432,7 +432,7 @@ export class CurrentLineController extends Disposable {
|
|||||||
decoration.range = editor.document.validateRange(new Range(line, showDetailsStartIndex, line, endOfLineIndex));
|
decoration.range = editor.document.validateRange(new Range(line, showDetailsStartIndex, line, endOfLineIndex));
|
||||||
decorationOptions.push(decoration);
|
decorationOptions.push(decoration);
|
||||||
|
|
||||||
if (showDetailsInStartingWhitespace && showDetailsStartIndex !== 0) {
|
if (showDetailsInStartingWhitespace && showDetailsStartIndex !== 0 && decoration.range.end.character !== 0) {
|
||||||
decorationOptions.push(Annotations.withRange(decoration, 0, firstNonWhitespace));
|
decorationOptions.push(Annotations.withRange(decoration, 0, firstNonWhitespace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,7 +446,7 @@ export class CurrentLineController extends Disposable {
|
|||||||
decoration.range = editor.document.validateRange(new Range(line, showChangesStartIndex, line, endOfLineIndex));
|
decoration.range = editor.document.validateRange(new Range(line, showChangesStartIndex, line, endOfLineIndex));
|
||||||
decorationOptions.push(decoration);
|
decorationOptions.push(decoration);
|
||||||
|
|
||||||
if (showChangesInStartingWhitespace && showChangesStartIndex !== 0) {
|
if (showChangesInStartingWhitespace && showChangesStartIndex !== 0 && decoration.range.end.character !== 0) {
|
||||||
decorationOptions.push(Annotations.withRange(decoration, 0, firstNonWhitespace));
|
decorationOptions.push(Annotations.withRange(decoration, 0, firstNonWhitespace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -462,7 +462,10 @@ export class CurrentLineController extends Disposable {
|
|||||||
const cfg = this._config.statusBar;
|
const cfg = this._config.statusBar;
|
||||||
if (!cfg.enabled || this._statusBarItem === undefined) return;
|
if (!cfg.enabled || this._statusBarItem === undefined) return;
|
||||||
|
|
||||||
this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat)}`;
|
this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dateFormat: cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat
|
||||||
|
} as ICommitFormatOptions)}`;
|
||||||
|
|
||||||
switch (cfg.command) {
|
switch (cfg.command) {
|
||||||
case StatusBarCommand.BlameAnnotate:
|
case StatusBarCommand.BlameAnnotate:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { AnnotationController } from './annotations/annotationController';
|
|||||||
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
||||||
import { OpenBranchesInRemoteCommand, OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
import { OpenBranchesInRemoteCommand, OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
||||||
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
||||||
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithRevisionCommand, DiffWithWorkingCommand } from './commands';
|
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithRevisionCommand, DiffWithWorkingCommand } from './commands';
|
||||||
import { ResetSuppressedWarningsCommand } from './commands';
|
import { ResetSuppressedWarningsCommand } from './commands';
|
||||||
import { ClearFileAnnotationsCommand, ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleFileRecentChangesCommand, ToggleLineBlameCommand } from './commands';
|
import { ClearFileAnnotationsCommand, ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleFileRecentChangesCommand, ToggleLineBlameCommand } from './commands';
|
||||||
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
||||||
@@ -19,6 +19,7 @@ import { CodeLensLocations, IConfig, LineHighlightLocations } from './configurat
|
|||||||
import { ApplicationInsightsKey, CommandContext, ExtensionKey, QualifiedExtensionId, setCommandContext, WorkspaceState } from './constants';
|
import { ApplicationInsightsKey, CommandContext, ExtensionKey, QualifiedExtensionId, setCommandContext, WorkspaceState } from './constants';
|
||||||
import { CodeLensController } from './codeLensController';
|
import { CodeLensController } from './codeLensController';
|
||||||
import { CurrentLineController, LineAnnotationType } from './currentLineController';
|
import { CurrentLineController, LineAnnotationType } from './currentLineController';
|
||||||
|
import { RemoteProviderFactory } from './git/remotes/factory';
|
||||||
import { GitContentProvider } from './gitContentProvider';
|
import { GitContentProvider } from './gitContentProvider';
|
||||||
import { GitExplorer } from './views/gitExplorer';
|
import { GitExplorer } from './views/gitExplorer';
|
||||||
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
||||||
@@ -33,6 +34,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
Logger.configure(context);
|
Logger.configure(context);
|
||||||
Messages.configure(context);
|
Messages.configure(context);
|
||||||
Telemetry.configure(ApplicationInsightsKey);
|
Telemetry.configure(ApplicationInsightsKey);
|
||||||
|
RemoteProviderFactory.configure(context);
|
||||||
|
|
||||||
const gitlens = extensions.getExtension(QualifiedExtensionId)!;
|
const gitlens = extensions.getExtension(QualifiedExtensionId)!;
|
||||||
const gitlensVersion = gitlens.packageJSON.version;
|
const gitlensVersion = gitlens.packageJSON.version;
|
||||||
@@ -103,6 +105,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
context.subscriptions.push(new DiffDirectoryCommand(git));
|
context.subscriptions.push(new DiffDirectoryCommand(git));
|
||||||
context.subscriptions.push(new DiffLineWithPreviousCommand(git));
|
context.subscriptions.push(new DiffLineWithPreviousCommand(git));
|
||||||
context.subscriptions.push(new DiffLineWithWorkingCommand(git));
|
context.subscriptions.push(new DiffLineWithWorkingCommand(git));
|
||||||
|
context.subscriptions.push(new DiffWithCommand(git));
|
||||||
context.subscriptions.push(new DiffWithBranchCommand(git));
|
context.subscriptions.push(new DiffWithBranchCommand(git));
|
||||||
context.subscriptions.push(new DiffWithNextCommand(git));
|
context.subscriptions.push(new DiffWithNextCommand(git));
|
||||||
context.subscriptions.push(new DiffWithPreviousCommand(git));
|
context.subscriptions.push(new DiffWithPreviousCommand(git));
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ import { Strings } from '../../system';
|
|||||||
import { GitCommit } from '../models/commit';
|
import { GitCommit } from '../models/commit';
|
||||||
import { Formatter, IFormatOptions } from './formatter';
|
import { Formatter, IFormatOptions } from './formatter';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { GlyphChars } from '../../constants';
|
||||||
|
|
||||||
export interface ICommitFormatOptions extends IFormatOptions {
|
export interface ICommitFormatOptions extends IFormatOptions {
|
||||||
|
truncateMessageAtNewLine?: boolean;
|
||||||
|
|
||||||
tokenOptions?: {
|
tokenOptions?: {
|
||||||
ago?: Strings.ITokenOptions;
|
ago?: Strings.ITokenOptions;
|
||||||
author?: Strings.ITokenOptions;
|
author?: Strings.ITokenOptions;
|
||||||
@@ -41,7 +44,14 @@ export class CommitFormatter extends Formatter<GitCommit, ICommitFormatOptions>
|
|||||||
}
|
}
|
||||||
|
|
||||||
get message() {
|
get message() {
|
||||||
const message = this._item.isUncommitted ? 'Uncommitted change' : this._item.message;
|
let message = this._item.isUncommitted ? 'Uncommitted change' : this._item.message;
|
||||||
|
if (this._options.truncateMessageAtNewLine) {
|
||||||
|
const index = message.indexOf('\n');
|
||||||
|
if (index !== -1) {
|
||||||
|
message = `${message.substring(0, index)}${GlyphChars.Space}${GlyphChars.Ellipsis}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this._padOrTruncate(message, this._options.tokenOptions!.message);
|
return this._padOrTruncate(message, this._options.tokenOptions!.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
109
src/git/git.ts
109
src/git/git.ts
@@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
import { Strings } from '../system';
|
||||||
import { findGitPath, IGit } from './gitLocator';
|
import { findGitPath, IGit } from './gitLocator';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { spawnPromise } from 'spawn-rx';
|
import { spawnPromise } from 'spawn-rx';
|
||||||
@@ -38,38 +39,49 @@ const GitWarnings = [
|
|||||||
/no upstream configured for branch/
|
/no upstream configured for branch/
|
||||||
];
|
];
|
||||||
|
|
||||||
async function gitCommand(options: { cwd: string, encoding?: string, onError?: (ex: Error) => string | undefined }, ...args: any[]) {
|
interface GitCommandOptions {
|
||||||
|
cwd: string;
|
||||||
|
encoding?: string;
|
||||||
|
overrideErrorHandling?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function gitCommand(options: GitCommandOptions, ...args: any[]): Promise<string> {
|
||||||
|
if (options.overrideErrorHandling) return gitCommandCore(options, ...args);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fixes https://github.com/eamodio/vscode-gitlens/issues/73
|
return await gitCommandCore(options, ...args);
|
||||||
// See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x
|
|
||||||
args.splice(0, 0, '-c', 'core.quotepath=false');
|
|
||||||
|
|
||||||
const opts = { encoding: 'utf8', ...options };
|
|
||||||
const s = await spawnPromise(git.path, args, { cwd: options.cwd, encoding: (opts.encoding === 'utf8') ? 'utf8' : 'binary' });
|
|
||||||
Logger.log('git', ...args, ` cwd='${options.cwd}'`);
|
|
||||||
if (opts.encoding === 'utf8' || opts.encoding === 'binary') return s;
|
|
||||||
|
|
||||||
return iconv.decode(Buffer.from(s, 'binary'), opts.encoding);
|
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
if (options.onError !== undefined) {
|
return gitCommandDefaultErrorHandler(ex, options, ...args);
|
||||||
const result = options.onError(ex);
|
}
|
||||||
if (result !== undefined) return result;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const msg = ex && ex.toString();
|
async function gitCommandCore(options: GitCommandOptions, ...args: any[]): Promise<string> {
|
||||||
if (msg) {
|
// Fixes https://github.com/eamodio/vscode-gitlens/issues/73
|
||||||
for (const warning of GitWarnings) {
|
// See https://stackoverflow.com/questions/4144417/how-to-handle-asian-characters-in-file-names-in-git-on-os-x
|
||||||
if (warning.test(msg)) {
|
args.splice(0, 0, '-c', 'core.quotepath=false');
|
||||||
Logger.warn('git', ...args, ` cwd='${options.cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
|
||||||
return '';
|
const opts = { encoding: 'utf8', ...options };
|
||||||
}
|
const s = await spawnPromise(git.path, args, { cwd: options.cwd, encoding: (opts.encoding === 'utf8') ? 'utf8' : 'binary' });
|
||||||
|
Logger.log('git', ...args, ` cwd='${options.cwd}'`);
|
||||||
|
if (opts.encoding === 'utf8' || opts.encoding === 'binary') return s;
|
||||||
|
|
||||||
|
return iconv.decode(Buffer.from(s, 'binary'), opts.encoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
function gitCommandDefaultErrorHandler(ex: Error, options: GitCommandOptions, ...args: any[]): string {
|
||||||
|
const msg = ex && ex.toString();
|
||||||
|
if (msg) {
|
||||||
|
for (const warning of GitWarnings) {
|
||||||
|
if (warning.test(msg)) {
|
||||||
|
Logger.warn('git', ...args, ` cwd='${options.cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.error(ex, 'git', ...args, ` cwd='${options.cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
|
||||||
throw ex;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.error(ex, 'git', ...args, ` cwd='${options.cwd}'`, msg && `\n ${msg.replace(/\r?\n|\r/g, ' ')}`);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Git {
|
export class Git {
|
||||||
@@ -98,8 +110,9 @@ export class Git {
|
|||||||
|
|
||||||
static async getVersionedFile(repoPath: string | undefined, fileName: string, branchOrSha: string) {
|
static async getVersionedFile(repoPath: string | undefined, fileName: string, branchOrSha: string) {
|
||||||
const data = await Git.show(repoPath, fileName, branchOrSha, 'binary');
|
const data = await Git.show(repoPath, fileName, branchOrSha, 'binary');
|
||||||
|
if (data === undefined) return undefined;
|
||||||
|
|
||||||
const suffix = Git.isSha(branchOrSha) ? branchOrSha.substring(0, 8) : branchOrSha;
|
const suffix = Strings.truncate(Strings.sanitizeForFS(Git.isSha(branchOrSha) ? Git.shortenSha(branchOrSha) : branchOrSha), 50, '');
|
||||||
const ext = path.extname(fileName);
|
const ext = path.extname(fileName);
|
||||||
return new Promise<string>((resolve, reject) => {
|
return new Promise<string>((resolve, reject) => {
|
||||||
tmp.file({ prefix: `${path.basename(fileName, ext)}-${suffix}__`, postfix: ext },
|
tmp.file({ prefix: `${path.basename(fileName, ext)}-${suffix}__`, postfix: ext },
|
||||||
@@ -134,6 +147,10 @@ export class Git {
|
|||||||
return fileName && fileName.replace(/\\/g, '/');
|
return fileName && fileName.replace(/\\/g, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static shortenSha(sha: string) {
|
||||||
|
return sha.substring(0, 8);
|
||||||
|
}
|
||||||
|
|
||||||
static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] {
|
static splitPath(fileName: string, repoPath: string | undefined, extract: boolean = true): [string, string] {
|
||||||
if (repoPath) {
|
if (repoPath) {
|
||||||
fileName = this.normalizePath(fileName);
|
fileName = this.normalizePath(fileName);
|
||||||
@@ -184,16 +201,20 @@ export class Git {
|
|||||||
return gitCommand({ cwd: repoPath }, ...params);
|
return gitCommand({ cwd: repoPath }, ...params);
|
||||||
}
|
}
|
||||||
|
|
||||||
static branch_current(repoPath: string) {
|
static async branch_current(repoPath: string) {
|
||||||
const params = [`rev-parse`, `--abbrev-ref`, `--symbolic-full-name`, `@`, `@{u}`];
|
const params = [`rev-parse`, `--abbrev-ref`, `--symbolic-full-name`, `@`, `@{u}`];
|
||||||
const onError = (ex: Error) => {
|
|
||||||
|
const opts = { cwd: repoPath, overrideErrorHandling: true };
|
||||||
|
try {
|
||||||
|
return await gitCommand(opts, ...params);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
if (/no upstream configured for branch/.test(ex && ex.toString())) {
|
if (/no upstream configured for branch/.test(ex && ex.toString())) {
|
||||||
return ex.message.split('\n')[0];
|
return ex.message.split('\n')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return undefined;
|
return gitCommandDefaultErrorHandler(ex, opts, ...params);
|
||||||
};
|
}
|
||||||
return gitCommand({ cwd: repoPath, onError: onError }, ...params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static checkout(repoPath: string, fileName: string, sha: string) {
|
static checkout(repoPath: string, fileName: string, sha: string) {
|
||||||
@@ -204,9 +225,9 @@ export class Git {
|
|||||||
|
|
||||||
static async config_get(key: string, repoPath?: string) {
|
static async config_get(key: string, repoPath?: string) {
|
||||||
try {
|
try {
|
||||||
return await gitCommand({ cwd: repoPath || '' }, `config`, `--get`, key);
|
return await gitCommand({ cwd: repoPath || '', overrideErrorHandling: true }, `config`, `--get`, key);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -310,9 +331,9 @@ export class Git {
|
|||||||
|
|
||||||
static async ls_files(repoPath: string, fileName: string): Promise<string> {
|
static async ls_files(repoPath: string, fileName: string): Promise<string> {
|
||||||
try {
|
try {
|
||||||
return await gitCommand({ cwd: repoPath }, 'ls-files', fileName);
|
return await gitCommand({ cwd: repoPath, overrideErrorHandling: true }, 'ls-files', fileName);
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -325,12 +346,24 @@ export class Git {
|
|||||||
return gitCommand({ cwd: repoPath }, 'remote', 'get-url', remote);
|
return gitCommand({ cwd: repoPath }, 'remote', 'get-url', remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
static show(repoPath: string | undefined, fileName: string, branchOrSha: string, encoding?: string) {
|
static async show(repoPath: string | undefined, fileName: string, branchOrSha: string, encoding?: string) {
|
||||||
const [file, root] = Git.splitPath(fileName, repoPath);
|
const [file, root] = Git.splitPath(fileName, repoPath);
|
||||||
branchOrSha = branchOrSha.replace('^', '');
|
branchOrSha = branchOrSha.replace('^', '');
|
||||||
|
|
||||||
if (Git.isUncommitted(branchOrSha)) return Promise.reject(new Error(`sha=${branchOrSha} is uncommitted`));
|
if (Git.isUncommitted(branchOrSha)) throw new Error(`sha=${branchOrSha} is uncommitted`);
|
||||||
return gitCommand({ cwd: root, encoding: encoding || defaultEncoding }, 'show', `${branchOrSha}:./${file}`);
|
|
||||||
|
const opts = { cwd: root, encoding: encoding || defaultEncoding, overrideErrorHandling: true };
|
||||||
|
const args = `${branchOrSha}:./${file}`;
|
||||||
|
try {
|
||||||
|
return await gitCommand(opts, 'show', args);
|
||||||
|
}
|
||||||
|
catch (ex) {
|
||||||
|
if (/Path \'.*?\' does not exist in/.test(ex && ex.toString())) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitCommandDefaultErrorHandler(ex, opts, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static stash_apply(repoPath: string, stashName: string, deleteAfter: boolean) {
|
static stash_apply(repoPath: string, stashName: string, deleteAfter: boolean) {
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ export class GitContextTracker extends Disposable {
|
|||||||
setCommandContext(CommandContext.IsRepository, !!this.git.repoPath);
|
setCommandContext(CommandContext.IsRepository, !!this.git.repoPath);
|
||||||
|
|
||||||
this._onConfigurationChanged();
|
this._onConfigurationChanged();
|
||||||
this._onActiveTextEditorChanged(window.activeTextEditor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
dispose() {
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ export class GitUri extends Uri {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get shortSha() {
|
get shortSha() {
|
||||||
return this.sha && this.sha.substring(0, 8);
|
return this.sha && GitService.shortenSha(this.sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
fileUri() {
|
fileUri() {
|
||||||
|
|||||||
@@ -13,11 +13,6 @@ export class GitBranch {
|
|||||||
this.remote = true;
|
this.remote = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const index = branch.indexOf(' ');
|
|
||||||
if (index !== -1) {
|
|
||||||
branch = branch.substring(0, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.current = current;
|
this.current = current;
|
||||||
this.name = branch;
|
this.name = branch;
|
||||||
this.tracking = tracking;
|
this.tracking = tracking;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class GitCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get shortSha() {
|
get shortSha() {
|
||||||
return this.sha.substring(0, 8);
|
return Git.shortenSha(this.sha);
|
||||||
}
|
}
|
||||||
|
|
||||||
get isUncommitted(): boolean {
|
get isUncommitted(): boolean {
|
||||||
@@ -62,7 +62,7 @@ export class GitCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get previousShortSha() {
|
get previousShortSha() {
|
||||||
return this.previousSha && this.previousSha.substring(0, 8);
|
return this.previousSha && Git.shortenSha(this.previousSha);
|
||||||
}
|
}
|
||||||
|
|
||||||
get previousUri(): Uri {
|
get previousUri(): Uri {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Uri } from 'vscode';
|
import { Uri } from 'vscode';
|
||||||
import { GitCommit, GitCommitType } from './commit';
|
import { GitCommit, GitCommitType } from './commit';
|
||||||
|
import { Git } from '../git';
|
||||||
import { GitStatusFileStatus, IGitStatusFile } from './status';
|
import { GitStatusFileStatus, IGitStatusFile } from './status';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ export class GitLogCommit extends GitCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get nextShortSha() {
|
get nextShortSha() {
|
||||||
return this.nextSha && this.nextSha.substring(0, 8);
|
return this.nextSha && Git.shortenSha(this.nextSha);
|
||||||
}
|
}
|
||||||
|
|
||||||
get nextUri(): Uri {
|
get nextUri(): Uri {
|
||||||
|
|||||||
47
src/git/remotes/bitbucket-server.ts
Normal file
47
src/git/remotes/bitbucket-server.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
'use strict';
|
||||||
|
import { Range } from 'vscode';
|
||||||
|
import { RemoteProvider } from './provider';
|
||||||
|
|
||||||
|
export class BitbucketServerService extends RemoteProvider {
|
||||||
|
|
||||||
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
||||||
|
super(domain, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return this.formatName('Bitbucket Server');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected get baseUrl() {
|
||||||
|
const [project, repo] = super.splitPath();
|
||||||
|
return `https://${this.domain}/projects/${project}/repos/${repo}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getUrlForBranches(): string {
|
||||||
|
return `${this.baseUrl}/branches`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getUrlForBranch(branch: string): string {
|
||||||
|
return `${this.baseUrl}/commits?until=${branch}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getUrlForCommit(sha: string): string {
|
||||||
|
return `${this.baseUrl}/commits/${sha}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
|
||||||
|
let line = '';
|
||||||
|
if (range) {
|
||||||
|
if (range.start.line === range.end.line) {
|
||||||
|
line = `#${range.start.line}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line = `#${range.start.line}-${range.end.line}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sha) return `${this.baseUrl}/browse/${fileName}?at=${sha}${line}`;
|
||||||
|
if (branch) return `${this.baseUrl}/browse/${fileName}?at=${branch}${line}`;
|
||||||
|
return `${this.baseUrl}/browse/${fileName}${line}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,12 +4,12 @@ import { RemoteProvider } from './provider';
|
|||||||
|
|
||||||
export class BitbucketService extends RemoteProvider {
|
export class BitbucketService extends RemoteProvider {
|
||||||
|
|
||||||
constructor(public domain: string, public path: string) {
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
||||||
super(domain, path);
|
super(domain, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return 'Bitbucket';
|
return this.formatName('Bitbucket');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getUrlForBranches(): string {
|
protected getUrlForBranches(): string {
|
||||||
|
|||||||
@@ -1,24 +1,66 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { RemoteProvider } from './provider';
|
import { ExtensionContext, workspace } from 'vscode';
|
||||||
import { BitbucketService } from './bitbucket';
|
import { BitbucketService } from './bitbucket';
|
||||||
|
import { BitbucketServerService } from './bitbucket-server';
|
||||||
|
import { CustomRemoteType, IConfig, IRemotesConfig } from '../../configuration';
|
||||||
|
import { ExtensionKey } from '../../constants';
|
||||||
import { GitHubService } from './github';
|
import { GitHubService } from './github';
|
||||||
import { GitLabService } from './gitlab';
|
import { GitLabService } from './gitlab';
|
||||||
import { VisualStudioService } from './visualStudio';
|
|
||||||
import { Logger } from '../../logger';
|
import { Logger } from '../../logger';
|
||||||
|
import { RemoteProvider } from './provider';
|
||||||
|
import { VisualStudioService } from './visualStudio';
|
||||||
|
import { Objects } from '../../system';
|
||||||
|
|
||||||
export { RemoteProvider };
|
export { RemoteProvider };
|
||||||
|
|
||||||
const providerMap = new Map<string, (domain: string, path: string) => RemoteProvider>([
|
const UrlRegex = /^(?:git:\/\/(.*?)\/|https:\/\/(.*?)\/|http:\/\/(.*?)\/|git@(.*):|ssh:\/\/(?:.*@)?(.*?)(?::.*?)?\/)(.*)$/;
|
||||||
|
|
||||||
|
function getCustomProvider(type: CustomRemoteType) {
|
||||||
|
switch (type) {
|
||||||
|
case CustomRemoteType.Bitbucket: return (domain: string, path: string) => new BitbucketService(domain, path, true);
|
||||||
|
case CustomRemoteType.BitbucketServer: return (domain: string, path: string) => new BitbucketServerService(domain, path, true);
|
||||||
|
case CustomRemoteType.GitHub: return (domain: string, path: string) => new GitHubService(domain, path, true);
|
||||||
|
case CustomRemoteType.GitLab: return (domain: string, path: string) => new GitLabService(domain, path, true);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultProviderMap = new Map<string, (domain: string, path: string) => RemoteProvider>([
|
||||||
['bitbucket.org', (domain: string, path: string) => new BitbucketService(domain, path)],
|
['bitbucket.org', (domain: string, path: string) => new BitbucketService(domain, path)],
|
||||||
['github.com', (domain: string, path: string) => new GitHubService(domain, path)],
|
['github.com', (domain: string, path: string) => new GitHubService(domain, path)],
|
||||||
['gitlab.com', (domain: string, path: string) => new GitLabService(domain, path)],
|
['gitlab.com', (domain: string, path: string) => new GitLabService(domain, path)],
|
||||||
['visualstudio.com', (domain: string, path: string) => new VisualStudioService(domain, path)]
|
['visualstudio.com', (domain: string, path: string) => new VisualStudioService(domain, path)]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const UrlRegex = /^(?:git:\/\/(.*?)\/|https:\/\/(.*?)\/|http:\/\/(.*?)\/|git@(.*):|ssh:\/\/(?:.*@)?(.*?)(?::.*?)?\/)(.*)$/;
|
let providerMap: Map<string, (domain: string, path: string) => RemoteProvider>;
|
||||||
|
let remotesCfg: IRemotesConfig[];
|
||||||
|
|
||||||
|
function onConfigurationChanged() {
|
||||||
|
const cfg = workspace.getConfiguration().get<IConfig>(ExtensionKey);
|
||||||
|
if (cfg === undefined) return;
|
||||||
|
|
||||||
|
if (!Objects.areEquivalent(cfg.remotes, remotesCfg)) {
|
||||||
|
providerMap = new Map(defaultProviderMap);
|
||||||
|
|
||||||
|
remotesCfg = cfg.remotes;
|
||||||
|
if (remotesCfg != null && remotesCfg.length > 0) {
|
||||||
|
for (const svc of remotesCfg) {
|
||||||
|
const provider = getCustomProvider(svc.type);
|
||||||
|
if (provider === undefined) continue;
|
||||||
|
|
||||||
|
providerMap.set(svc.domain.toLowerCase(), provider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export class RemoteProviderFactory {
|
export class RemoteProviderFactory {
|
||||||
|
|
||||||
|
static configure(context: ExtensionContext) {
|
||||||
|
context.subscriptions.push(workspace.onDidChangeConfiguration(onConfigurationChanged));
|
||||||
|
onConfigurationChanged();
|
||||||
|
}
|
||||||
|
|
||||||
static getRemoteProvider(url: string): RemoteProvider | undefined {
|
static getRemoteProvider(url: string): RemoteProvider | undefined {
|
||||||
try {
|
try {
|
||||||
const match = UrlRegex.exec(url);
|
const match = UrlRegex.exec(url);
|
||||||
@@ -32,7 +74,7 @@ export class RemoteProviderFactory {
|
|||||||
: domain;
|
: domain;
|
||||||
|
|
||||||
const creator = providerMap.get(key.toLowerCase());
|
const creator = providerMap.get(key.toLowerCase());
|
||||||
if (!creator) return undefined;
|
if (creator === undefined) return undefined;
|
||||||
|
|
||||||
return creator(domain, path);
|
return creator(domain, path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import { RemoteProvider } from './provider';
|
|||||||
|
|
||||||
export class GitHubService extends RemoteProvider {
|
export class GitHubService extends RemoteProvider {
|
||||||
|
|
||||||
constructor(public domain: string, public path: string) {
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
||||||
super(domain, path);
|
super(domain, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return 'GitHub';
|
return this.formatName('GitHub');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getUrlForBranches(): string {
|
protected getUrlForBranches(): string {
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ import { GitHubService } from './github';
|
|||||||
|
|
||||||
export class GitLabService extends GitHubService {
|
export class GitLabService extends GitHubService {
|
||||||
|
|
||||||
constructor(public domain: string, public path: string) {
|
constructor(public domain: string, public path: string, public custom: boolean = false) {
|
||||||
super(domain, path);
|
super(domain, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
return 'GitLab';
|
return this.formatName('GitLab');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ export function getNameFromRemoteResource(resource: RemoteResource) {
|
|||||||
|
|
||||||
export abstract class RemoteProvider {
|
export abstract class RemoteProvider {
|
||||||
|
|
||||||
constructor(public domain: string, public path: string) { }
|
constructor(public domain: string, public path: string, public custom: boolean = false) { }
|
||||||
|
|
||||||
abstract get name(): string;
|
abstract get name(): string;
|
||||||
|
|
||||||
@@ -34,6 +34,15 @@ export abstract class RemoteProvider {
|
|||||||
return `https://${this.domain}/${this.path}`;
|
return `https://${this.domain}/${this.path}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected formatName(name: string) {
|
||||||
|
return `${name}${this.custom ? ` (${this.domain})` : ''}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected splitPath(): [string, string] {
|
||||||
|
const index = this.path.indexOf('/');
|
||||||
|
return [ this.path.substring(0, index), this.path.substring(index + 1) ];
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract getUrlForBranches(): string;
|
protected abstract getUrlForBranches(): string;
|
||||||
protected abstract getUrlForBranch(branch: string): string;
|
protected abstract getUrlForBranch(branch: string): string;
|
||||||
protected abstract getUrlForCommit(sha: string): string;
|
protected abstract getUrlForCommit(sha: string): string;
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ export class GitContentProvider implements TextDocumentContentProvider {
|
|||||||
const data = GitService.fromGitContentUri(uri);
|
const data = GitService.fromGitContentUri(uri);
|
||||||
const fileName = data.originalFileName || data.fileName;
|
const fileName = data.originalFileName || data.fileName;
|
||||||
try {
|
try {
|
||||||
let text = await this.git.getVersionedFileText(data.repoPath, fileName, data.sha);
|
let text = data.sha !== GitService.fakeSha
|
||||||
|
? await this.git.getVersionedFileText(data.repoPath, fileName, data.sha)
|
||||||
|
: '';
|
||||||
if (data.decoration) {
|
if (data.decoration) {
|
||||||
text = `${data.decoration}\n${text}`;
|
text = `${data.decoration}\n${text}`;
|
||||||
}
|
}
|
||||||
@@ -23,7 +25,7 @@ export class GitContentProvider implements TextDocumentContentProvider {
|
|||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'GitContentProvider', 'getVersionedFileText');
|
Logger.error(ex, 'GitContentProvider', 'getVersionedFileText');
|
||||||
window.showErrorMessage(`Unable to show Git revision ${data.sha.substring(0, 8)} of '${path.relative(data.repoPath, fileName)}'`);
|
window.showErrorMessage(`Unable to show Git revision ${GitService.shortenSha(data.sha)} of '${path.relative(data.repoPath, fileName)}'`);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,8 @@ export const RepoChangedReasons = {
|
|||||||
|
|
||||||
export class GitService extends Disposable {
|
export class GitService extends Disposable {
|
||||||
|
|
||||||
|
static fakeSha = 'ffffffffffffffffffffffffffffffffffffffff';
|
||||||
|
|
||||||
private _onDidBlameFail = new EventEmitter<string>();
|
private _onDidBlameFail = new EventEmitter<string>();
|
||||||
get onDidBlameFail(): Event<string> {
|
get onDidBlameFail(): Event<string> {
|
||||||
return this._onDidBlameFail.event;
|
return this._onDidBlameFail.event;
|
||||||
@@ -96,7 +98,6 @@ export class GitService extends Disposable {
|
|||||||
private _disposable: Disposable | undefined;
|
private _disposable: Disposable | undefined;
|
||||||
private _gitignore: Promise<ignore.Ignore | undefined>;
|
private _gitignore: Promise<ignore.Ignore | undefined>;
|
||||||
private _repoWatcher: FileSystemWatcher | undefined;
|
private _repoWatcher: FileSystemWatcher | undefined;
|
||||||
private _stashWatcher: FileSystemWatcher | undefined;
|
|
||||||
|
|
||||||
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
|
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
|
||||||
|
|
||||||
@@ -125,9 +126,6 @@ export class GitService extends Disposable {
|
|||||||
this._repoWatcher && this._repoWatcher.dispose();
|
this._repoWatcher && this._repoWatcher.dispose();
|
||||||
this._repoWatcher = undefined;
|
this._repoWatcher = undefined;
|
||||||
|
|
||||||
this._stashWatcher && this._stashWatcher.dispose();
|
|
||||||
this._stashWatcher = undefined;
|
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
this._remotesCache.clear();
|
this._remotesCache.clear();
|
||||||
this._uriCache.clear();
|
this._uriCache.clear();
|
||||||
@@ -147,8 +145,7 @@ export class GitService extends Disposable {
|
|||||||
if (cfg.advanced.caching.enabled) {
|
if (cfg.advanced.caching.enabled) {
|
||||||
this._cacheDisposable && this._cacheDisposable.dispose();
|
this._cacheDisposable && this._cacheDisposable.dispose();
|
||||||
|
|
||||||
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/index', true, false, true);
|
this._repoWatcher = this._repoWatcher || workspace.createFileSystemWatcher('**/.git/{index,HEAD,refs/stash,refs/heads/**,refs/remotes/**}');
|
||||||
this._stashWatcher = this._stashWatcher || workspace.createFileSystemWatcher('**/.git/refs/stash', true, false, true);
|
|
||||||
|
|
||||||
const disposables: Disposable[] = [];
|
const disposables: Disposable[] = [];
|
||||||
|
|
||||||
@@ -156,7 +153,6 @@ export class GitService extends Disposable {
|
|||||||
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
|
disposables.push(workspace.onDidChangeTextDocument(this._onTextDocumentChanged, this));
|
||||||
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
|
disposables.push(workspace.onDidSaveTextDocument(d => this._removeCachedEntry(d, RemoveCacheReason.DocumentSaved)));
|
||||||
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
|
disposables.push(this._repoWatcher.onDidChange(this._onRepoChanged, this));
|
||||||
disposables.push(this._stashWatcher.onDidChange(this._onStashChanged, this));
|
|
||||||
|
|
||||||
this._cacheDisposable = Disposable.from(...disposables);
|
this._cacheDisposable = Disposable.from(...disposables);
|
||||||
}
|
}
|
||||||
@@ -167,9 +163,6 @@ export class GitService extends Disposable {
|
|||||||
this._repoWatcher && this._repoWatcher.dispose();
|
this._repoWatcher && this._repoWatcher.dispose();
|
||||||
this._repoWatcher = undefined;
|
this._repoWatcher = undefined;
|
||||||
|
|
||||||
this._stashWatcher && this._stashWatcher.dispose();
|
|
||||||
this._stashWatcher = undefined;
|
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
this._remotesCache.clear();
|
this._remotesCache.clear();
|
||||||
}
|
}
|
||||||
@@ -216,17 +209,19 @@ export class GitService extends Disposable {
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onRepoChanged() {
|
private _onRepoChanged(uri: Uri) {
|
||||||
|
if (uri !== undefined && uri.path.endsWith('ref/stash')) {
|
||||||
|
this._fireRepoChange('stash');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this._gitCache.clear();
|
this._gitCache.clear();
|
||||||
|
|
||||||
this._fireRepoChange();
|
this._fireRepoChange();
|
||||||
this._fireGitCacheChange();
|
this._fireGitCacheChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onStashChanged() {
|
|
||||||
this._fireRepoChange('stash');
|
|
||||||
}
|
|
||||||
|
|
||||||
private _fireGitCacheChangeDebounced: (() => void) | undefined = undefined;
|
private _fireGitCacheChangeDebounced: (() => void) | undefined = undefined;
|
||||||
|
|
||||||
private _fireGitCacheChange() {
|
private _fireGitCacheChange() {
|
||||||
@@ -961,6 +956,8 @@ export class GitService extends Disposable {
|
|||||||
Logger.log(`getVersionedFile('${repoPath}', '${fileName}', ${sha})`);
|
Logger.log(`getVersionedFile('${repoPath}', '${fileName}', ${sha})`);
|
||||||
|
|
||||||
const file = await Git.getVersionedFile(repoPath, fileName, sha);
|
const file = await Git.getVersionedFile(repoPath, fileName, sha);
|
||||||
|
if (file === undefined) return undefined;
|
||||||
|
|
||||||
const cacheKey = this.getCacheEntryKey(file);
|
const cacheKey = this.getCacheEntryKey(file);
|
||||||
const entry = new UriCacheEntry(new GitUri(Uri.file(fileName), { sha, repoPath: repoPath!, fileName }));
|
const entry = new UriCacheEntry(new GitUri(Uri.file(fileName), { sha, repoPath: repoPath!, fileName }));
|
||||||
this._uriCache.set(cacheKey, entry);
|
this._uriCache.set(cacheKey, entry);
|
||||||
@@ -1068,11 +1065,17 @@ export class GitService extends Disposable {
|
|||||||
return Git.normalizePath(fileName, repoPath);
|
return Git.normalizePath(fileName, repoPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static toGitContentUri(sha: string, shortSha: string, fileName: string, repoPath: string, originalFileName?: string): Uri;
|
static shortenSha(sha: string | undefined) {
|
||||||
|
if (sha === undefined) return undefined;
|
||||||
|
return Git.shortenSha(sha);
|
||||||
|
}
|
||||||
|
|
||||||
|
static toGitContentUri(sha: string, fileName: string, repoPath: string, originalFileName?: string): Uri;
|
||||||
static toGitContentUri(commit: GitCommit): Uri;
|
static toGitContentUri(commit: GitCommit): Uri;
|
||||||
static toGitContentUri(uri: GitUri): Uri;
|
static toGitContentUri(uri: GitUri): Uri;
|
||||||
static toGitContentUri(shaOrcommitOrUri: string | GitCommit | GitUri, shortSha?: string, fileName?: string, repoPath?: string, originalFileName?: string): Uri {
|
static toGitContentUri(shaOrcommitOrUri: string | GitCommit | GitUri, fileName?: string, repoPath?: string, originalFileName?: string): Uri {
|
||||||
let data: IGitUriData;
|
let data: IGitUriData;
|
||||||
|
let shortSha: string | undefined;
|
||||||
if (typeof shaOrcommitOrUri === 'string') {
|
if (typeof shaOrcommitOrUri === 'string') {
|
||||||
data = GitService._toGitUriData({
|
data = GitService._toGitUriData({
|
||||||
sha: shaOrcommitOrUri,
|
sha: shaOrcommitOrUri,
|
||||||
@@ -1080,6 +1083,7 @@ export class GitService extends Disposable {
|
|||||||
repoPath: repoPath!,
|
repoPath: repoPath!,
|
||||||
originalFileName: originalFileName
|
originalFileName: originalFileName
|
||||||
});
|
});
|
||||||
|
shortSha = GitService.shortenSha(shaOrcommitOrUri);
|
||||||
}
|
}
|
||||||
else if (shaOrcommitOrUri instanceof GitCommit) {
|
else if (shaOrcommitOrUri instanceof GitCommit) {
|
||||||
data = GitService._toGitUriData(shaOrcommitOrUri, undefined, shaOrcommitOrUri.originalFileName);
|
data = GitService._toGitUriData(shaOrcommitOrUri, undefined, shaOrcommitOrUri.originalFileName);
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ export class Messages {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
static showCommitHasNoPreviousCommitWarningMessage(commit: GitCommit): Promise<string | undefined> {
|
static showCommitHasNoPreviousCommitWarningMessage(commit?: GitCommit): Promise<string | undefined> {
|
||||||
|
if (commit === undefined) return Messages._showMessage('info', `Commit has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
|
||||||
return Messages._showMessage('info', `Commit ${commit.shortSha} (${commit.author}, ${moment(commit.date).fromNow()}) has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
|
return Messages._showMessage('info', `Commit ${commit.shortSha} (${commit.author}, ${moment(commit.date).fromNow()}) has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,14 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
|
|||||||
const description = GitStatusFile.getFormattedDirectory(status, true);
|
const description = GitStatusFile.getFormattedDirectory(status, true);
|
||||||
|
|
||||||
let sha;
|
let sha;
|
||||||
let shortSha;
|
|
||||||
if (status.status === 'D') {
|
if (status.status === 'D') {
|
||||||
sha = commit.previousSha!;
|
sha = commit.previousSha!;
|
||||||
shortSha = commit.previousShortSha!;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sha = commit.sha;
|
sha = commit.sha;
|
||||||
shortSha = commit.shortSha;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
super(GitService.toGitContentUri(sha, shortSha, status.fileName, commit.repoPath, status.originalFileName), {
|
super(GitService.toGitContentUri(sha, status.fileName, commit.repoPath, status.originalFileName), {
|
||||||
label: `${Strings.pad(octicon, 4, 2)} ${path.basename(status.fileName)}`,
|
label: `${Strings.pad(octicon, 4, 2)} ${path.basename(status.fileName)}`,
|
||||||
description: description
|
description: description
|
||||||
});
|
});
|
||||||
@@ -48,7 +45,7 @@ export class CommitWithFileStatusQuickPickItem extends OpenFileCommandQuickPickI
|
|||||||
originalFileName: status.originalFileName
|
originalFileName: status.originalFileName
|
||||||
} as IGitCommitInfo);
|
} as IGitCommitInfo);
|
||||||
this.sha = sha;
|
this.sha = sha;
|
||||||
this.shortSha = shortSha;
|
this.shortSha = GitService.shortenSha(sha)!;
|
||||||
this.status = status.status;
|
this.status = status.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +85,7 @@ export class OpenCommitFileRevisionsCommandQuickPickItem extends OpenFilesComman
|
|||||||
constructor(commit: GitLogCommit, item?: QuickPickItem) {
|
constructor(commit: GitLogCommit, item?: QuickPickItem) {
|
||||||
const uris = commit.fileStatuses
|
const uris = commit.fileStatuses
|
||||||
.filter(s => s.status !== 'D')
|
.filter(s => s.status !== 'D')
|
||||||
.map(s => GitService.toGitContentUri(commit.sha, commit.shortSha, s.fileName, commit.repoPath, s.originalFileName));
|
.map(s => GitService.toGitContentUri(commit.sha, s.fileName, commit.repoPath, s.originalFileName));
|
||||||
|
|
||||||
super(uris, item || {
|
super(uris, item || {
|
||||||
label: `$(file-symlink-file) Open Changed Revisions`,
|
label: `$(file-symlink-file) Open Changed Revisions`,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class OpenCommitFileRevisionCommandQuickPickItem extends OpenFileCommandQ
|
|||||||
let description: string;
|
let description: string;
|
||||||
let uri: Uri;
|
let uri: Uri;
|
||||||
if (commit.status === 'D') {
|
if (commit.status === 'D') {
|
||||||
uri = GitService.toGitContentUri(commit.previousSha!, commit.previousShortSha!, commit.previousFileName!, commit.repoPath, undefined);
|
uri = GitService.toGitContentUri(commit.previousSha!, commit.previousFileName!, commit.repoPath, undefined);
|
||||||
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)} in ${GlyphChars.Space}$(git-commit) ${commit.previousShortSha} (deleted in ${GlyphChars.Space}$(git-commit) ${commit.shortSha})`;
|
description = `${Strings.pad(GlyphChars.Dash, 2, 3)} ${path.basename(commit.fileName)} in ${GlyphChars.Space}$(git-commit) ${commit.previousShortSha} (deleted in ${GlyphChars.Space}$(git-commit) ${commit.shortSha})`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { QuickPickOptions, window } from 'vscode';
|
|||||||
import { Commands, OpenInRemoteCommandArgs } from '../commands';
|
import { Commands, OpenInRemoteCommandArgs } from '../commands';
|
||||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common';
|
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut } from './common';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { getNameFromRemoteResource, GitLogCommit, GitRemote, RemoteResource } from '../gitService';
|
import { getNameFromRemoteResource, GitLogCommit, GitRemote, GitService, RemoteResource } from '../gitService';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class OpenRemoteCommandQuickPickItem extends CommandQuickPickItem {
|
export class OpenRemoteCommandQuickPickItem extends CommandQuickPickItem {
|
||||||
@@ -43,7 +43,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'commit':
|
case 'commit':
|
||||||
const shortSha = resource.sha.substring(0, 8);
|
const shortSha = GitService.shortenSha(resource.sha);
|
||||||
description = `$(git-commit) ${shortSha}`;
|
description = `$(git-commit) ${shortSha}`;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export class OpenRemotesCommandQuickPickItem extends CommandQuickPickItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const shortFileSha = resource.sha === undefined ? '' : resource.sha.substring(0, 8);
|
const shortFileSha = resource.sha === undefined ? '' : GitService.shortenSha(resource.sha);
|
||||||
description = `$(file-text) ${path.basename(resource.fileName)}${shortFileSha ? ` in ${GlyphChars.Space}$(git-commit) ${shortFileSha}` : ''}`;
|
description = `$(file-text) ${path.basename(resource.fileName)}${shortFileSha ? ` in ${GlyphChars.Space}$(git-commit) ${shortFileSha}` : ''}`;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { commands, QuickPickOptions, TextDocumentShowOptions, Uri, window } from
|
|||||||
import { Commands, DiffWithWorkingCommandArgs, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
|
import { Commands, DiffWithWorkingCommandArgs, OpenChangedFilesCommandArgs, ShowQuickBranchHistoryCommandArgs, ShowQuickRepoStatusCommandArgs, ShowQuickStashListCommandArgs } from '../commands';
|
||||||
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common';
|
import { CommandQuickPickItem, getQuickPickIgnoreFocusOut, OpenFileCommandQuickPickItem, QuickPickItem } from './common';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { GitStatus, GitStatusFile, GitUri } from '../gitService';
|
import { GitService, GitStatus, GitStatusFile, GitUri } from '../gitService';
|
||||||
import { Keyboard, Keys } from '../keyboard';
|
import { Keyboard, Keys } from '../keyboard';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ export class RepoStatusQuickPick {
|
|||||||
if (status.upstream && status.state.behind) {
|
if (status.upstream && status.state.behind) {
|
||||||
items.splice(0, 0, new CommandQuickPickItem({
|
items.splice(0, 0, new CommandQuickPickItem({
|
||||||
label: `$(cloud-download)${GlyphChars.Space} ${status.state.behind} Commit${status.state.behind > 1 ? 's' : ''} behind ${GlyphChars.Space}$(git-branch) ${status.upstream}`,
|
label: `$(cloud-download)${GlyphChars.Space} ${status.state.behind} Commit${status.state.behind > 1 ? 's' : ''} behind ${GlyphChars.Space}$(git-branch) ${status.upstream}`,
|
||||||
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.upstream} but not ${GlyphChars.Space}$(git-branch) ${status.branch}${status.sha ? ` (since ${GlyphChars.Space}$(git-commit) ${status.sha.substring(0, 8)})` : ''}`
|
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} shows commits in ${GlyphChars.Space}$(git-branch) ${status.upstream} but not ${GlyphChars.Space}$(git-branch) ${status.branch}${status.sha ? ` (since ${GlyphChars.Space}$(git-commit) ${GitService.shortenSha(status.sha)})` : ''}`
|
||||||
}, Commands.ShowQuickBranchHistory, [
|
}, Commands.ShowQuickBranchHistory, [
|
||||||
new GitUri(Uri.file(status.repoPath), { fileName: '', repoPath: status.repoPath, sha: `${status.branch}..${status.upstream}` }),
|
new GitUri(Uri.file(status.repoPath), { fileName: '', repoPath: status.repoPath, sha: `${status.branch}..${status.upstream}` }),
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -101,12 +101,20 @@ export namespace Strings {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function truncate(s: string, truncateTo?: number) {
|
// Removes \ / : * ? " < > | and C0 and C1 control codes
|
||||||
if (!s || truncateTo === undefined) return s;
|
const illegalCharsForFSRegEx = /[\\/:*?"<>|\x00-\x1f\x80-\x9f]/g;
|
||||||
|
|
||||||
|
export function sanitizeForFS(s: string, replacement: string = '_') {
|
||||||
|
if (!s) return s;
|
||||||
|
return s.replace(illegalCharsForFSRegEx, replacement);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function truncate(s: string, truncateTo: number, ellipsis: string = '\u2026') {
|
||||||
|
if (!s) return s;
|
||||||
|
|
||||||
const len = getWidth(s);
|
const len = getWidth(s);
|
||||||
if (len <= truncateTo) return s;
|
if (len <= truncateTo) return s;
|
||||||
if (len === s.length) return `${s.substring(0, truncateTo - 1)}\u2026`;
|
if (len === s.length) return `${s.substring(0, truncateTo - 1)}${ellipsis}`;
|
||||||
|
|
||||||
// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated
|
// Skip ahead to start as far as we can by assuming all the double-width characters won't be truncated
|
||||||
let chars = Math.floor(truncateTo / (len / s.length));
|
let chars = Math.floor(truncateTo / (len / s.length));
|
||||||
@@ -119,6 +127,6 @@ export namespace Strings {
|
|||||||
chars--;
|
chars--;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${s.substring(0, chars)}\u2026`;
|
return `${s.substring(0, chars)}${ellipsis}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,22 +3,27 @@ import { Iterables } from '../system';
|
|||||||
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||||
import { CommitNode } from './commitNode';
|
import { CommitNode } from './commitNode';
|
||||||
import { GlyphChars } from '../constants';
|
import { GlyphChars } from '../constants';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType, ShowAllCommitsNode } from './explorerNode';
|
||||||
import { GitBranch, GitService, GitUri } from '../gitService';
|
import { GitBranch, GitService, GitUri } from '../gitService';
|
||||||
|
|
||||||
export class BranchHistoryNode extends ExplorerNode {
|
export class BranchHistoryNode extends ExplorerNode {
|
||||||
|
|
||||||
readonly resourceType: ResourceType = 'gitlens:branch-history';
|
readonly resourceType: ResourceType = 'gitlens:branch-history';
|
||||||
|
|
||||||
|
maxCount: number | undefined = undefined;
|
||||||
|
|
||||||
constructor(public readonly branch: GitBranch, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
constructor(public readonly branch: GitBranch, uri: GitUri, private readonly template: string, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
||||||
super(uri);
|
super(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getChildren(): Promise<ExplorerNode[]> {
|
async getChildren(): Promise<ExplorerNode[]> {
|
||||||
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name);
|
const log = await this.git.getLogForRepo(this.uri.repoPath!, this.branch.name, this.maxCount);
|
||||||
if (log === undefined) return [];
|
if (log === undefined) return [];
|
||||||
|
|
||||||
return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git))];
|
const children = Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git));
|
||||||
|
if (!log.truncated) return [...children];
|
||||||
|
|
||||||
|
return [...children, new ShowAllCommitsNode(this, this.context)];
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTreeItem(): Promise<TreeItem> {
|
async getTreeItem(): Promise<TreeItem> {
|
||||||
@@ -27,7 +32,7 @@ export class BranchHistoryNode extends ExplorerNode {
|
|||||||
name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`;
|
name += ` ${GlyphChars.Space}${GlyphChars.ArrowLeftRight}${GlyphChars.Space} ${this.branch.tracking}`;
|
||||||
}
|
}
|
||||||
const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed);
|
const item = new TreeItem(`${this.branch!.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`, TreeItemCollapsibleState.Collapsed);
|
||||||
item.contextValue = this.resourceType;
|
item.contextValue = this.branch.tracking ? `${this.resourceType}:remote` : this.resourceType;
|
||||||
|
|
||||||
item.iconPath = {
|
item.iconPath = {
|
||||||
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
|
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ export class BranchesNode extends ExplorerNode {
|
|||||||
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
|
return [...Iterables.filterMap(branches, b => b.remote ? undefined : new BranchHistoryNode(b, this.uri, this.git.config.gitExplorer.commitFormat, this.context, this.git))];
|
||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
async getTreeItem(): Promise<TreeItem> {
|
||||||
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded);
|
const item = new TreeItem(`Branches`, TreeItemCollapsibleState.Expanded);
|
||||||
item.contextValue = this.resourceType;
|
|
||||||
|
const remotes = await this.git.getRemotes(this.uri.repoPath!);
|
||||||
|
item.contextValue = (remotes !== undefined && remotes.length > 0)
|
||||||
|
? `${this.resourceType}:remote`
|
||||||
|
: this.resourceType;
|
||||||
|
|
||||||
item.iconPath = {
|
item.iconPath = {
|
||||||
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
|
dark: this.context.asAbsolutePath('images/dark/icon-branch.svg'),
|
||||||
|
|||||||
@@ -40,16 +40,6 @@ export class CommitFileNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCommand(): Command | undefined {
|
getCommand(): Command | undefined {
|
||||||
let allowMissingPrevious = false;
|
|
||||||
let prefix = undefined;
|
|
||||||
if (this.status.status === 'A') {
|
|
||||||
allowMissingPrevious = true;
|
|
||||||
prefix = 'added in ';
|
|
||||||
}
|
|
||||||
else if (this.status.status === 'D') {
|
|
||||||
prefix = 'deleted in ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'Compare File with Previous Revision',
|
title: 'Compare File with Previous Revision',
|
||||||
command: Commands.DiffWithPrevious,
|
command: Commands.DiffWithPrevious,
|
||||||
@@ -61,9 +51,7 @@ export class CommitFileNode extends ExplorerNode {
|
|||||||
showOptions: {
|
showOptions: {
|
||||||
preserveFocus: true,
|
preserveFocus: true,
|
||||||
preview: true
|
preview: true
|
||||||
},
|
}
|
||||||
allowMissingPrevious: allowMissingPrevious,
|
|
||||||
rightTitlePrefix: prefix
|
|
||||||
} as DiffWithPreviousCommandArgs
|
} as DiffWithPreviousCommandArgs
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'v
|
|||||||
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
||||||
import { CommitFileNode } from './commitFileNode';
|
import { CommitFileNode } from './commitFileNode';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri } from '../gitService';
|
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri, ICommitFormatOptions } from '../gitService';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class CommitNode extends ExplorerNode {
|
export class CommitNode extends ExplorerNode {
|
||||||
@@ -28,7 +28,11 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, this.git.config.defaultDateFormat));
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dataFormat: this.git.config.defaultDateFormat
|
||||||
|
} as ICommitFormatOptions));
|
||||||
|
|
||||||
if (this.commit.type === 'file') {
|
if (this.commit.type === 'file') {
|
||||||
item.collapsibleState = TreeItemCollapsibleState.None;
|
item.collapsibleState = TreeItemCollapsibleState.None;
|
||||||
item.command = this.getCommand();
|
item.command = this.getCommand();
|
||||||
@@ -55,17 +59,6 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCommand(): Command | undefined {
|
getCommand(): Command | undefined {
|
||||||
let allowMissingPrevious = false;
|
|
||||||
let prefix = undefined;
|
|
||||||
const status = this.commit.fileStatuses[0];
|
|
||||||
if (status.status === 'A') {
|
|
||||||
allowMissingPrevious = true;
|
|
||||||
prefix = 'added in ';
|
|
||||||
}
|
|
||||||
else if (status.status === 'D') {
|
|
||||||
prefix = 'deleted in ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'Compare File with Previous Revision',
|
title: 'Compare File with Previous Revision',
|
||||||
command: Commands.DiffWithPrevious,
|
command: Commands.DiffWithPrevious,
|
||||||
@@ -77,9 +70,7 @@ export class CommitNode extends ExplorerNode {
|
|||||||
showOptions: {
|
showOptions: {
|
||||||
preserveFocus: true,
|
preserveFocus: true,
|
||||||
preview: true
|
preview: true
|
||||||
},
|
}
|
||||||
allowMissingPrevious: allowMissingPrevious,
|
|
||||||
rightTitlePrefix: prefix
|
|
||||||
} as DiffWithPreviousCommandArgs
|
} as DiffWithPreviousCommandArgs
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Command, Event, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||||
|
import { GlyphChars } from '../constants';
|
||||||
import { GitUri } from '../gitService';
|
import { GitUri } from '../gitService';
|
||||||
|
import { RefreshNodeCommandArgs } from './gitExplorer';
|
||||||
|
|
||||||
export declare type ResourceType =
|
export declare type ResourceType =
|
||||||
'gitlens:branches' |
|
'gitlens:branches' |
|
||||||
@@ -10,6 +12,7 @@ export declare type ResourceType =
|
|||||||
'gitlens:file-history' |
|
'gitlens:file-history' |
|
||||||
'gitlens:history' |
|
'gitlens:history' |
|
||||||
'gitlens:message' |
|
'gitlens:message' |
|
||||||
|
'gitlens:pager' |
|
||||||
'gitlens:remote' |
|
'gitlens:remote' |
|
||||||
'gitlens:remotes' |
|
'gitlens:remotes' |
|
||||||
'gitlens:repository' |
|
'gitlens:repository' |
|
||||||
@@ -31,10 +34,6 @@ export abstract class ExplorerNode {
|
|||||||
getCommand(): Command | undefined {
|
getCommand(): Command | undefined {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
onDidChangeTreeData?: Event<ExplorerNode>;
|
|
||||||
|
|
||||||
refresh?(): void;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MessageNode extends ExplorerNode {
|
export class MessageNode extends ExplorerNode {
|
||||||
@@ -55,3 +54,45 @@ export class MessageNode extends ExplorerNode {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class PagerNode extends ExplorerNode {
|
||||||
|
|
||||||
|
readonly resourceType: ResourceType = 'gitlens:pager';
|
||||||
|
args: RefreshNodeCommandArgs = {};
|
||||||
|
|
||||||
|
constructor(private message: string, private node: ExplorerNode, protected readonly context: ExtensionContext) {
|
||||||
|
super(new GitUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
getChildren(): ExplorerNode[] | Promise<ExplorerNode[]> {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
getTreeItem(): TreeItem | Promise<TreeItem> {
|
||||||
|
const item = new TreeItem(this.message, TreeItemCollapsibleState.None);
|
||||||
|
item.contextValue = this.resourceType;
|
||||||
|
item.command = this.getCommand();
|
||||||
|
item.iconPath = {
|
||||||
|
dark: this.context.asAbsolutePath('images/dark/icon-sync.svg'),
|
||||||
|
light: this.context.asAbsolutePath('images/light/icon-sync.svg')
|
||||||
|
};
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCommand(): Command | undefined {
|
||||||
|
return {
|
||||||
|
title: 'Refresh',
|
||||||
|
command: 'gitlens.gitExplorer.refreshNode',
|
||||||
|
arguments: [this.node, this.args]
|
||||||
|
} as Command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ShowAllCommitsNode extends PagerNode {
|
||||||
|
|
||||||
|
args: RefreshNodeCommandArgs = { maxCount: 0 };
|
||||||
|
|
||||||
|
constructor(node: ExplorerNode, context: ExtensionContext) {
|
||||||
|
super(`Show All Commits ${GlyphChars.Space}${GlyphChars.Dash}${GlyphChars.Space} this may take a while`, node, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ import { Commands, DiffWithPreviousCommandArgs, DiffWithWorkingCommandArgs, open
|
|||||||
import { UriComparer } from '../comparers';
|
import { UriComparer } from '../comparers';
|
||||||
import { ExtensionKey, IConfig } from '../configuration';
|
import { ExtensionKey, IConfig } from '../configuration';
|
||||||
import { CommandContext, setCommandContext } from '../constants';
|
import { CommandContext, setCommandContext } from '../constants';
|
||||||
import { CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoryNode, StashNode } from './explorerNodes';
|
import { BranchHistoryNode, CommitFileNode, CommitNode, ExplorerNode, HistoryNode, MessageNode, RepositoryNode, StashNode } from './explorerNodes';
|
||||||
import { GitService, GitUri, RepoChangedReasons } from '../gitService';
|
import { GitService, GitUri, RepoChangedReasons } from '../gitService';
|
||||||
|
|
||||||
export * from './explorerNodes';
|
export * from './explorerNodes';
|
||||||
@@ -23,6 +23,10 @@ export interface OpenFileRevisionCommandArgs {
|
|||||||
showOptions?: TextDocumentShowOptions;
|
showOptions?: TextDocumentShowOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface RefreshNodeCommandArgs {
|
||||||
|
maxCount?: number;
|
||||||
|
}
|
||||||
|
|
||||||
export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
||||||
|
|
||||||
private _config: IConfig;
|
private _config: IConfig;
|
||||||
@@ -38,6 +42,7 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
commands.registerCommand('gitlens.gitExplorer.switchToHistoryView', () => this.switchTo(GitExplorerView.History), this);
|
commands.registerCommand('gitlens.gitExplorer.switchToHistoryView', () => this.switchTo(GitExplorerView.History), this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.switchToRepositoryView', () => this.switchTo(GitExplorerView.Repository), this);
|
commands.registerCommand('gitlens.gitExplorer.switchToRepositoryView', () => this.switchTo(GitExplorerView.Repository), this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.refresh', this.refresh, this);
|
commands.registerCommand('gitlens.gitExplorer.refresh', this.refresh, this);
|
||||||
|
commands.registerCommand('gitlens.gitExplorer.refreshNode', this.refreshNode, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.openChanges', this.openChanges, this);
|
commands.registerCommand('gitlens.gitExplorer.openChanges', this.openChanges, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.openChangesWithWorking', this.openChangesWithWorking, this);
|
commands.registerCommand('gitlens.gitExplorer.openChangesWithWorking', this.openChangesWithWorking, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.openFile', this.openFile, this);
|
commands.registerCommand('gitlens.gitExplorer.openFile', this.openFile, this);
|
||||||
@@ -47,10 +52,11 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
commands.registerCommand('gitlens.gitExplorer.openChangedFileRevisions', this.openChangedFileRevisions, this);
|
||||||
commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this);
|
commands.registerCommand('gitlens.gitExplorer.applyChanges', this.applyChanges, this);
|
||||||
|
|
||||||
context.subscriptions.push(this.git.onDidChangeRepo(this.onRepoChanged, this));
|
const repoChangedFn = Functions.debounce(this.onRepoChanged, 250);
|
||||||
|
context.subscriptions.push(this.git.onDidChangeRepo(repoChangedFn, this));
|
||||||
|
|
||||||
const fn = Functions.debounce(this.onActiveEditorChanged, 500);
|
const editorChangedFn = Functions.debounce(this.onActiveEditorChanged, 500);
|
||||||
context.subscriptions.push(window.onDidChangeActiveTextEditor(fn, this));
|
context.subscriptions.push(window.onDidChangeActiveTextEditor(editorChangedFn, this));
|
||||||
context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
|
context.subscriptions.push(workspace.onDidChangeConfiguration(this.onConfigurationChanged, this));
|
||||||
|
|
||||||
this.onConfigurationChanged();
|
this.onConfigurationChanged();
|
||||||
@@ -132,6 +138,14 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
this._onDidChangeTreeData.fire(node);
|
this._onDidChangeTreeData.fire(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
refreshNode(node: ExplorerNode, args: RefreshNodeCommandArgs) {
|
||||||
|
if (node instanceof BranchHistoryNode) {
|
||||||
|
node.maxCount = args.maxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.refresh(node);
|
||||||
|
}
|
||||||
|
|
||||||
switchTo(view: GitExplorerView) {
|
switchTo(view: GitExplorerView) {
|
||||||
if (this._view === view) return;
|
if (this._view === view) return;
|
||||||
|
|
||||||
@@ -187,7 +201,7 @@ export class GitExplorer implements TreeDataProvider<ExplorerNode> {
|
|||||||
private async openChangedFileRevisions(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) {
|
private async openChangedFileRevisions(node: CommitNode | StashNode, options: TextDocumentShowOptions = { preserveFocus: false, preview: false }) {
|
||||||
const uris = node.commit.fileStatuses
|
const uris = node.commit.fileStatuses
|
||||||
.filter(s => s.status !== 'D')
|
.filter(s => s.status !== 'D')
|
||||||
.map(s => GitService.toGitContentUri(node.commit.sha, node.commit.shortSha, s.fileName, node.commit.repoPath, s.originalFileName));
|
.map(s => GitService.toGitContentUri(node.commit.sha, s.fileName, node.commit.repoPath, s.originalFileName));
|
||||||
for (const uri of uris) {
|
for (const uri of uris) {
|
||||||
await openEditor(uri, options);
|
await openEditor(uri, options);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Event, EventEmitter, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { CommitFormatter, GitService, GitStashCommit, GitUri } from '../gitService';
|
import { CommitFormatter, GitService, GitStashCommit, GitUri, ICommitFormatOptions } from '../gitService';
|
||||||
import { StashFileNode } from './stashFileNode';
|
import { StashFileNode } from './stashFileNode';
|
||||||
|
|
||||||
export class StashNode extends ExplorerNode {
|
export class StashNode extends ExplorerNode {
|
||||||
|
|
||||||
readonly resourceType: ResourceType = 'gitlens:stash';
|
readonly resourceType: ResourceType = 'gitlens:stash';
|
||||||
|
|
||||||
private _onDidChangeTreeData = new EventEmitter<ExplorerNode>();
|
|
||||||
public get onDidChangeTreeData(): Event<ExplorerNode> {
|
|
||||||
return this._onDidChangeTreeData.event;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(public readonly commit: GitStashCommit, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
constructor(public readonly commit: GitStashCommit, protected readonly context: ExtensionContext, protected readonly git: GitService) {
|
||||||
super(new GitUri(commit.uri, commit));
|
super(new GitUri(commit.uri, commit));
|
||||||
}
|
}
|
||||||
@@ -22,14 +17,11 @@ export class StashNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
const label = CommitFormatter.fromTemplate(this.git.config.gitExplorer.stashFormat, this.commit, this.git.config.defaultDateFormat);
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.git.config.gitExplorer.stashFormat, this.commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
|
dataFormat: this.git.config.defaultDateFormat
|
||||||
|
} as ICommitFormatOptions), TreeItemCollapsibleState.Collapsed);
|
||||||
item.contextValue = this.resourceType;
|
item.contextValue = this.resourceType;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
|
||||||
this._onDidChangeTreeData.fire();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -17,7 +17,7 @@ export class StatusUpstreamNode extends ExplorerNode {
|
|||||||
const range = this.direction === 'ahead'
|
const range = this.direction === 'ahead'
|
||||||
? `${this.status.upstream}..${this.status.branch}`
|
? `${this.status.upstream}..${this.status.branch}`
|
||||||
: `${this.status.branch}..${this.status.upstream}`;
|
: `${this.status.branch}..${this.status.upstream}`;
|
||||||
let log = await this.git.getLogForRepo(this.uri.repoPath!, range);
|
let log = await this.git.getLogForRepo(this.uri.repoPath!, range, 0);
|
||||||
if (log === undefined) return [];
|
if (log === undefined) return [];
|
||||||
|
|
||||||
if (this.direction !== 'ahead') return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git))];
|
if (this.direction !== 'ahead') return [...Iterables.map(log.commits.values(), c => new CommitNode(c, this.template, this.context, this.git))];
|
||||||
|
|||||||
Reference in New Issue
Block a user