@@ -255,6 +255,25 @@ func prepareTestEnv(t testing.TB, skip ...int) func() {
255255 assert .NoError (t , util .RemoveAll (setting .RepoRootPath ))
256256
257257 assert .NoError (t , util .CopyDir (path .Join (filepath .Dir (setting .AppPath ), "integrations/gitea-repositories-meta" ), setting .RepoRootPath ))
258+ ownerDirs , err := os .ReadDir (setting .RepoRootPath )
259+ if err != nil {
260+ assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
261+ }
262+ for _ , ownerDir := range ownerDirs {
263+ if ! ownerDir .Type ().IsDir () {
264+ continue
265+ }
266+ repoDirs , err := os .ReadDir (filepath .Join (setting .RepoRootPath , ownerDir .Name ()))
267+ if err != nil {
268+ assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
269+ }
270+ for _ , repoDir := range repoDirs {
271+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "pack" ), 0755 )
272+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "info" ), 0755 )
273+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "heads" ), 0755 )
274+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "tag" ), 0755 )
275+ }
276+ }
258277
259278 return deferFn
260279}
@@ -532,4 +551,23 @@ func resetFixtures(t *testing.T) {
532551 assert .NoError (t , unittest .LoadFixtures ())
533552 assert .NoError (t , util .RemoveAll (setting .RepoRootPath ))
534553 assert .NoError (t , util .CopyDir (path .Join (filepath .Dir (setting .AppPath ), "integrations/gitea-repositories-meta" ), setting .RepoRootPath ))
554+ ownerDirs , err := os .ReadDir (setting .RepoRootPath )
555+ if err != nil {
556+ assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
557+ }
558+ for _ , ownerDir := range ownerDirs {
559+ if ! ownerDir .Type ().IsDir () {
560+ continue
561+ }
562+ repoDirs , err := os .ReadDir (filepath .Join (setting .RepoRootPath , ownerDir .Name ()))
563+ if err != nil {
564+ assert .NoError (t , err , "unable to read the new repo root: %v\n " , err )
565+ }
566+ for _ , repoDir := range repoDirs {
567+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "pack" ), 0755 )
568+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "objects" , "info" ), 0755 )
569+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "heads" ), 0755 )
570+ _ = os .MkdirAll (filepath .Join (setting .RepoRootPath , ownerDir .Name (), repoDir .Name (), "refs" , "tag" ), 0755 )
571+ }
572+ }
535573}
0 commit comments