diff --git a/github-actions/commit-message-based-labels/main.js b/github-actions/commit-message-based-labels/main.js index 2725b1983..b851e57b5 100644 --- a/github-actions/commit-message-based-labels/main.js +++ b/github-actions/commit-message-based-labels/main.js @@ -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) { diff --git a/github-actions/slash-commands/main.js b/github-actions/slash-commands/main.js index 0116458a0..74718ad35 100644 --- a/github-actions/slash-commands/main.js +++ b/github-actions/slash-commands/main.js @@ -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) { diff --git a/ng-dev/utils/git/git-client.ts b/ng-dev/utils/git/git-client.ts index 6ec2419cf..97c5c8130 100644 --- a/ng-dev/utils/git/git-client.ts +++ b/ng-dev/utils/git/git-client.ts @@ -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; } diff --git a/tools/local-actions/changelog/main.js b/tools/local-actions/changelog/main.js index f83c66f45..9d49ac861 100644 --- a/tools/local-actions/changelog/main.js +++ b/tools/local-actions/changelog/main.js @@ -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) {