@@ -38,6 +38,35 @@ test("resolveReviewTarget falls back to branch diff when repo is clean", () => {
3838 assert . match ( context . content , / B r a n c h D i f f / ) ;
3939} ) ;
4040
41+ test ( "default branch names with special characters are passed to git literally" , ( ) => {
42+ const cwd = makeTempDir ( ) ;
43+ const branchName = "main&branch-helper&x" ;
44+ const helperOutputPath = path . join ( cwd , "branch-helper-output" ) ;
45+ initGitRepo ( cwd ) ;
46+ fs . writeFileSync ( path . join ( cwd , "branch-helper.cmd" ) , "@echo branch-helper>branch-helper-output\r\n" ) ;
47+ fs . writeFileSync ( path . join ( cwd , "app.js" ) , "console.log('base');\n" ) ;
48+ run ( "git" , [ "add" , "app.js" , "branch-helper.cmd" ] , { cwd } ) ;
49+ run ( "git" , [ "commit" , "-m" , "base" ] , { cwd } ) ;
50+ run ( "git" , [ "branch" , "-m" , branchName ] , { cwd, shell : false } ) ;
51+ run ( "git" , [ "update-ref" , `refs/remotes/origin/${ branchName } ` , branchName ] , { cwd, shell : false } ) ;
52+ run ( "git" , [ "symbolic-ref" , "refs/remotes/origin/HEAD" , `refs/remotes/origin/${ branchName } ` ] , {
53+ cwd,
54+ shell : false
55+ } ) ;
56+ run ( "git" , [ "checkout" , "-b" , "feature/test" ] , { cwd } ) ;
57+ fs . writeFileSync ( path . join ( cwd , "app.js" ) , "console.log('feature');\n" ) ;
58+ run ( "git" , [ "add" , "app.js" ] , { cwd } ) ;
59+ run ( "git" , [ "commit" , "-m" , "feature" ] , { cwd } ) ;
60+
61+ const target = resolveReviewTarget ( cwd , { } ) ;
62+ const context = collectReviewContext ( cwd , target ) ;
63+
64+ assert . equal ( target . mode , "branch" ) ;
65+ assert . equal ( target . baseRef , branchName ) ;
66+ assert . match ( context . content , / B r a n c h D i f f / ) ;
67+ assert . equal ( fs . existsSync ( helperOutputPath ) , false ) ;
68+ } ) ;
69+
4170test ( "resolveReviewTarget honors explicit base overrides" , ( ) => {
4271 const cwd = makeTempDir ( ) ;
4372 initGitRepo ( cwd ) ;
0 commit comments