Browse Source

Fixes issues with tracked .gitignore'd files

main
Eric Amodio 7 years ago
parent
commit
61ce8adad0
7 changed files with 115 additions and 260 deletions
  1. +5
    -0
      CHANGELOG.md
  2. +0
    -1
      README.md
  3. +52
    -188
      package-lock.json
  4. +2
    -8
      package.json
  5. +0
    -10
      src/@types/ignore/index.d.ts
  6. +0
    -3
      src/configuration.ts
  7. +56
    -50
      src/gitService.ts

+ 5
- 0
CHANGELOG.md View File

@ -5,6 +5,11 @@ 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/).
## [Unreleased] ## [Unreleased]
### Removed
- Removes `gitlens.advanced.gitignore.enabled` setting since it usage has been replaced by a tracked file cache
### Fixed
- Fixes issues with tracked files which are ignored via `.gitignore` not working properly
## [5.6.4] - 2017-10-12 ## [5.6.4] - 2017-10-12
### Fixed ### Fixed

+ 0
- 1
README.md View File

@ -430,7 +430,6 @@ GitLens is highly customizable and provides many configuration settings to allow
|`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached |`gitlens.advanced.caching.enabled`|Specifies whether git output will be cached
|`gitlens.advanced.caching.maxLines`|Specifies the threshold for caching larger documents |`gitlens.advanced.caching.maxLines`|Specifies the threshold for caching larger documents
|`gitlens.advanced.git`|Specifies the git path to use |`gitlens.advanced.git`|Specifies the git path to use
|`gitlens.advanced.gitignore.enabled`|Specifies whether or not to parse the root .gitignore file for better performance (i.e. avoids blaming excluded files)
|`gitlens.advanced.maxQuickHistory`|Specifies the maximum number of QuickPick history entries to show |`gitlens.advanced.maxQuickHistory`|Specifies the maximum number of QuickPick history entries to show
|`gitlens.advanced.quickPick.closeOnFocusOut`|Specifies whether or not to close the QuickPick menu when focus is lost |`gitlens.advanced.quickPick.closeOnFocusOut`|Specifies whether or not to close the QuickPick menu when focus is lost

+ 52
- 188
package-lock.json View File

@ -16,7 +16,7 @@
"integrity": "sha1-qjuL2ivlErGuCgV7lC6GnDcKVWk=", "integrity": "sha1-qjuL2ivlErGuCgV7lC6GnDcKVWk=",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "8.0.34"
"@types/node": "8.0.41"
} }
}, },
"@types/mocha": { "@types/mocha": {
@ -26,9 +26,9 @@
"dev": true "dev": true
}, },
"@types/node": { "@types/node": {
"version": "8.0.34",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.34.tgz",
"integrity": "sha512-Jnmm57+nHqvJUPwUzt1CLoLzFtF2B2vgG7cWFut+a4nqTp9/L6pL0N+o0Jt3V7AQnCKMsPEqQpLFZYleBCdq3w==",
"version": "8.0.41",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.41.tgz",
"integrity": "sha512-6XPVDfoTQE5O6FRCbSgFg0YEobbsqUuu6Wxnp7g3kydKTTQep/Mo3rT9CCS1igzQeAb1GLB7r3+xTgcHv+4KSQ==",
"dev": true "dev": true
}, },
"@types/tmp": { "@types/tmp": {
@ -861,12 +861,6 @@
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
"dev": true "dev": true
}, },
"graceful-readlink": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
"integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
"dev": true
},
"growl": { "growl": {
"version": "1.10.3", "version": "1.10.3",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz",
@ -896,9 +890,9 @@
} }
}, },
"gulp-gunzip": { "gulp-gunzip": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/gulp-gunzip/-/gulp-gunzip-0.0.3.tgz",
"integrity": "sha1-e24HsPWP09QlFcSOrVpj3wVy9i8=",
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/gulp-gunzip/-/gulp-gunzip-1.0.0.tgz",
"integrity": "sha1-FbdBFF6Dqcb1CIYkG1fMWHHxUak=",
"dev": true, "dev": true,
"requires": { "requires": {
"through2": "0.6.5", "through2": "0.6.5",
@ -1113,68 +1107,59 @@
} }
}, },
"gulp-vinyl-zip": { "gulp-vinyl-zip": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/gulp-vinyl-zip/-/gulp-vinyl-zip-1.4.0.tgz",
"integrity": "sha1-VjgvLMtXIxuwR4x4c3zNVylzvuE=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/gulp-vinyl-zip/-/gulp-vinyl-zip-2.1.0.tgz",
"integrity": "sha1-JOQGhdwFtxSZlSRQmeBZAmO+ja0=",
"dev": true, "dev": true,
"requires": { "requires": {
"event-stream": "3.3.4", "event-stream": "3.3.4",
"queue": "3.1.0",
"through2": "0.6.5",
"vinyl": "0.4.6",
"queue": "4.4.1",
"through2": "2.0.3",
"vinyl": "2.1.0",
"vinyl-fs": "2.4.4", "vinyl-fs": "2.4.4",
"yauzl": "2.8.0", "yauzl": "2.8.0",
"yazl": "2.4.2" "yazl": "2.4.2"
}, },
"dependencies": { "dependencies": {
"clone": { "clone": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/clone/-/clone-0.2.0.tgz",
"integrity": "sha1-xhJqkK1Pctv1rNskPMN3JP6T/B8=",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs=",
"dev": true "dev": true
}, },
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=",
"clone-stats": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
"dev": true "dev": true
}, },
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"queue": {
"version": "4.4.1",
"resolved": "https://registry.npmjs.org/queue/-/queue-4.4.1.tgz",
"integrity": "sha512-Lcs97MDk4ewesYBtC6P3hl+klvVmHN2PLzgsQcK29bVQ2+5T0Ef0ZmXhBIINkpJd3LzZK29MWjyTL2lGLYGOPA==",
"dev": true, "dev": true,
"requires": { "requires": {
"core-util-is": "1.0.2",
"inherits": "2.0.3",
"isarray": "0.0.1",
"string_decoder": "0.10.31"
"inherits": "2.0.3"
} }
}, },
"string_decoder": {
"version": "0.10.31",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz",
"integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=",
"replace-ext": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=",
"dev": true "dev": true
}, },
"through2": {
"version": "0.6.5",
"resolved": "https://registry.npmjs.org/through2/-/through2-0.6.5.tgz",
"integrity": "sha1-QaucZ7KdVyCQcUEOHXp6lozTrUg=",
"dev": true,
"requires": {
"readable-stream": "1.0.34",
"xtend": "4.0.1"
}
},
"vinyl": { "vinyl": {
"version": "0.4.6",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-0.4.6.tgz",
"integrity": "sha1-LzVsh6VQolVGHza76ypbqL94SEc=",
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.1.0.tgz",
"integrity": "sha1-Ah+cLPlR1rk5lDyJ617lrdT9kkw=",
"dev": true, "dev": true,
"requires": { "requires": {
"clone": "0.2.0",
"clone-stats": "0.0.1"
"clone": "2.1.1",
"clone-buffer": "1.0.0",
"clone-stats": "1.0.0",
"cloneable-readable": "1.0.0",
"remove-trailing-separator": "1.1.0",
"replace-ext": "1.0.0"
} }
} }
} }
@ -1281,11 +1266,6 @@
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
"integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ=="
}, },
"ignore": {
"version": "3.3.5",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.5.tgz",
"integrity": "sha512-JLH93mL8amZQhh/p6mfQgVBH3M6epNq3DfsXsTSuSrInVjwyYlFE1nv2AgfRCC8PoOhM0jwQ5v8s9LgbK7yGDw=="
},
"inflight": { "inflight": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -1489,12 +1469,6 @@
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
"dev": true "dev": true
}, },
"json3": {
"version": "3.3.2",
"resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz",
"integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=",
"dev": true
},
"jsonify": { "jsonify": {
"version": "0.0.0", "version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
@ -1545,28 +1519,12 @@
"readable-stream": "2.3.3" "readable-stream": "2.3.3"
} }
}, },
"lodash._baseassign": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz",
"integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=",
"dev": true,
"requires": {
"lodash._basecopy": "3.0.1",
"lodash.keys": "3.1.2"
}
},
"lodash._basecopy": { "lodash._basecopy": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz",
"integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=",
"dev": true "dev": true
}, },
"lodash._basecreate": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz",
"integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=",
"dev": true
},
"lodash._basetostring": { "lodash._basetostring": {
"version": "3.0.1", "version": "3.0.1",
"resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz", "resolved": "https://registry.npmjs.org/lodash._basetostring/-/lodash._basetostring-3.0.1.tgz",
@ -1620,17 +1578,6 @@
"resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz", "resolved": "https://registry.npmjs.org/lodash.assign/-/lodash.assign-4.2.0.tgz",
"integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc=" "integrity": "sha1-DZnzzNem0mHRm9rrkkUAXShYCOc="
}, },
"lodash.create": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz",
"integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=",
"dev": true,
"requires": {
"lodash._baseassign": "3.2.0",
"lodash._basecreate": "3.0.3",
"lodash._isiterateecall": "3.0.9"
}
},
"lodash.debounce": { "lodash.debounce": {
"version": "4.0.8", "version": "4.0.8",
"resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
@ -2350,18 +2297,18 @@
} }
}, },
"source-map": { "source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true "dev": true
}, },
"source-map-support": { "source-map-support": {
"version": "0.4.18",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.4.18.tgz",
"integrity": "sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA==",
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.0.tgz",
"integrity": "sha512-vUoN3I7fHQe0R/SJLKRdKYuEdRGogsviXFkHHo17AWaTGv17VLnxw+CFXvqy+y4ORZ3doWLQcxRYfwKrsd/H7Q==",
"dev": true, "dev": true,
"requires": { "requires": {
"source-map": "0.5.7"
"source-map": "0.6.1"
} }
}, },
"sparkles": { "sparkles": {
@ -2814,108 +2761,25 @@
} }
}, },
"vscode": { "vscode": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.5.tgz",
"integrity": "sha1-EOsQQAGEDD3QgTgV/UoF+PyILRQ=",
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/vscode/-/vscode-1.1.6.tgz",
"integrity": "sha1-Ru0a+iwbnWifY5TI8WvR1xkPdfs=",
"dev": true, "dev": true,
"requires": { "requires": {
"glob": "7.1.2", "glob": "7.1.2",
"gulp-chmod": "2.0.0", "gulp-chmod": "2.0.0",
"gulp-filter": "5.0.1", "gulp-filter": "5.0.1",
"gulp-gunzip": "0.0.3",
"gulp-gunzip": "1.0.0",
"gulp-remote-src": "0.4.3", "gulp-remote-src": "0.4.3",
"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",
"mocha": "3.5.3",
"gulp-vinyl-zip": "2.1.0",
"mocha": "4.0.1",
"request": "2.83.0", "request": "2.83.0",
"semver": "5.4.1", "semver": "5.4.1",
"source-map-support": "0.4.18",
"source-map-support": "0.5.0",
"url-parse": "1.1.9", "url-parse": "1.1.9",
"vinyl-source-stream": "1.1.0" "vinyl-source-stream": "1.1.0"
},
"dependencies": {
"commander": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
"integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=",
"dev": true,
"requires": {
"graceful-readlink": "1.0.1"
}
},
"debug": {
"version": "2.6.8",
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz",
"integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=",
"dev": true,
"requires": {
"ms": "2.0.0"
}
},
"diff": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz",
"integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=",
"dev": true
},
"growl": {
"version": "1.9.2",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz",
"integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
"dev": true
},
"has-flag": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz",
"integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=",
"dev": true
},
"mocha": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-3.5.3.tgz",
"integrity": "sha512-/6na001MJWEtYxHOV1WLfsmR4YIynkUEhBwzsb+fk2qmQ3iqsi258l/Q2MWHJMImAcNpZ8DEdYAK72NHoIQ9Eg==",
"dev": true,
"requires": {
"browser-stdout": "1.3.0",
"commander": "2.9.0",
"debug": "2.6.8",
"diff": "3.2.0",
"escape-string-regexp": "1.0.5",
"glob": "7.1.1",
"growl": "1.9.2",
"he": "1.1.1",
"json3": "3.3.2",
"lodash.create": "3.1.1",
"mkdirp": "0.5.1",
"supports-color": "3.1.2"
},
"dependencies": {
"glob": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz",
"integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=",
"dev": true,
"requires": {
"fs.realpath": "1.0.0",
"inflight": "1.0.6",
"inherits": "2.0.3",
"minimatch": "3.0.4",
"once": "1.4.0",
"path-is-absolute": "1.0.1"
}
}
}
},
"supports-color": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz",
"integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=",
"dev": true,
"requires": {
"has-flag": "1.0.0"
}
}
} }
}, },
"wrappy": { "wrappy": {

+ 2
- 8
package.json View File

@ -719,11 +719,6 @@
"default": null, "default": null,
"description": "Specifies the git path to use" "description": "Specifies the git path to use"
}, },
"gitlens.advanced.gitignore.enabled": {
"type": "boolean",
"default": true,
"description": "Specifies whether or not to parse the root .gitignore file for better performance (i.e. avoids blaming excluded files)"
},
"gitlens.advanced.maxQuickHistory": { "gitlens.advanced.maxQuickHistory": {
"type": "number", "type": "number",
"default": 200, "default": 200,
@ -2000,7 +1995,6 @@
"copy-paste": "1.3.0", "copy-paste": "1.3.0",
"date-fns": "1.29.0", "date-fns": "1.29.0",
"iconv-lite": "0.4.19", "iconv-lite": "0.4.19",
"ignore": "3.3.5",
"lodash.debounce": "4.0.8", "lodash.debounce": "4.0.8",
"lodash.escaperegexp": "4.1.2", "lodash.escaperegexp": "4.1.2",
"lodash.isequal": "4.5.0", "lodash.isequal": "4.5.0",
@ -2012,12 +2006,12 @@
"@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.43", "@types/mocha": "2.2.43",
"@types/node": "8.0.34",
"@types/node": "8.0.41",
"@types/tmp": "0.0.33", "@types/tmp": "0.0.33",
"husky": "^0.14.3", "husky": "^0.14.3",
"mocha": "4.0.1", "mocha": "4.0.1",
"tslint": "5.7.0", "tslint": "5.7.0",
"typescript": "2.5.3", "typescript": "2.5.3",
"vscode": "1.1.5"
"vscode": "1.1.6"
} }
} }

+ 0
- 10
src/@types/ignore/index.d.ts View File

@ -1,10 +0,0 @@
declare module "ignore" {
namespace ignore {
interface Ignore {
add(patterns: string | Array<string> | Ignore): Ignore;
filter(paths: Array<string>): Array<string>;
}
}
function ignore(): ignore.Ignore;
export = ignore;
}

+ 0
- 3
src/configuration.ts View File

@ -58,9 +58,6 @@ export interface IAdvancedConfig {
maxLines: number; maxLines: number;
}; };
git: string; git: string;
gitignore: {
enabled: boolean;
};
maxQuickHistory: number; maxQuickHistory: number;
menus: { menus: {
explorerContext: { explorerContext: {

+ 56
- 50
src/gitService.ts View File

@ -8,7 +8,6 @@ import { Git, GitAuthor, GitBlame, GitBlameCommit, GitBlameLine, GitBlameLines,
import { GitUri, IGitCommitInfo, IGitUriData } from './git/gitUri'; import { GitUri, IGitCommitInfo, IGitUriData } from './git/gitUri';
import { Logger } from './logger'; import { Logger } from './logger';
import * as fs from 'fs'; import * as fs from 'fs';
import * as ignore from 'ignore';
import * as path from 'path'; import * as path from 'path';
export { GitUri, IGitCommitInfo }; export { GitUri, IGitCommitInfo };
@ -21,14 +20,14 @@ export * from './git/gitContextTracker';
class UriCacheEntry { class UriCacheEntry {
constructor(public uri: GitUri) { }
constructor(public readonly uri: GitUri) { }
} }
class GitCacheEntry { class GitCacheEntry {
private cache: Map<string, CachedBlame | CachedDiff | CachedLog> = new Map(); private cache: Map<string, CachedBlame | CachedDiff | CachedLog> = new Map();
constructor(public key: string) { }
constructor(public readonly key: string) { }
get hasErrors(): boolean { get hasErrors(): boolean {
return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined); return Iterables.every(this.cache.values(), _ => _.errorMessage !== undefined);
@ -98,11 +97,11 @@ export class GitService extends Disposable {
private _gitCache: Map<string, GitCacheEntry>; private _gitCache: Map<string, GitCacheEntry>;
private _remotesCache: Map<string, GitRemote[]>; private _remotesCache: Map<string, GitRemote[]>;
private _cacheDisposable: Disposable | undefined; private _cacheDisposable: Disposable | undefined;
private _uriCache: Map<string, UriCacheEntry>;
private _trackedCache: Map<string, boolean>;
private _versionedUriCache: Map<string, UriCacheEntry>;
config: IConfig; config: IConfig;
private _disposable: Disposable | undefined; private _disposable: Disposable | undefined;
private _gitignore: Promise<ignore.Ignore | undefined>;
private _repoWatcher: FileSystemWatcher | undefined; private _repoWatcher: FileSystemWatcher | undefined;
static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined); static EmptyPromise: Promise<GitBlame | GitDiff | GitLog | undefined> = Promise.resolve(undefined);
@ -112,7 +111,8 @@ export class GitService extends Disposable {
this._gitCache = new Map(); this._gitCache = new Map();
this._remotesCache = new Map(); this._remotesCache = new Map();
this._uriCache = new Map();
this._trackedCache = new Map();
this._versionedUriCache = new Map();
this._onConfigurationChanged(); this._onConfigurationChanged();
@ -136,7 +136,8 @@ export class GitService extends Disposable {
this._gitCache.clear(); this._gitCache.clear();
this._remotesCache.clear(); this._remotesCache.clear();
this._uriCache.clear();
this._trackedCache.clear();
this._versionedUriCache.clear();
} }
public get UseCaching() { public get UseCaching() {
@ -174,28 +175,6 @@ export class GitService extends Disposable {
this._gitCache.clear(); this._gitCache.clear();
} }
this._gitignore = new Promise<ignore.Ignore | undefined>((resolve, reject) => {
if (!cfg.advanced.gitignore.enabled) {
resolve(undefined);
return;
}
const gitignorePath = path.join(this.repoPath, '.gitignore');
fs.exists(gitignorePath, e => {
if (e) {
fs.readFile(gitignorePath, 'utf8', (err, data) => {
if (!err) {
resolve(ignore().add(data));
return;
}
resolve(undefined);
});
return;
}
resolve(undefined);
});
});
} }
const ignoreWhitespace = this.config && this.config.blame.ignoreWhitespace; const ignoreWhitespace = this.config && this.config.blame.ignoreWhitespace;
@ -237,6 +216,7 @@ export class GitService extends Disposable {
} }
this._gitCache.clear(); this._gitCache.clear();
this._trackedCache.clear();
this._fireRepoChange(); this._fireRepoChange();
this._fireGitCacheChange(); this._fireGitCacheChange();
@ -431,17 +411,16 @@ export class GitService extends Disposable {
} }
private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise<GitBlame | undefined> { private async _getBlameForFile(uri: GitUri, entry: GitCacheEntry | undefined, key: string): Promise<GitBlame | undefined> {
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
const ignore = await this._gitignore;
if (ignore && !ignore.filter([file]).length) {
Logger.log(`Skipping blame; '${uri.fsPath}' is gitignored`);
if (!(await this.isTracked(uri))) {
Logger.log(`Skipping blame; '${uri.fsPath}' is not tracked`);
if (entry && entry.key) { if (entry && entry.key) {
this._onDidBlameFail.fire(entry.key); this._onDidBlameFail.fire(entry.key);
} }
return await GitService.EmptyPromise as GitBlame; return await GitService.EmptyPromise as GitBlame;
} }
const [file, root] = Git.splitPath(uri.fsPath, uri.repoPath, false);
try { try {
const data = await Git.blame(root, file, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace }); const data = await Git.blame(root, file, uri.sha, { ignoreWhitespace: this.config.blame.ignoreWhitespace });
const blame = GitBlameParser.parse(data, root, file); const blame = GitBlameParser.parse(data, root, file);
@ -597,7 +576,7 @@ export class GitService extends Disposable {
getGitUriForFile(uri: Uri) { getGitUriForFile(uri: Uri) {
const cacheKey = this.getCacheEntryKey(uri); const cacheKey = this.getCacheEntryKey(uri);
const entry = this._uriCache.get(cacheKey);
const entry = this._versionedUriCache.get(cacheKey);
return entry && entry.uri; return entry && entry.uri;
} }
@ -832,14 +811,13 @@ export class GitService extends Disposable {
} }
private async _getLogForFile(repoPath: string | undefined, fileName: string, sha: string | undefined, options: { maxCount?: number, range?: Range, reverse?: boolean, skipMerges?: boolean }, entry: GitCacheEntry | undefined, key: string): Promise<GitLog | undefined> { private async _getLogForFile(repoPath: string | undefined, fileName: string, sha: string | undefined, options: { maxCount?: number, range?: Range, reverse?: boolean, skipMerges?: boolean }, entry: GitCacheEntry | undefined, key: string): Promise<GitLog | undefined> {
const [file, root] = Git.splitPath(fileName, repoPath, false);
const ignore = await this._gitignore;
if (ignore && !ignore.filter([file]).length) {
Logger.log(`Skipping log; '${fileName}' is gitignored`);
if (!(await this.isTracked(fileName, repoPath))) {
Logger.log(`Skipping log; '${fileName}' is not tracked`);
return await GitService.EmptyPromise as GitLog; return await GitService.EmptyPromise as GitLog;
} }
const [file, root] = Git.splitPath(fileName, repoPath, false);
try { try {
const { range, ...opts } = options; const { range, ...opts } = options;
const data = await Git.log_file(root, file, sha, { ...opts, ...{ startLine: range && range.start.line + 1, endLine: range && range.end.line + 1 } }); const data = await Git.log_file(root, file, sha, { ...opts, ...{ startLine: range && range.start.line + 1, endLine: range && range.end.line + 1 } });
@ -951,7 +929,7 @@ export class GitService extends Disposable {
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._versionedUriCache.set(cacheKey, entry);
return file; return file;
} }
@ -965,7 +943,7 @@ export class GitService extends Disposable {
if (editor === undefined || editor.document === undefined || editor.document.uri === undefined) return false; if (editor === undefined || editor.document === undefined || editor.document.uri === undefined) return false;
const cacheKey = this.getCacheEntryKey(editor.document.uri); const cacheKey = this.getCacheEntryKey(editor.document.uri);
return this._uriCache.has(cacheKey);
return this._versionedUriCache.has(cacheKey);
} }
isEditorBlameable(editor: TextEditor): boolean { isEditorBlameable(editor: TextEditor): boolean {
@ -979,19 +957,47 @@ export class GitService extends Disposable {
return !!status; return !!status;
} }
isTrackable(uri: Uri): boolean {
// Logger.log(`isTrackable('${uri.scheme}', '${uri.fsPath}')`);
isTrackable(scheme: string): boolean;
isTrackable(uri: Uri): boolean;
isTrackable(schemeOruri: string | Uri): boolean {
let scheme: string;
if (typeof schemeOruri === 'string') {
scheme = schemeOruri;
}
else {
scheme = schemeOruri.scheme;
}
return uri.scheme === DocumentSchemes.File || uri.scheme === DocumentSchemes.Git || uri.scheme === DocumentSchemes.GitLensGit;
return scheme === DocumentSchemes.File || scheme === DocumentSchemes.Git || scheme === DocumentSchemes.GitLensGit;
} }
async isTracked(uri: GitUri): Promise<boolean> {
if (!this.isTrackable(uri)) return false;
async isTracked(fileName: string, repoPath: string | undefined): Promise<boolean>;
async isTracked(uri: GitUri): Promise<boolean>;
async isTracked(fileNameOrUri: string | GitUri, repoPath?: string | undefined): Promise<boolean> {
let cacheKey: string;
let fileName: string;
if (typeof fileNameOrUri === 'string') {
[fileName, repoPath] = Git.splitPath(fileNameOrUri, repoPath);
cacheKey = this.getCacheEntryKey(fileNameOrUri);
}
else {
if (!this.isTrackable(fileNameOrUri)) return false;
fileName = fileNameOrUri.fsPath;
repoPath = fileNameOrUri.repoPath;
cacheKey = this.getCacheEntryKey(fileNameOrUri);
}
Logger.log(`isTracked('${fileName}', '${repoPath}')`);
let tracked = this._trackedCache.get(cacheKey);
if (tracked !== undefined) return tracked;
Logger.log(`isTracked('${uri.fsPath}', '${uri.repoPath}')`);
const result = await Git.ls_files(repoPath === undefined ? '' : repoPath, fileName);
tracked = !!result;
this._trackedCache.set(cacheKey, tracked);
const result = await Git.ls_files(uri.repoPath === undefined ? '' : uri.repoPath, uri.fsPath);
return !!result;
return tracked;
} }
openDiffTool(repoPath: string, uri: Uri, staged: boolean) { openDiffTool(repoPath: string, uri: Uri, staged: boolean) {

Loading…
Cancel
Save