@@ -184,6 +184,70 @@ return function()
184184
185185 helpers .cleanup_test_env ()
186186 end )
187+
188+ helpers .test (" standalone branch is not overridden by nil dependency branch" , function ()
189+ helpers .setup_test_env ()
190+
191+ require (' zpack' ).setup ({
192+ spec = {
193+ {
194+ ' test/parent' ,
195+ dependencies = {
196+ ' test/dep' ,
197+ },
198+ },
199+ {
200+ ' test/dep' ,
201+ branch = ' main' ,
202+ },
203+ },
204+ defaults = { confirm = false },
205+ })
206+
207+ helpers .flush_pending ()
208+ local state = require (' zpack.state' )
209+ local src = ' https://github.com/test/dep'
210+
211+ local merged_spec = state .spec_registry [src ].merged_spec
212+ helpers .assert_equal (merged_spec .branch , ' main' , " standalone branch should be preserved" )
213+
214+ local pack_spec = state .src_to_pack_spec [src ]
215+ helpers .assert_equal (pack_spec .version , ' main' , " pack_spec.version should use merged branch" )
216+
217+ helpers .cleanup_test_env ()
218+ end )
219+
220+ helpers .test (" dependency branch is used when standalone has no branch" , function ()
221+ helpers .setup_test_env ()
222+
223+ require (' zpack' ).setup ({
224+ spec = {
225+ {
226+ ' test/parent' ,
227+ dependencies = {
228+ { ' test/dep' , branch = ' develop' },
229+ },
230+ },
231+ {
232+ ' test/dep' ,
233+ config = function () end ,
234+ },
235+ },
236+ defaults = { confirm = false },
237+ })
238+
239+ helpers .flush_pending ()
240+ local state = require (' zpack.state' )
241+ local src = ' https://github.com/test/dep'
242+
243+ local merged_spec = state .spec_registry [src ].merged_spec
244+ helpers .assert_equal (merged_spec .branch , ' develop' , " dependency branch should be used when standalone has none" )
245+
246+ local pack_spec = state .src_to_pack_spec [src ]
247+ helpers .assert_equal (pack_spec .version , ' develop' , " pack_spec.version should use dependency branch" )
248+
249+ helpers .cleanup_test_env ()
250+ end )
187251 end )
188252
189253 helpers .describe (" Merge Module Unit Tests" , function ()
0 commit comments