Skip to content
Source
Sign inSign up

Pin shared modules to commits

CI / Speed and debugging

Pin shared modules to commits

A tag such as v1.0.0 can move, so the name in a src: import does not show which code runs. A commit id does. A commit id can lie too: a repository can keep a commit that it never put on a branch or a tag, like a commit of a deleted branch or a force push. TanStack Source checks each commit pin against the branches and tags of its repository, and shows the result on the pull request.

4 min read

You need a repository that imports a shared module, and the src CLI, logged in.

1. Turn on commit pins

A repository created on or after 2026-11-26 requires commit pins already. An older repository does not, so its tag imports keep working. To require them, an admin runs:

src ci settings --commit-pins on
Set the CI settings.
Containers at once: 20, the limit of the forge
Approval gates: none
Merge queue check timeout: 60 minutes
Commit pins: required: each src: import names a commit
Close fixed issues: on merge

In the browser, open Settings, then CI under Code, and turn on Require commit pins. --commit-pins off turns the rule off, and --commit-pins default goes back to the default for the age of the repository.

With the rule on, the plan stops at an import of a tag or a branch:

src:acme/ci-steps@v1.0.0/pnpm.ts: this repository requires commit pins, so a src: import names a commit (40 hex digits), not the tag or branch "v1.0.0". Run `src ci update --pin` to pin it to the commit that "v1.0.0" points at now.

The rule covers the imports of your workflows. The imports inside a module are the module's own: src.lock pins each of them to a commit.

2. Pin the imports with src ci update --pin

Run it in the root of the repository:

src ci update --pin
acme/ci-steps@3f2a1b9c0d4e5f60718293a4b5c6d7e8f9012345: new pin at 3f2a1b9
  added pnpm.ts: 6 lines
Pinned the src: imports of .source/workflows/ci.ts to commits.
Wrote .source/src.lock.

Each import of a tag or a branch now names the commit that the tag or branch points at. The old name stays in a comment on the line, so you can still see the version:

import { pnpmInstall } from 'src:acme/ci-steps@3f2a1b9c0d4e5f60718293a4b5c6d7e8f9012345/pnpm.ts' // v1.0.0

To move to a newer version later, write the new commit in the import, or the new tag, and run src ci update --pin again. Or let the Dependencies tab do it: see step 5.

3. Open a pull request

Commit the workflows and .source/src.lock, push a branch, and open a pull request:

git add .source
git commit -m "ci: pin the shared steps to commits"
git push -u origin HEAD
src pr create --fill

4. Read the Workflow imports card

The Conversation tab of the pull request shows a Workflow imports card when the pull request adds, moves or removes a pin in .source/src.lock. Each row shows the module, the old and the new commit, and where the new commit is:

  • A green badge names the tag or the branch that holds the commit, like tag v1.0.0. in branch main means that the commit is in the history of main, not at its tip.
  • A red On no branch or tag badge means that no branch or tag of that repository holds the commit. It can be a commit of a deleted branch, a force push, or another repository. CI refuses it.
  • Not checked means that the commit is too deep in the history to check. Pin a commit that a tag points at.
  • Can't read the repository means that you cannot read the repository of the module.

From a terminal, src pr pins shows the same list, and exits with 1 when a commit is on no branch or tag:

src pr pins 12
acme/ci-steps@3f2a1b9c0d4e5f60718293a4b5c6d7e8f9012345	new at 3f2a1b9	on tag v1.0.0
acme/ci-steps@v1.0.0	was 3f2a1b9	removed

REST gives it at GET /api/v1/repos/<owner>/<repo>/pulls/<number>/pins, and MCP with get_pull_pins.

5. Keep the pins up to date

The CI pins card of the Dependencies tab shows each pin of the default branch, the version of its comment, and whether a newer commit of that version is out. Update moves the pins that are behind in a pull request of the bot, with src.lock written again. From a terminal, src deps pins lists them and src deps pin moves them. See Update the CI pins of the workflows.

What CI checks

Each plan checks every commit pin, with or without the rule of step 1:

The checkWhen it fails
A branch or a tag of the module's repository holds the commitsrc:acme/ci-steps@<commit>: commit 3f2a1b9 is not on any branch or tag of acme/ci-steps. The plan stops, and no job runs.
The repository requires commit pinsAn import of a tag or a branch stops the plan. Run src ci update --pin.
src.lock pins the commit, and the files match its hashAs for every src: import. See Share steps.

Only branches and tags count, never the refs of pull requests, agents or CI. A failed check shows on the pull request as a failed plan run, next to the red badge of the card.