Skip to content

feat(ship): Phase 1 template variable substitution · Refs #304 - #424

Merged
erishforG merged 1 commit into
developfrom
feat/auto-304-template-vars-phase1
Sep 5, 2026
Merged

feat(ship): Phase 1 template variable substitution · Refs #304#424
erishforG merged 1 commit into
developfrom
feat/auto-304-template-vars-phase1

Conversation

@erishforG

Copy link
Copy Markdown
Owner

무엇

parsec ship의 PR template에 {{ticket}}, {{branch}}, {{title}}, {{ticket_url}} 변수 치환 기능을 추가합니다 (#304 Phase 1).

기존에는 .github/PULL_REQUEST_TEMPLATE.md 를 탐지해 읽어오는 것까지는 구현되어 있었지만, 파일 내용이 변수 치환 없이 verbatim으로 삽입됐습니다. 이 PR로 template 내 {{…}} placeholder가 ship 컨텍스트 값으로 치환됩니다.

이슈 #304의 AC 중 "template 변수 (commits, branch) 자동 치환"이 미구현 상태였음. 사용자가 .github/PULL_REQUEST_TEMPLATE.md{{ticket}}이나 {{branch}}를 써도 그대로 출력되어 실용성이 낮았음.

Refs #304

변경

파일 변경 내용
src/cli/commands/ship.rs substitute_template_vars() 신규 함수 + build_pr_body()branch 파라미터 추가 + template 치환 로직 + 5 unit tests

지원 변수

변수 치환 값
{{ticket}} ticket/workspace ID (예: CL-1234)
{{branch}} push된 git branch 이름
{{title}} PR 제목 (없으면 빈 문자열)
{{ticket_url}} tracker URL (없으면 빈 문자열)

미지원 {{…}} 토큰은 그대로 유지 (다른 tooling 변수 보호).

예시 template

## {{title}}

Ticket: [{{ticket}}]({{ticket_url}})
Branch: `{{branch}}`

ship 실행 후:

## feat: my change

Ticket: [CL-42](https://linear.app/CL-42)
Branch: `feature/CL-42`

다음 Phase 힌트

리스크

low — 새 private helper 함수 추가 + build_pr_body() 내부 시그니처 변경만. 외부 CLI 인터페이스 불변. template 미사용 시 동작 동일.

롤백

git revert 또는 --template 없이 사용하면 기존과 동일 동작.

Test plan

  • cargo build
  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test 178 tests pass ✅ (90 + 5 unit + 83 integration)
  • 5 신규 unit tests: all-vars, optional-vars-empty, unknown-var-intact, multi-occurrence, build_pr_body end-to-end

@erishforG

Add `substitute_template_vars()` helper that expands `{{ticket}}`,
`{{branch}}`, `{{title}}`, `{{ticket_url}}` placeholders in PR
template content before embedding it into the PR body.

Changes:
- src/cli/commands/ship.rs:
  - New `substitute_template_vars()` with RustDoc explaining each var
  - `build_pr_body()` gains `branch: &str` parameter; passes it + other
    context to substitute_template_vars when template content is present
  - Template section comment updated to reference #304 alongside #233
  - 5 unit tests: all-vars, optional-vars-empty, unknown-var-intact,
    multi-occurrence, build_pr_body end-to-end

Unknown `{{…}}` tokens are left intact so templates using other
tooling variables are not silently mangled.

Refs #304

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@erishforG erishforG added the auto-improvement Daily auto-generated improvement PR/issue label Sep 5, 2026
@erishforG
erishforG merged commit dc626ee into develop Sep 5, 2026
12 checks passed
@erishforG
erishforG deleted the feat/auto-304-template-vars-phase1 branch September 5, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-improvement Daily auto-generated improvement PR/issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant