File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed
Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -469,5 +469,35 @@ describe('git', () => {
469469 expect ( execute ) . toHaveBeenCalledTimes ( 17 )
470470 expect ( response ) . toBe ( Status . SUCCESS )
471471 } )
472+
473+ it ( 'should generate temporary branch name without forward slashes to avoid conflicts' , async ( ) => {
474+ Object . assign ( action , {
475+ hostname : 'github.com' ,
476+ silent : false ,
477+ folder : 'assets' ,
478+ branch : 'branch' ,
479+ token : '123' ,
480+ repositoryName : 'JamesIves/montezuma' ,
481+ pusher : {
482+ name : 'asd' ,
483+ email : 'as@cat'
484+ } ,
485+ isTest : TestFlag . HAS_CHANGED_FILES
486+ } )
487+
488+ await deploy ( action )
489+
490+ // Check that execute was called with a checkout command that doesn't contain forward slashes in branch name
491+ const executeCalls = ( execute as jest . Mock ) . mock . calls
492+ const checkoutCall = executeCalls . find ( ( call ) =>
493+ call [ 0 ] . includes ( 'checkout -b' ) && call [ 0 ] . includes ( 'github-pages-deploy-action' )
494+ )
495+
496+ expect ( checkoutCall ) . toBeDefined ( )
497+ // The branch name should contain 'github-pages-deploy-action-' (with hyphen, not slash)
498+ expect ( checkoutCall [ 0 ] ) . toMatch ( / g i t h u b - p a g e s - d e p l o y - a c t i o n - [ a - z 0 - 9 ] + / )
499+ // The branch name should NOT contain forward slashes
500+ expect ( checkoutCall [ 0 ] ) . not . toMatch ( / g i t h u b - p a g e s - d e p l o y - a c t i o n \/ / )
501+ } )
472502 } )
473503} )
Original file line number Diff line number Diff line change @@ -108,7 +108,7 @@ export async function init(action: ActionInterface): Promise<void | Error> {
108108export async function deploy ( action : ActionInterface ) : Promise < Status > {
109109 const temporaryDeploymentDirectory =
110110 'github-pages-deploy-action-temp-deployment-folder'
111- const temporaryDeploymentBranch = `github-pages-deploy-action/ ${ Math . random ( )
111+ const temporaryDeploymentBranch = `github-pages-deploy-action- ${ Math . random ( )
112112 . toString ( 36 )
113113 . substr ( 2 , 9 ) } `
114114 const rsyncVersion = getRsyncVersion ( )
You can’t perform that action at this time.
0 commit comments