@@ -13,7 +13,7 @@ import (
1313var addWorkflowPRLog = logger .New ("cli:add_workflow_pr" )
1414
1515// addWorkflowsWithPR handles workflow addition with PR creation and returns the PR number and URL.
16- func addWorkflowsWithPR (workflows []* WorkflowSpec , number int , verbose bool , quiet bool , engineOverride string , name string , force bool , appendText string , push bool , noGitattributes bool , fromWildcard bool , workflowDir string , noStopAfter bool , stopAfter string ) (int , string , error ) {
16+ func addWorkflowsWithPR (workflows []* WorkflowSpec , opts AddOptions ) (int , string , error ) {
1717 addWorkflowPRLog .Printf ("Adding %d workflow(s) with PR creation" , len (workflows ))
1818
1919 // Get current branch for restoration later
@@ -31,7 +31,7 @@ func addWorkflowsWithPR(workflows []*WorkflowSpec, number int, verbose bool, qui
3131
3232 addWorkflowPRLog .Printf ("Creating temporary branch: %s" , branchName )
3333
34- if err := createAndSwitchBranch (branchName , verbose ); err != nil {
34+ if err := createAndSwitchBranch (branchName , opts . Verbose ); err != nil {
3535 return 0 , "" , fmt .Errorf ("failed to create branch %s: %w" , branchName , err )
3636 }
3737
@@ -43,33 +43,36 @@ func addWorkflowsWithPR(workflows []*WorkflowSpec, number int, verbose bool, qui
4343
4444 // Ensure we switch back to original branch on exit
4545 defer func () {
46- if switchErr := switchBranch (currentBranch , verbose ); switchErr != nil && verbose {
46+ if switchErr := switchBranch (currentBranch , opts . Verbose ); switchErr != nil && opts . Verbose {
4747 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to switch back to branch %s: %v" , currentBranch , switchErr )))
4848 }
4949 }()
5050
5151 // Add workflows using the normal function logic
5252 addWorkflowPRLog .Print ("Adding workflows to repository" )
53- if err := addWorkflowsNormal (workflows , number , verbose , quiet , engineOverride , name , force , appendText , push , noGitattributes , fromWildcard , workflowDir , noStopAfter , stopAfter ); err != nil {
53+ // Disable security scanner for PR creation to use workflow settings
54+ prOpts := opts
55+ prOpts .DisableSecurityScanner = false
56+ if err := addWorkflowsNormal (workflows , prOpts ); err != nil {
5457 addWorkflowPRLog .Printf ("Failed to add workflows: %v" , err )
5558 // Rollback on error
56- if rollbackErr := tracker .RollbackAllFiles (verbose ); rollbackErr != nil && verbose {
59+ if rollbackErr := tracker .RollbackAllFiles (opts . Verbose ); rollbackErr != nil && opts . Verbose {
5760 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to rollback files: %v" , rollbackErr )))
5861 }
5962 return 0 , "" , fmt .Errorf ("failed to add workflows: %w" , err )
6063 }
6164
6265 // Stage all files before creating PR
6366 addWorkflowPRLog .Print ("Staging workflow files" )
64- if err := tracker .StageAllFiles (verbose ); err != nil {
65- if rollbackErr := tracker .RollbackAllFiles (verbose ); rollbackErr != nil && verbose {
67+ if err := tracker .StageAllFiles (opts . Verbose ); err != nil {
68+ if rollbackErr := tracker .RollbackAllFiles (opts . Verbose ); rollbackErr != nil && opts . Verbose {
6669 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to rollback files: %v" , rollbackErr )))
6770 }
6871 return 0 , "" , fmt .Errorf ("failed to stage workflow files: %w" , err )
6972 }
7073
71- // Update .gitattributes and stage it if modified
72- if err := stageGitAttributesIfChanged (); err != nil && verbose {
74+ // Update .gitattributes and stage it if changed
75+ if err := stageGitAttributesIfChanged (); err != nil && opts . Verbose {
7376 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to stage .gitattributes: %v" , err )))
7477 }
7578
@@ -92,29 +95,29 @@ func addWorkflowsWithPR(workflows []*WorkflowSpec, number int, verbose bool, qui
9295 prBody = fmt .Sprintf ("Add agentic workflows: %s" , joinedNames )
9396 }
9497
95- if err := commitChanges (commitMessage , verbose ); err != nil {
96- if rollbackErr := tracker .RollbackAllFiles (verbose ); rollbackErr != nil && verbose {
98+ if err := commitChanges (commitMessage , opts . Verbose ); err != nil {
99+ if rollbackErr := tracker .RollbackAllFiles (opts . Verbose ); rollbackErr != nil && opts . Verbose {
97100 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to rollback files: %v" , rollbackErr )))
98101 }
99102 return 0 , "" , fmt .Errorf ("failed to commit files: %w" , err )
100103 }
101104
102105 // Push branch
103106 addWorkflowPRLog .Printf ("Pushing branch %s to remote" , branchName )
104- if err := pushBranch (branchName , verbose ); err != nil {
107+ if err := pushBranch (branchName , opts . Verbose ); err != nil {
105108 addWorkflowPRLog .Printf ("Failed to push branch: %v" , err )
106- if rollbackErr := tracker .RollbackAllFiles (verbose ); rollbackErr != nil && verbose {
109+ if rollbackErr := tracker .RollbackAllFiles (opts . Verbose ); rollbackErr != nil && opts . Verbose {
107110 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to rollback files: %v" , rollbackErr )))
108111 }
109112 return 0 , "" , fmt .Errorf ("failed to push branch %s: %w" , branchName , err )
110113 }
111114
112115 // Create PR
113116 addWorkflowPRLog .Printf ("Creating pull request: %s" , prTitle )
114- prNumber , prURL , err := createPR (branchName , prTitle , prBody , verbose )
117+ prNumber , prURL , err := createPR (branchName , prTitle , prBody , opts . Verbose )
115118 if err != nil {
116119 addWorkflowPRLog .Printf ("Failed to create PR: %v" , err )
117- if rollbackErr := tracker .RollbackAllFiles (verbose ); rollbackErr != nil && verbose {
120+ if rollbackErr := tracker .RollbackAllFiles (opts . Verbose ); rollbackErr != nil && opts . Verbose {
118121 fmt .Fprintln (os .Stderr , console .FormatWarningMessage (fmt .Sprintf ("Failed to rollback files: %v" , rollbackErr )))
119122 }
120123 return 0 , "" , fmt .Errorf ("failed to create PR: %w" , err )
@@ -125,7 +128,7 @@ func addWorkflowsWithPR(workflows []*WorkflowSpec, number int, verbose bool, qui
125128 // Success - no rollback needed
126129
127130 // Switch back to original branch
128- if err := switchBranch (currentBranch , verbose ); err != nil {
131+ if err := switchBranch (currentBranch , opts . Verbose ); err != nil {
129132 return prNumber , prURL , fmt .Errorf ("failed to switch back to branch %s: %w" , currentBranch , err )
130133 }
131134
0 commit comments