refactor(engine): CSM 코드 구조 및 가독성 개선#915
Merged
Merged
Conversation
- Extract utility functions from buildCSMNode into csm.util.ts - getMergeParentCommit: Get merge parent commit - findSquashStartNodeIndex: Find node index in stem - findSquashEndIndex: Find end index for squash collection - collectSquashNodes: Collect nodes and remove from stem - extractNestedMergeParents: Extract nested merge parents - Create csm.const.ts for magic number constants - MERGE_PARENT_INDEX: Merge parent index - FIRST_PARENT_INDEX: First parent index - Refactor buildCSMNode function - Reduce function length from 72 lines to ~50 lines - Remove non-null assertions (! operator) - Improve type safety with optional chaining - Add clear comments for each step - Add comprehensive JSDoc documentation - Document all public and private functions - Add parameter and return type descriptions
ytaek
requested changes
Sep 30, 2025
ytaek
left a comment
Contributor
There was a problem hiding this comment.
와 눈물나는 PR입니다!!!!
코드를 완벽히 이해한 다음에, 멋진 문서화를 하셨네요!!!!!!
코드 자체에 설명을 다 녹여놓은 완벽한 상태 같습니다!!!
firstparent 관련 용어관련 리뷰 하나만 달아놓았는데, 이것만 반영해주시면 감사하겠습니다!!
| import type { CommitDict, CommitNode, Stem } from "./types"; | ||
|
|
||
| /** Gets the second parent (starting point of merged branch) of a merge commit. */ | ||
| export const getMergeParentCommit = (baseCommitNode: CommitNode, commitDict: CommitDict): CommitNode | undefined => { |
Contributor
There was a problem hiding this comment.
이게 정확하게는 git domain에서 사용하는 용어가 firstParent 입니다.
parent는 복수개가 있을 수가 있고,
stem할 때는 편의상 git의 firstparent를 따라가는 걸로 githru 초창기부터 구현해놓았습니다!
function 이름에도 반영해주시면 감사하겠습니다!
Contributor
Author
There was a problem hiding this comment.
반영했습니다! 확인 감사합니다ㅎㅎ 상수도 이름 변경했습니다!
Comment on lines
+73
to
+80
| /** | ||
| * Integrates Pull Request information into a CSM node. | ||
| * Reflects PR details in commit message and statistics. | ||
| * | ||
| * @param csmNode - Existing CSM node | ||
| * @param pr - Pull Request information | ||
| * @returns CSM node with integrated PR information | ||
| */ |
Contributor
There was a problem hiding this comment.
오우 function document 도 넘 좋습니다!!! 주석이라면(?) 이 정도는 되어야 주석이죠!!
Consolidate MERGE_PARENT_INDEX and FIRST_PARENT_INDEX into a single FIRST_PARENT_INDEX constant, and rename getMergeParentCommit to getFirstParentCommit to improve code consistency and clarity. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Kyoungwoong
approved these changes
Oct 1, 2025
Kyoungwoong
left a comment
There was a problem hiding this comment.
주석과 함수명이 직관적이라서 이해하기 쉬운거 같아요!!
고생하셨습니다~~
SingTheCode
changed the base branch from
feature/#870_delete-csm-reverse
to
core/CSMDict
October 5, 2025 14:18
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.
🎯 목적
CSM 빌드 로직의 코드 구조를 개선하고 가독성을 향상시킵니다.
📋 주요 변경사항
1. 유틸리티 함수 분리 (
csm.util.ts)getMergeParentCommit: 머지 커밋의 부모 커밋 조회findSquashStartNodeIndex: stem에서 특정 커밋 노드 인덱스 탐색findSquashEndIndex: squash 수집 종료 인덱스 계산collectSquashNodes: 노드 수집 및 stem에서 제거extractNestedMergeParents: 중첩된 머지의 부모 커밋 추출2. 상수 파일 추가 (
csm.const.ts)MERGE_PARENT_INDEX: 머지 커밋의 두 번째 부모 인덱스 (1)FIRST_PARENT_INDEX: 첫 번째 부모 인덱스 (0)3. 메인 로직 개선 (
csm.ts)📊 영향 범위
✅ 체크리스트
🔍 리팩토링 세부사항
Before
After
📝 비고