Skip to content

fix(ng-dev): uncommitted changes check returning false-positives #416

New issue

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

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

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions github-actions/commit-message-based-labels/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49407,6 +49407,7 @@ var require_git_client = __commonJS({
return branchName;
}
hasUncommittedChanges() {
this.runGraceful(["update-index", "-q", "--refresh"]);
return this.runGraceful(["diff-index", "--quiet", "HEAD"]).status !== 0;
}
checkout(branchOrRevision, cleanState) {
Expand Down
1 change: 1 addition & 0 deletions github-actions/slash-commands/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55081,6 +55081,7 @@ var require_git_client = __commonJS({
return branchName;
}
hasUncommittedChanges() {
this.runGraceful(["update-index", "-q", "--refresh"]);
return this.runGraceful(["diff-index", "--quiet", "HEAD"]).status !== 0;
}
checkout(branchOrRevision, cleanState) {
Expand Down
7 changes: 7 additions & 0 deletions ng-dev/utils/git/git-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ export class GitClient {

/** Gets whether the current Git repository has uncommitted changes. */
hasUncommittedChanges(): boolean {
// We also need to refresh the index in case some files have been touched
// but not modified. The diff-index command will not check contents so we
// manually need to refresh and cleanup the index before performing the diff.
// Relevant info: https://git-scm.com/docs/git-diff-index#_non_cached_mode,
// https://git-scm.com/docs/git-update-index and https://stackoverflow.com/a/34808299.
this.runGraceful(['update-index', '-q', '--refresh']);

return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0;
}

Expand Down
1 change: 1 addition & 0 deletions tools/local-actions/changelog/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46508,6 +46508,7 @@ var require_git_client = __commonJS({
return branchName;
}
hasUncommittedChanges() {
this.runGraceful(["update-index", "-q", "--refresh"]);
return this.runGraceful(["diff-index", "--quiet", "HEAD"]).status !== 0;
}
checkout(branchOrRevision, cleanState) {
Expand Down