feat(ship): Phase 1 template variable substitution · Refs #304 - #424
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
무엇
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.rssubstitute_template_vars()신규 함수 +build_pr_body()에branch파라미터 추가 + template 치환 로직 + 5 unit tests지원 변수
{{ticket}}CL-1234){{branch}}{{title}}{{ticket_url}}미지원
{{…}}토큰은 그대로 유지 (다른 tooling 변수 보호).예시 template
ship 실행 후:
다음 Phase 힌트
{{commits}}변수 — git log 요약 자동 삽입--template명시 옵션 + config에 default template 경로 설정리스크
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 test178 tests pass ✅ (90 + 5 unit + 83 integration)@erishforG