Fix recycle dependency

This commit is contained in:
Lunny Xiao 2024-10-27 17:15:03 -07:00
parent b362ffaa0c
commit fafd7b73ba
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
2 changed files with 4 additions and 4 deletions

View File

@ -284,7 +284,9 @@ func (repo *Repository) CreateBundle(ctx context.Context, commit string, out io.
if err != nil { if err != nil {
return err return err
} }
defer util.RemoveAll(tmp) defer func() {
_ = util.RemoveAll(tmp)
}()
env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects")) env := append(os.Environ(), "GIT_OBJECT_DIRECTORY="+filepath.Join(repo.Path, "objects"))
_, _, err = NewCommand(ctx, "init", "--bare").RunStdString(&RunOpts{Dir: tmp, Env: env}) _, _, err = NewCommand(ctx, "init", "--bare").RunStdString(&RunOpts{Dir: tmp, Env: env})

View File

@ -11,15 +11,13 @@ import (
"testing" "testing"
"time" "time"
"code.gitea.io/gitea/modules/setting"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
) )
func TestCopyFile(t *testing.T) { func TestCopyFile(t *testing.T) {
testContent := []byte("hello") testContent := []byte("hello")
tmpDir := setting.TempDir() tmpDir := os.TempDir()
now := time.Now() now := time.Now()
srcFile := fmt.Sprintf("%s/copy-test-%d-src.txt", tmpDir, now.UnixMicro()) srcFile := fmt.Sprintf("%s/copy-test-%d-src.txt", tmpDir, now.UnixMicro())
dstFile := fmt.Sprintf("%s/copy-test-%d-dst.txt", tmpDir, now.UnixMicro()) dstFile := fmt.Sprintf("%s/copy-test-%d-dst.txt", tmpDir, now.UnixMicro())