Skip to content

✨ feat: add passthrough for verbatim issue keys#77

Merged
djk01281 merged 3 commits into
mainfrom
feature/76
Jul 1, 2026
Merged

✨ feat: add passthrough for verbatim issue keys#77
djk01281 merged 3 commits into
mainfrom
feature/76

Conversation

@djk01281

@djk01281 djk01281 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Before vs After

  • Previously the helper matched only <prefix>/<number> branches (e.g. feature/123), looked the prefix up in rules, and produced a GitHub reference like #123 or org/repo#123. A branch carrying a full tracker key such as feature/PROJ-123 matched nothing, so the commit stayed untagged.
  • Now it also recognizes full issue keys (Jira, Linear, and similar, shaped PROJECT-123) for the projects you list, and copies them into the message verbatim. The existing rules behavior is unchanged and still wins when a branch matches both.

Behavior by case

With this config:

{
    "rules": { "feature": null, "qa": "org/repo" },
    "passthrough": ["PROJ"], // 명시 필요
    "protect": ["main"]
}
Branch Commit tag Resolver vs before
feature/123 [#123] rules unchanged
qa/45 [org/repo#45] rules unchanged
feature/PROJ-123 [PROJ-123] passthrough new
PROJ-123 [PROJ-123] passthrough new
feature/PROJ-123-add-login [PROJ-123] passthrough new
feature/PROJ-123_wip [PROJ-123] passthrough new
feature/OPS-9 untouched none (OPS not listed) new
feature/12-ABC-34 [#12] rules wins unchanged
feature/wip untouched none unchanged
main commit blocked protect unchanged

passthrough

passthrough lists the project keys to copy verbatim; rules (GitHub prefixes) still take precedence when a branch matches both.

Value Recognizes
["PROJ", …] only the listed project keys
omitted / [] nothing (verbatim tagging off)

Only listed projects are tagged, so unrelated UPPERCASE-NUMBER tokens (e.g. UTF-8, SHA-1) are never mistaken for issues.

Branch recognition

passthrough recognizes a key shaped PROJECT-NUMBER - an uppercase project ([A-Z][A-Z0-9]+, ≥2 chars), a hyphen, and a 1–7 digit number - appearing anywhere in the branch.

For a passthrough entry PROJ:

Branch Tagged Why
PROJ-123 [PROJ-123] bare key
feature/PROJ-123 [PROJ-123] key after a path prefix
feature_PROJ-123 [PROJ-123] characters before the key don't matter
PROJ-123-add-login [PROJ-123] description suffix (after the number) is ignored
PROJ-123_wip [PROJ-123] any suffix after the number is ignored
PROJ-123-20260101 [PROJ-123] a -<number> (date) suffix is ignored too
PROJ-123/anything [PROJ-123] trailing path is fine
PROJ-12345678 not tagged the number has more than 7 digits
PROJ/123 not tagged a key uses - (PROJ-123); the slash form is a rules prefix
PROJ_123 not tagged project and number must be joined by -
proj-123 not tagged the project part must be uppercase
OPS-123 not tagged OPS is not listed

So name the branch with the key joined by a hyphen — PROJ-123 or feature/PROJ-123-short-desc. PROJ_123 (underscore) and PROJ/123 (slash) are not keys; a suffix after the number (-desc, _wip, -20260101, /path) is fine.

Configuration example

{
    "$schema": "./node_modules/@naverpay/commithelper-go/schema.json",
    "rules": { "feature": null, "qa": "org/repo" },
    "passthrough": ["PROJ"],
    "protect": ["main", "release/*"],
    "template": "{{.Message}}\n\nRef. [{{.Prefix}}]"
}

$schema is optional; it gives editor autocompletion and validation and resolves from the installed package (offline, no CDN).

Fixes included

Idempotency (isAlreadyTaggedalreadyHasRef). The old check treated a message as tagged only when it started with a bracketed reference matching ^\[.*?#\d+\]. That was tied to the default format and the #number shape, so a custom template placing the reference in the body went undetected and was re-added on every amend. It is replaced by alreadyHasRef, which checks whether the branch's resolved reference is already present anywhere in the message as a whole token (so #123 is not found in #1234, and PROJ-1871 is not found in MY-PROJ-1871). This is template-independent and works for verbatim keys too.

On branch feature/123 (resolved reference #123):

Incoming message Old isAlreadyTagged New alreadyHasRef
[#123] fix skip skip
fix with Ref. [#123] in body re-tag (bug) skip
[#999] fix (different reference) skip adds [#123]
fix tag tag

The third row is the one intentional behavior change: the old check skipped when the message started with any bracketed reference; the new check skips only when this branch's own reference is present.

Protected branch ordering. Branch protection now runs before the already-tagged check, so a message that already contains a tag can no longer slip past protect.

Tests

resolveKey is covered by a table that mirrors Jigit's rules (TestResolveKey_JigitParity) - every branch Jigit's docs list as recognized/ignored is asserted here - plus edge cases (8-digit numbers, _/date suffixes, longer-key boundaries, unlisted projects). alreadyHasRef and processMessage cover the idempotency and protect behavior above.

@djk01281 djk01281 self-assigned this Jun 30, 2026
@npayfebot

npayfebot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

✅ Changeset detected

Latest commit: f5bd805

@naverpay/commithelper-go package have detected changes.

If no version change is needed, please add skip-detect-change to the label.

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@naverpay/commithelper-go ✨ Minor
@naverpay/commithelper-go-darwin-arm64 ✨ Minor
@naverpay/commithelper-go-darwin-x64 ✨ Minor
@naverpay/commithelper-go-linux-x64 ✨ Minor
@naverpay/commithelper-go-win32-x64 ✨ Minor
powered by: naverpay changeset detect-add actions

@djk01281

Copy link
Copy Markdown
Contributor Author

/canary-publish

@djk01281

Copy link
Copy Markdown
Contributor Author

@claude review this PR

@npayfebot

Copy link
Copy Markdown
Contributor

Published Canary Packages

@naverpay/commithelper-go@1.4.0-canary.260630-96b8be8

Recognize full tracker keys (Jira/Linear style, e.g. PROJ-123) in the branch and copy them into the commit message unchanged, via a new `passthrough` config ("uppercase" for any uppercase key shape, or an array of project keys). GitHub-style `rules` are unchanged and take precedence when a branch matches both.

Also fix idempotency to detect the resolved reference anywhere in the message, so body-placed templates no longer double-tag on git commit --amend; and evaluate branch protection before the already-tagged check so a pre-tagged message cannot bypass protect.

Ship schema.json in the package for editor autocompletion and validation.
@djk01281

djk01281 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author
image

@_@

@djk01281

djk01281 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

/canary-publish

@npayfebot

Copy link
Copy Markdown
Contributor

Published Canary Packages

@naverpay/commithelper-go@1.4.0-canary.260701-5bcae77
@naverpay/commithelper-go-darwin-arm64@1.4.0-canary.260701-5bcae77
@naverpay/commithelper-go-darwin-x64@1.4.0-canary.260701-5bcae77
@naverpay/commithelper-go-linux-x64@1.4.0-canary.260701-5bcae77
@naverpay/commithelper-go-win32-x64@1.4.0-canary.260701-5bcae77

@kyungmi

kyungmi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@djk01281 님, 작업 감사합니다. 혹시 @naverpay/commithelper 쪽에도 동일 작업 부탁드려도 될까요?

- `passthrough` is now an explicit project-key list (`["PROJ"]`);
  recognition follows Jigit's rule (<PROJECT>-<1-7 digits>, anywhere in
  the branch), so a listed project links identically in commithelper and
  Jigit
- fix idempotency whole-token boundary so a reference is not matched
  inside a longer key (e.g. PROJ-1871 within MY-PROJ-1871)
- update schema, README, tests (incl. a Jigit-parity table), and fold
  the changeset into a single note

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@djk01281

djk01281 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

/canary-publish

@djk01281

djk01281 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@djk01281 님, 작업 감사합니다. 혹시 @naverpay/commithelper 쪽에도 동일 작업 부탁드려도 될까요?

넵! 확인했습니다! 🙇🏻

@npayfebot

Copy link
Copy Markdown
Contributor

Published Canary Packages

@naverpay/commithelper-go@1.4.0-canary.260701-bea4bcc
@naverpay/commithelper-go-darwin-arm64@1.4.0-canary.260701-bea4bcc
@naverpay/commithelper-go-darwin-x64@1.4.0-canary.260701-bea4bcc
@naverpay/commithelper-go-linux-x64@1.4.0-canary.260701-bea4bcc
@naverpay/commithelper-go-win32-x64@1.4.0-canary.260701-bea4bcc

@djk01281 djk01281 marked this pull request as ready for review July 1, 2026 05:28
@djk01281 djk01281 requested a review from a team as a code owner July 1, 2026 05:28
@kyungmi

kyungmi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

@djk01281 혹시 commithelper쪽 작업은 아직 작업 전이신거죠?

@djk01281

djk01281 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@kyungmi 님 네 규칙을 맞추려고 했어서 아직 전이긴 합니다,,!

yujeong-jeon
yujeong-jeon previously approved these changes Jul 1, 2026

@yujeong-jeon yujeong-jeon 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.

LGTM~!

kyungmi
kyungmi previously approved these changes Jul 1, 2026

@kyungmi kyungmi 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.

main() 에서 순수 코어 processMessage 를 분리하고 resolve/resolvePrefix/resolveKey/alreadyHasRef 로 쪼갠 덕에 테이블 테스트가 촘촘하게 붙은 구조가 좋습니다.

  • passthrough 를 allowlist + 프로젝트 키(≥2자)·숫자(1~7자리)로 좁혀 UTF-8/SHA-1 같은 토큰 오탐을 막고, alreadyHasRef 의 토큰 경계 검사로 [PROJ-123] 재태깅까지 멱등 처리한 점이 견고합니다.
  • rules 우선 → passthrough 순서와 Jigit parity 테스트까지 있어 동작 확신이 섭니다.
  • [nit] 2건만 남깁니다: 커스텀 template + passthrough 조합에서 {{.Number}} 빈 값 / ioutil deprecated 정리. 둘 다 반영은 선택입니다.

Comment thread packages/commithelper-go/main.go Outdated
}
for _, m := range keyPattern.FindAllStringSubmatch(branch, -1) {
if len(m[2]) <= 7 && allowed[m[1]] {
return &TemplateData{Prefix: m[0]}

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.

[nit] passthrough 경로에서는 Prefix 만 채워서, 커스텀 template{{.Number}}(또는 {{.Repo}})를 참조하면 빈 값이 렌더될 수 있어요.

  • 예: "template": "{{.Message}}\n\nRef. [#{{.Number}}]" 설정 시 feature/PROJ-123 브랜치에서는 Ref. [#] 로 나옵니다. (rules 경로는 Number 가 채워져 정상)
  • 기본 template([{{.Prefix}}] {{.Message}})에는 영향이 없어 우선순위는 낮습니다. Number: m[2] 정도를 함께 채워두면 기존 template 사용자와의 호환이 깔끔해질 것 같아요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

f5bd805 수정했습니다! 한번만 더 부탁드립니닷 !

if _, err := os.Stat(input); err == nil {
// Input is a file path
isFile = true
commitMessageBytes, err := ioutil.ReadFile(input)

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.

[nit] io/ioutil 은 Go 1.16 부터 deprecated 라(현재 go.mod 1.24.4), 이 리팩터링 겸 os/io 로 정리해도 좋을 것 같아요.

  • ioutil.ReadFile/WriteFileos.ReadFile/os.WriteFile, ioutil.ReadAllio.ReadAll
  • 이 PR 스코프(passthrough)와는 무관해서 별도 정리로 빼도 무방합니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

별도로 나중에 수정해보겠습니다! 감사합니다!

resolveKey only set Prefix, so a custom template using {{.Number}}
(e.g. "Ref. [#{{.Number}}]") rendered "[#]" on a passthrough branch.
Set Number to the key's number part; Repo stays empty (a verbatim key
has no repo). The default [{{.Prefix}}] template is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@djk01281 djk01281 dismissed stale reviews from kyungmi and yujeong-jeon via f5bd805 July 1, 2026 06:01

@keemhyunseok keemhyunseok left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

감사합니다

@djk01281 djk01281 merged commit 643fc05 into main Jul 1, 2026
7 checks passed
@djk01281 djk01281 deleted the feature/76 branch July 1, 2026 08:25
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.

[commit-helper-go] 대문자 패턴 인식 가능 옵션 추가

5 participants