@@ -27,6 +27,9 @@ require("./shim.cjs");
2727
2828const { getErrorMessage } = require ( "./error_helpers.cjs" ) ;
2929const { ERR_CONFIG , ERR_PARSE , ERR_SYSTEM , ERR_VALIDATION } = require ( "./error_codes.cjs" ) ;
30+ const { getSetupTimeoutMs } = require ( "./child_process_timeouts.cjs" ) ;
31+
32+ const GIT_COMMAND_TIMEOUT_MS = getSetupTimeoutMs ( "importGit" ) ;
3033
3134/**
3235 * Parse the agent import specification to extract repository details
@@ -188,11 +191,11 @@ function sparseCheckoutGithubFolder(owner, repo, ref, tempDir) {
188191
189192 try {
190193 // Initialize git repository
191- execFileSync ( "git" , [ "init" ] , { cwd : tempDir , stdio : "pipe" } ) ;
194+ execFileSync ( "git" , [ "init" ] , { cwd : tempDir , stdio : "pipe" , timeout : GIT_COMMAND_TIMEOUT_MS } ) ;
192195 core . info ( "Initialized temporary git repository" ) ;
193196
194197 // Configure sparse checkout
195- execFileSync ( "git" , [ "config" , "core.sparseCheckout" , "true" ] , { cwd : tempDir , stdio : "pipe" } ) ;
198+ execFileSync ( "git" , [ "config" , "core.sparseCheckout" , "true" ] , { cwd : tempDir , stdio : "pipe" , timeout : GIT_COMMAND_TIMEOUT_MS } ) ;
196199 core . info ( "Enabled sparse checkout" ) ;
197200
198201 // Set sparse checkout pattern to only include .github folder
@@ -201,15 +204,15 @@ function sparseCheckoutGithubFolder(owner, repo, ref, tempDir) {
201204 core . info ( "Configured sparse checkout pattern: .github/" ) ;
202205
203206 // Add remote - using execFileSync prevents shell injection
204- execFileSync ( "git" , [ "remote" , "add" , "origin" , repoUrl ] , { cwd : tempDir , stdio : "pipe" } ) ;
207+ execFileSync ( "git" , [ "remote" , "add" , "origin" , repoUrl ] , { cwd : tempDir , stdio : "pipe" , timeout : GIT_COMMAND_TIMEOUT_MS } ) ;
205208 core . info ( `Added remote: ${ repoUrl } ` ) ;
206209
207210 // Fetch and checkout - using execFileSync with validated ref
208211 core . info ( `Fetching ref: ${ ref } ` ) ;
209- execFileSync ( "git" , [ "fetch" , "--depth" , "1" , "origin" , ref ] , { cwd : tempDir , stdio : "pipe" } ) ;
212+ execFileSync ( "git" , [ "fetch" , "--depth" , "1" , "origin" , ref ] , { cwd : tempDir , stdio : "pipe" , timeout : GIT_COMMAND_TIMEOUT_MS } ) ;
210213
211214 core . info ( "Checking out .github folder" ) ;
212- execFileSync ( "git" , [ "checkout" , "FETCH_HEAD" ] , { cwd : tempDir , stdio : "pipe" } ) ;
215+ execFileSync ( "git" , [ "checkout" , "FETCH_HEAD" ] , { cwd : tempDir , stdio : "pipe" , timeout : GIT_COMMAND_TIMEOUT_MS } ) ;
213216
214217 core . info ( "Sparse checkout completed successfully" ) ;
215218 } catch ( error ) {
0 commit comments