Skip to content

Commit 4bdcc04

Browse files
committed
Make dedicated package for release archive handling
This is the initial minimal refactoring for what will eventually be a more significant package.
1 parent 8473338 commit 4bdcc04

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

internal/command/sync/sync.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/arduino/libraries-repository-engine/internal/configuration"
3838
"github.com/arduino/libraries-repository-engine/internal/feedback"
3939
"github.com/arduino/libraries-repository-engine/internal/libraries"
40+
"github.com/arduino/libraries-repository-engine/internal/libraries/archive"
4041
"github.com/arduino/libraries-repository-engine/internal/libraries/db"
4142
"github.com/arduino/libraries-repository-engine/internal/libraries/gitutils"
4243
"github.com/arduino/libraries-repository-engine/internal/libraries/hash"
@@ -268,10 +269,10 @@ func syncLibraryTaggedRelease(logger *log.Logger, repo *libraries.Repository, ta
268269
releaseLog += formattedReport
269270
}
270271

271-
zipName := libraries.ZipFolderName(library)
272+
zipName := archive.ZipFolderName(library)
272273
lib := filepath.Base(filepath.Clean(filepath.Join(repo.FolderPath, "..")))
273274
host := filepath.Base(filepath.Clean(filepath.Join(repo.FolderPath, "..", "..")))
274-
zipFilePath, err := libraries.ZipRepo(repo.FolderPath, filepath.Join(config.LibrariesFolder, host, lib), zipName)
275+
zipFilePath, err := archive.ZipRepo(repo.FolderPath, filepath.Join(config.LibrariesFolder, host, lib), zipName)
275276
if err != nil {
276277
return fmt.Errorf("Error while zipping library: %s", err)
277278
}

internal/libraries/repoarchive.go renamed to internal/libraries/archive/archive.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
// Arduino software without disclosing the source code of your own applications.
2222
// To purchase a commercial license, send an email to license@arduino.cc.
2323

24-
package libraries
24+
// Package archive handles the library release archive.
25+
package archive
2526

2627
import (
2728
"os"

internal/libraries/git_integration_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"path/filepath"
3030
"testing"
3131

32+
"github.com/arduino/libraries-repository-engine/internal/libraries/archive"
3233
"github.com/arduino/libraries-repository-engine/internal/libraries/db"
3334
"github.com/arduino/libraries-repository-engine/internal/libraries/gitutils"
3435
"github.com/stretchr/testify/require"
@@ -68,11 +69,11 @@ func TestUpdateLibraryJson(t *testing.T) {
6869
require.NoError(t, err)
6970
require.NotNil(t, library)
7071

71-
zipFolderName := ZipFolderName(library)
72+
zipFolderName := archive.ZipFolderName(library)
7273

7374
release := db.FromLibraryToRelease(library)
7475

75-
zipFilePath, err := ZipRepo(r.FolderPath, librariesRepo, zipFolderName)
76+
zipFilePath, err := archive.ZipRepo(r.FolderPath, librariesRepo, zipFolderName)
7677
require.NoError(t, err)
7778
require.NotEmpty(t, zipFilePath)
7879

0 commit comments

Comments
 (0)