1717import { describe , it , beforeEach , afterEach , afterAll , expect , vi } from 'vitest' ;
1818import fs from 'fs' ;
1919import path from 'path' ;
20- import { execFile } from 'child_process' ;
21- import { promisify } from 'util' ;
2220import { getConfigFile } from '../src/config/file' ;
2321import {
2422 ConfigLoader ,
@@ -35,8 +33,6 @@ import {
3533} from '../src/config/types' ;
3634import axios from 'axios' ;
3735
38- const execFileAsync = promisify ( execFile ) ;
39-
4036describe ( 'ConfigLoader' , ( ) => {
4137 let configLoader : ConfigLoader ;
4238 let tempDir : string ;
@@ -475,64 +471,6 @@ describe('ConfigLoader', () => {
475471 expect ( config ) . toHaveProperty ( 'cookieSecret' ) ;
476472 } , 10000 ) ;
477473
478- it ( 'should recover a cached git repository that is on a detached HEAD' , async ( ) => {
479- const source : GitSource = {
480- type : 'git' ,
481- repository : 'https://example.com/git-proxy-config-test.git' ,
482- path : 'proxy.config.json' ,
483- branch : 'main' ,
484- enabled : true ,
485- } ;
486- const remoteDir = path . resolve ( tempDir , 'remote.git' ) ;
487- const workDir = path . resolve ( tempDir , 'work' ) ;
488- const envPaths = ( await import ( 'env-paths' ) ) . default ;
489- const paths = envPaths ( 'git-proxy' , { suffix : '' } ) ;
490- const repoDirName = Buffer . from ( source . repository )
491- . toString ( 'base64' )
492- . replace ( / [ ^ a - z A - Z 0 - 9 ] / g, '_' ) ;
493- const repoDir = path . join ( paths . cache , 'git-config-cache' , repoDirName ) ;
494-
495- if ( fs . existsSync ( repoDir ) ) {
496- fs . rmSync ( repoDir , { recursive : true } ) ;
497- }
498-
499- await execFileAsync ( 'git' , [ 'init' , '--bare' , remoteDir ] ) ;
500- await execFileAsync ( 'git' , [ 'init' , '--initial-branch=main' , workDir ] ) ;
501- fs . writeFileSync (
502- path . join ( workDir , source . path ) ,
503- JSON . stringify ( { proxyUrl : 'https://test.com' , cookieSecret : 'from-cache' } ) ,
504- ) ;
505- await execFileAsync ( 'git' , [ 'add' , source . path ] , { cwd : workDir } ) ;
506- await execFileAsync (
507- 'git' ,
508- [
509- '-c' ,
510- 'user.email=test@example.com' ,
511- '-c' ,
512- 'user.name=git-proxy test' ,
513- 'commit' ,
514- '-m' ,
515- 'add config' ,
516- ] ,
517- { cwd : workDir } ,
518- ) ;
519- await execFileAsync ( 'git' , [ 'remote' , 'add' , 'origin' , remoteDir ] , { cwd : workDir } ) ;
520- await execFileAsync ( 'git' , [ 'push' , '-u' , 'origin' , 'main' ] , { cwd : workDir } ) ;
521- await execFileAsync ( 'git' , [ 'clone' , remoteDir , repoDir ] ) ;
522- // The clone's default branch follows the host's `init.defaultBranch`, which
523- // may differ from the pushed `main` (e.g. `master` on CI), leaving local
524- // HEAD unborn. Detach at the pushed commit by SHA so HEAD is reliably
525- // detached and the working tree is populated on every git version.
526- const { stdout : headSha } = await execFileAsync ( 'git' , [ 'rev-parse' , 'origin/main' ] , {
527- cwd : repoDir ,
528- } ) ;
529- await execFileAsync ( 'git' , [ 'checkout' , headSha . trim ( ) ] , { cwd : repoDir } ) ;
530-
531- const config = await configLoader . loadFromSource ( source ) ;
532-
533- expect ( config . cookieSecret ) . toBe ( 'from-cache' ) ;
534- } ) ;
535-
536474 it ( 'should throw error for invalid configuration file path (git)' , async ( ) => {
537475 const source : GitSource = {
538476 type : 'git' ,
0 commit comments