{{ message }}
fix(scripts/check_emdash.sh): skip emdash check when no diff base is available#26489
Merged
Conversation
The emdash/endash check is a diff gate for pull requests: it resolves the merge-base against the target branch and only inspects added lines. When no base ref can be resolved, the script fell back to scanning every tracked file. Push builds on release branches hit exactly this case. The lint job checks out with fetch-depth: 1, so origin/main is absent, and GITHUB_BASE_REF is only set for pull_request events. With no base ref, the whole-tree scan flags the many pre-existing emdash/endash characters already in the repo and fails lint/emdash, even though the build introduced none of them. Skip the check in that case instead of scanning everything. A full scan is still available explicitly via --all.
This was referenced Jun 17, 2026
johnstcn
approved these changes
Jun 17, 2026
f0ssel
added a commit
that referenced
this pull request
Jun 17, 2026
…available (#26490) Backport of #26489 to `release/2.34`. ## Problem On `release/2.34`, `make lint` (`lint/emdash`) fails on push builds. `scripts/check_emdash.sh` only resolves a base ref for pull requests (`GITHUB_BASE_REF`) or when `origin/main` is present. The `lint` job checks out with `fetch-depth: 1`, so on a release-branch push neither is available, and the script falls back to scanning **every tracked file**, flagging pre-existing emdash/endash characters the build did not introduce. Observed on run [27704528068](https://github.com/coder/coder/actions/runs/27704528068/job/81949529546). ## Fix When no base ref can be determined (outside a pull request), skip the check instead of scanning the whole tree. `--all` still forces a full scan. Note: this branch carries an older variant of the script than `main`, so the change is applied by hand rather than cherry-picked, but the behavior matches #26489. ## Testing - Isolated no-base-ref repo (no `GITHUB_BASE_REF`, no `origin/main`): old script scans all files and fails on a pre-existing emdash; patched script skips and exits 0. - `shellcheck`, `shfmt`, `bash -n` clean. --- Generated by Coder Agents on behalf of @f0ssel.
f0ssel
added a commit
that referenced
this pull request
Jun 17, 2026
…available (#26491) Backport of #26489 to `release/2.33`. ## Problem `scripts/check_emdash.sh` only resolves a base ref for pull requests (`GITHUB_BASE_REF`) or when `origin/main` is present. The `lint` job checks out with `fetch-depth: 1`, so on a release-branch push neither is available, and the script falls back to scanning **every tracked file**, flagging pre-existing emdash/endash characters the build did not introduce. This is the same failure mode seen on the `release/2.34` push build (run [27704528068](https://github.com/coder/coder/actions/runs/27704528068/job/81949529546)); `release/2.33` carries the same script and the same bug. ## Fix When no base ref can be determined (outside a pull request), skip the check instead of scanning the whole tree. `--all` still forces a full scan. Note: this branch carries an older variant of the script than `main`, so the change is applied by hand rather than cherry-picked, but the behavior matches #26489. ## Testing - Isolated no-base-ref repo (no `GITHUB_BASE_REF`, no `origin/main`): old script scans all files and fails on a pre-existing emdash; patched script skips and exits 0. - `shellcheck`, `shfmt`, `bash -n` clean. --- Generated by Coder Agents on behalf of @f0ssel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
scripts/check_emdash.shis a diff gate for pull requests: it resolves the merge-base against the target branch and only inspects added lines. When it cannot resolve a base ref, it fell back to scanning every tracked file.Push builds on release branches hit exactly this case: the
lintjob checks out withfetch-depth: 1, soorigin/mainis absent, andGITHUB_BASE_REFis only set forpull_requestevents. With no base ref, the whole-tree scan flags the many pre-existing emdash/endash characters already in the repo and failsmake lint(lint/emdash), even though the build introduced none of them. Observed onrelease/2.34CI (run 27704528068).Fix
When no base ref can be determined (i.e. outside a pull request), skip the check instead of scanning the entire tree. A full scan remains available on demand via
scripts/check_emdash.sh --all.Testing
GITHUB_BASE_REF, noorigin/main): old script scans all files and fails on a pre-existing emdash; new script skips and exits 0.OK: no emdash or endash characters found.--all: still scans the full tree (flags pre-existing characters as before).shellcheckandshfmtclean.Backports
Backport PRs target
release/2.33andrelease/2.34(same bug, older script variant).release/2.29andrelease/2.32do not containscripts/check_emdash.sh, so there is nothing to backport there.Decision log
Considered alternatives to the skip:
github.event.beforeon push events. Rejected: the before-SHA is frequently unreachable in afetch-depth: 1clone, and wiring it in requires per-workflow env changes that complicate backports.origin/main/ deepen history in the release lint job. Rejected for the same backport-surface reason and because it only masks the design intent.The check exists to stop new emdashes from landing via PRs; that gate already ran on the originating PRs. On non-PR builds there is no meaningful diff base, so skipping is correct and self-contained in the script (clean to backport). The explicit
--allmode is preserved for intentional full-tree audits.Generated by Coder Agents on behalf of @f0ssel.