Repository navigation
fix: preserve literal Git paths for route inference (DEV-158) - #23
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
| const diff = gitOutput(["diff", "--name-only", "-z", "--diff-filter=ACMR", range], options.cwd); | ||
| if (diff !== null) { | ||
| return { files: splitLines(diff), range }; | ||
| return { files: splitPaths(diff), range }; |
There was a problem hiding this comment.
🟡 한글 컴포넌트 변경 시 무관한 페이지까지 비교
한글 이름의 React Router 컴포넌트를 수정하면 componentKey가 이름을 빈 문자열로 바꿉니다. 이름이 한글로만 된 다른 컴포넌트도 같은 키를 받아, 변경되지 않은 페이지까지 비교합니다.
Learn more
resolveRoutes는 Git 변경 목록과 React Router에서 발견한 컴포넌트 이름을 함께 전달합니다. parseRouterSource는 JSX의 Component 속성에서 한글 식별자도 읽습니다. matchRouterRoute는 변경된 파일과 라우트 컴포넌트의 이름을 같은 키 함수로 비교하는데, componentKey는 영문자와 숫자만 남깁니다. 기본 Git 인용 설정에서 이전 변경 목록의 한글은 이스케이프된 숫자로 남았지만, 이제 한글 파일명과 한글 컴포넌트 이름이 같은 빈 키로 합쳐집니다.
Example: /settings는 설정, /help는 도움말을 렌더링합니다. src/pages/설정.tsx만 수정하고 자동 비교를 실행하면 /settings만 선택해야 하지만 /help도 함께 선택합니다.
Recommended fix: componentKey에서 유니코드 문자와 숫자를 보존하고, matchRouterRoute에서는 빈 키끼리 일치시키지 마세요. 서로 다른 한글 컴포넌트가 등록된 Git 기반 테스트에서 변경된 컴포넌트의 경로만 선택되는지 확인하세요.
Was this helpful? React with 👍 or 👎 to provide feedback.
| const diff = gitOutput(["diff", "--name-only", "-z", "--diff-filter=ACMR", range], options.cwd); | ||
| if (diff !== null) { | ||
| return { files: splitLines(diff), range }; | ||
| return { files: splitPaths(diff), range }; |
There was a problem hiding this comment.
🟡 탭이 들어간 정적 페이지의 잘못된 스크린샷 주소
탭이 들어간 정적 페이지가 변경되면 captureSide는 탭을 URL에 그대로 넣습니다. 브라우저가 탭을 제거해, 비교에서 다른 페이지를 캡처하거나 404가 발생합니다.
Learn more
staticHtmlRoute는 파일명에서 URL 경로를 만들지만 경로 세그먼트를 인코딩하지 않습니다. 이전 Git 출력에는 탭이 이스케이프되고 파일명 전체가 인용되어, 이 정적 페이지가 자동 비교에 선택되지 않았습니다. 이제 resolveRoutes가 탭을 포함한 경로를 선택하고 captureSide가 그대로 탐색 URL을 만듭니다. 브라우저에서 탭을 제거하므로 serveDirectory는 원래 파일명과 다른 경로를 받습니다. 서버는 그 경로에 해당하는 파일이나 기본 페이지를 반환하며, 둘 다 없으면 404를 반환합니다.
Example: pricing/index.html과 team\tupdates/index.html을 수정합니다. 이전 비교는 /pricing만 캡처했지만, 이제 /team%09updates 대신 /teamupdates도 요청합니다. 그 경로와 루트 index.html이 없으면 새 비교 항목은 404로 실패합니다.
Recommended fix: staticHtmlRoute에서 파일명으로부터 얻은 각 세그먼트를 URL 인코딩한 후 결합하세요. 사용자가 명시한 URL이나 이미 해석된 다른 라우터 경로에는 이 인코딩을 적용하지 마세요. 정적 서버와 자동 비교를 연결한 테스트에서 탭을 포함한 실제 HTML이 캡처되는지 확인하세요.
Was this helpful? React with 👍 or 👎 to provide feedback.
| .filter((line) => line.length > 0); | ||
| function splitPaths(value: string): string[] { | ||
| // Git -z emits literal pathnames separated by NUL, never C-quoted lines. | ||
| return value.split("\0").filter((path) => path.length > 0); |
There was a problem hiding this comment.
🟡 역슬래시가 포함된 폴더에서 존재하지 않는 경로 추론
POSIX에서 이름에 역슬래시가 있는 폴더의 파일을 변경하면 inferRoutes가 역슬래시를 폴더 구분자로 바꿉니다. 실제로는 없는 Next.js 페이지가 비교 대상으로 선택됩니다.
Learn more
Git의 NUL 구분 출력은 POSIX 파일명의 리터럴 역슬래시를 그대로 전달합니다. 기존 출력은 해당 파일명을 인용하고 역슬래시를 이스케이프했기 때문에 App Router의 app/ 판별에 걸리지 않았습니다. 이제 inferRoutes가 toPosix로 리터럴 역슬래시를 /로 바꾸고, nextAppRoute는 바뀐 경로를 실제 페이지로 인식합니다. resolveRoutes는 이 경로를 자동 캡처 대상으로 전달합니다.
Example: app\settings라는 단일 폴더 안의 page.tsx를 수정합니다. 실제 app/settings 폴더가 없는데도 /settings가 선택되어 캡처가 실패합니다.
Recommended fix: Git에서 온 경로는 이미 /가 구분자이므로, CLI와 비교 기능에서 Git 경로임을 명시해 경로 추론 중 역슬래시 변환을 생략하세요. 공개 추론 함수가 지원하던 Windows 스타일 입력은 별도로 유지하고, 회귀 테스트에서 리터럴 역슬래시가 새 경로를 만들지 않는지 확인하세요.
Was this helpful? React with 👍 or 👎 to provide feedback.
| it('preserves whitespace, quotes, backslashes and line boundaries without trimming', () => { | ||
| const f=fixture(); | ||
| const names=[' leading.tsx','trailing.tsx ','two words.tsx','tab\tname.tsx','line\nbreak.tsx','quote"name.tsx',...(process.platform==='win32'?[]:['back\\slash.tsx'])]; | ||
| f.add(names); | ||
| expect(changedFiles({cwd:f.cwd,baseRef:f.base}).files.sort()).toEqual([...names].sort()); | ||
| }); | ||
| it('uses the same lossless parsing for unrelated-history direct fallback', () => { | ||
| const f=fixture(); | ||
| f.git('checkout','--quiet','--orphan','unrelated'); | ||
| f.add(['app/설정/page.tsx','tabs\tand\nlines.tsx',' trailing ']); |
| try { | ||
| return execFileSync("git", args, { | ||
| cwd, | ||
| encoding: "utf8", |
| .filter((line) => line.length > 0); | ||
| function splitPaths(value: string): string[] { | ||
| // Git -z emits literal pathnames separated by NUL, never C-quoted lines. | ||
| return value.split("\0").filter((path) => path.length > 0); |
There was a problem hiding this comment.
🟨 PR 파일명이 터미널의 경로 목록을 변조할 수 있음
검토자가 PR 브랜치에서 proofshot routes를 실행하면 commandRoutes는 파일명을 그대로 출력합니다. PR 작성자가 파일명에 넣은 제어 문자가 터미널에서 해석되어 경로 목록을 숨기거나 덮어쓸 수 있습니다.
Was this helpful? React with 👍 or 👎 to provide feedback.
Summary
git diff --name-only -zoutput in both merge-base and direct fallback paths.Validation
Refs DEV-158.