7171
7272 // uploadRepositoryChangesFunc is a must-not-call test seam used to prove offline/file modes suppress git upload.
7373 uploadRepositoryChangesFunc = uploadRepositoryChanges
74+
75+ // getSearchCommitsFunc allows tests to exercise repository upload control flow without reading local git state.
76+ getSearchCommitsFunc = getSearchCommits
77+
78+ // unshallowGitRepositoryFunc allows tests to control the fallback branch without mutating the local repository.
79+ unshallowGitRepositoryFunc = utils .UnshallowGitRepository
80+
81+ // sendObjectsPackFileFunc allows tests to inspect the upload request without creating or sending real pack files.
82+ sendObjectsPackFileFunc = sendObjectsPackFile
7483)
7584
7685// ensureSettingsInitialization performs the one-time settings bootstrap, including any git upload work required before a final settings read.
@@ -380,7 +389,7 @@ func GetImpactedTestsAnalyzer() *impactedtests.ImpactedTestAnalyzer {
380389// uploadRepositoryChanges discovers the commits and packfiles that must be uploaded so backend features can reason about the current repo state.
381390func uploadRepositoryChanges () (bytes int64 , err error ) {
382391 // get the search commits response
383- initialCommitData , err := getSearchCommits ()
392+ initialCommitData , err := getSearchCommitsFunc ()
384393 if err != nil {
385394 return 0 , fmt .Errorf ("civisibility: error getting the search commits response: %s" , err )
386395 }
@@ -409,7 +418,7 @@ func uploadRepositoryChanges() (bytes int64, err error) {
409418 }
410419
411420 // there's some missing commits on the backend, first we need to check if we need to unshallow before sending anything...
412- hasBeenUnshallowed , err := utils . UnshallowGitRepository ()
421+ hasBeenUnshallowed , err := unshallowGitRepositoryFunc ()
413422 if err != nil || ! hasBeenUnshallowed {
414423 if err != nil {
415424 log .Warn ("%s" , err .Error ())
@@ -418,11 +427,11 @@ func uploadRepositoryChanges() (bytes int64, err error) {
418427 // the initial commit data
419428
420429 // send the pack file with the missing commits
421- return sendObjectsPackFile (initialCommitData .LocalCommits [0 ], initialMissingCommits , initialCommitData .RemoteCommits )
430+ return sendObjectsPackFileFunc (initialCommitData .LocalCommits [0 ], initialMissingCommits , initialCommitData .RemoteCommits )
422431 }
423432
424433 // after unshallowing the repository we need to get the search commits to calculate the missing commits again
425- commitsData , err := getSearchCommits ()
434+ commitsData , err := getSearchCommitsFunc ()
426435 if err != nil {
427436 return 0 , fmt .Errorf ("civisibility: error getting the search commits response: %s" , err )
428437 }
@@ -433,7 +442,7 @@ func uploadRepositoryChanges() (bytes int64, err error) {
433442 }
434443
435444 // send the pack file with the missing commits
436- return sendObjectsPackFile (commitsData .LocalCommits [0 ], commitsData .missingCommits (), commitsData .RemoteCommits )
445+ return sendObjectsPackFileFunc (commitsData .LocalCommits [0 ], commitsData .missingCommits (), commitsData .RemoteCommits )
437446}
438447
439448// getSearchCommits gets the search commits response with the local and remote commits
0 commit comments