Gets whether the current Git repository has uncommitted changes.
()
| 166 | |
| 167 | /** Gets whether the current Git repository has uncommitted changes. */ |
| 168 | hasUncommittedChanges(): boolean { |
| 169 | // We also need to refresh the index in case some files have been touched |
| 170 | // but not modified. The diff-index command will not check contents so we |
| 171 | // manually need to refresh and cleanup the index before performing the diff. |
| 172 | // Relevant info: https://git-scm.com/docs/git-diff-index#_non_cached_mode, |
| 173 | // https://git-scm.com/docs/git-update-index and https://stackoverflow.com/a/34808299. |
| 174 | this.runGraceful(['update-index', '-q', '--refresh']); |
| 175 | |
| 176 | return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; |
| 177 | } |
| 178 | |
| 179 | /** |
| 180 | * Checks out a requested branch or revision, optionally cleaning the state of the repository |
no test coverage detected