Skip to content

ci: stop re-shallowing origin/main in commitlint job#1173

Merged
olu-duffel merged 1 commit into
duffelhq:mainfrom
todor-a:fix-commitlint-shallow-main-fetch
Jun 15, 2026
Merged

ci: stop re-shallowing origin/main in commitlint job#1173
olu-duffel merged 1 commit into
duffelhq:mainfrom
todor-a:fix-commitlint-shallow-main-fetch

Conversation

@todor-a

@todor-a todor-a commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Problem

The Commitlint job fails on PRs whose branch is behind main, reporting errors on old, pre-convention commits (e.g. chore(release): 1.8.0, [STAYS-521] Add cancel booking to Stays) rather than the PR's own commits.

Root cause

The job checks out with fetch-depth: 0 (full history), but then runs:

- name: Fetch main for commitlint
  run: git fetch origin main --depth=1

That --depth=1 fetch re-shallows the origin/main ref to a single commit, throwing away the full history fetch-depth: 0 had just provided. With no common ancestor in the local history, commitlint --from origin/main can't compute the merge-base and instead lints the entire repo history — failing on legacy commits.

Fix

Remove the redundant shallow-fetch step. fetch-depth: 0 already makes origin/main available with full history, so the merge-base resolves and commitlint lints only the PR's commits.

Seen on #1165, where the Commitlint check failed on unrelated historical commits.

The Commitlint job checks out with `fetch-depth: 0` (full history), but a
follow-up `git fetch origin main --depth=1` step re-shallowed the
`origin/main` ref to a single commit. That destroyed the merge-base between
the PR branch and main, so `commitlint --from origin/main` resolved to the
entire repo history and failed on old, pre-convention commits instead of
just the PR's commits.

Remove the redundant shallow fetch — `fetch-depth: 0` already provides
`origin/main` with full history, so the merge-base resolves correctly.
@todor-a todor-a requested a review from a team as a code owner June 15, 2026 06:16

@igorp1 igorp1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix @todor-a, I'm happy with the change

@olu-duffel olu-duffel merged commit e6cdca7 into duffelhq:main Jun 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants