Commit reference formatters can emit bare SHAs that parseReferences rejects
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
🐛 The bug
referenceFor() can emit a same-repository commit reference that parseReferences() rejects.
The shared parser accepts bare hexadecimal SHAs of 7–40 characters only when they contain both a letter (a–f) and a decimal digit. This prevents ordinary numbers and hexadecimal words from becoming false-positive commit references. The formatters truncate SHAs without checking that condition.
This is existing behaviour in GitHub and GitLab, not a Tangled-only regression. PR #238 adds the same formatting pattern for Tangled.
Confirmed from source:
- GitHub's shared
githubShapedWeb()formatter insrc/web.tsemits seven characters. - GitLab's formatter in
src/gitlab/web.tsemits eight characters. - Tangled's formatter in
src/tangled/web.tsemits seven characters.
For example, a SHA beginning deadbeef1… produces deadbee on GitHub/Tangled and deadbeef on GitLab. Both are rejected as bare references, even though a longer prefix would contain a digit. The same mismatch occurs with a digits-only prefix followed by a letter.
Repository-qualified references such as acme/widgets@deadbee use a separate parsing rule and do not require mixed letters and digits.
🛠️ To reproduce
Use this minimal example from the repository root. No forge API requests or real commits are required; these APIs operate on reference text.
import { github } from './src/github/index.ts'
import { gitlab } from './src/gitlab/index.ts'
for (const provider of [github(), gitlab()]) {
const repo = {
forge: provider.forge,
instance: provider.instance,
owner: 'acme',
name: 'widgets',
}
const ref = {
forge: provider.forge,
instance: provider.instance,
repo,
sha: 'deadbeef1234567890abcdef1234567890abcdef12',
}
const text = provider.referenceFor(ref, { from: repo })!
console.log(provider.forge, text, provider.parseReferences(text, { from: repo }))
}
Current results, derived from source inspection:
- GitHub:
deadbee, then[]. - GitLab:
deadbeef, then[].
This example has not been executed in the review sandbox. No hosted reproduction is available.
🌈 Expected behaviour
Align commit-reference formatting and parsing across affected providers.
When referenceFor() emits a bare commit reference, parseReferences() should recognise that reference in the same repository context.
One possible approach is to extend the prefix until it satisfies the parser's existing rules. If no acceptable prefix exists, use an explicit repository-qualified reference or a supported commit URL instead. Keep the parser's protection against ordinary numbers and hexadecimal words.
A URL fallback is not a parseReferences() round trip: that API deliberately excludes URLs. If a formatter uses a URL fallback, verify it with parseUrl().
Acceptance criteria:
- Cover letter-only prefixes followed by a digit and digit-only prefixes followed by a letter.
- Define and test the fallback for full SHAs containing only digits or only hexadecimal letters.
- Keep normal mixed-character short SHAs working.
- Keep repository-qualified commit references working, including prefixes that contain only letters or only digits.
- Preserve the existing negative parsing tests for ordinary numbers and hexadecimal words.
- Apply a consistent policy across affected providers and add regression coverage.
ℹ️ Additional context
Affected areas:
src/web.ts:isBareSha(), commit rules inrulesFor(), andgithubShapedWeb().src/gitlab/web.tsandsrc/tangled/web.ts: commit-reference formatting.test/unit/references.test.ts: parsing and round-trip coverage.- Audit other formatters before deciding the final scope. Source inspection also found SHA truncation in SourceHut and Bitbucket, and shared
githubShapedWeb()use by Forgejo, Gitee, and Pushin. Their full behaviour has not been verified here.
Track this as a cross-provider follow-up rather than requiring a Tangled-only fix in #238.
Requested by @serhalp.
- Lingua principale
- TypeScript
- Stelle
- 123
- Fork
- 7
- Merge medio
- 9h 15m
- PR unite (30g)
- 188
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di danielroe/forges
-
enhancement
Difficoltà 4/5 1-2 giorni Idoneità per principianti 56/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement good first issue
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
danielroe/forges#244 · 1 commento · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement needs discussion
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di danielroe/forges
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
awslabs/visual-asset-management-system#937 ·
I maintainer di solito rispondono entro 1 giorno
-
t0ggles
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
nolimits4web/swiper#8255 · 1 commento ·
I maintainer di solito rispondono entro 15 giorni
-
render: --variables-file (and --variables <path>) fails with "io.readFile is not a function" since 0.8.212Forse già presa @miguel-heygen l’ha presa oggi. Apertabug triage/needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
heygen-com/hyperframes#6830 ·
I maintainer di solito rispondono entro 1 giorno
-
bug launch local use
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
account: profile bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 5 giorni