Skip to content

Commit 5cbc41f

Browse files
refactor
1 parent c1c0406 commit 5cbc41f

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

pkg/package_manager.go

+16-16
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,22 @@ func (pm *PackageManager) Create(opts PackageCreateOpts) (string, error) {
230230
return status.Path, nil
231231
}
232232

233+
func DetermineFilterRoot(contentPath string) string {
234+
_, filterRoot, _ := strings.Cut(contentPath, content.JCRRoot)
235+
filterRoot = strings.ReplaceAll(filterRoot, "\\", "/")
236+
if strings.HasSuffix(filterRoot, content.JCRContentFile) && content.IsContentFile(contentPath) {
237+
filterRoot = strings.ReplaceAll(filterRoot, content.JCRContentFile, content.JCRContentNode)
238+
} else if strings.HasSuffix(filterRoot, content.JCRContentFile) {
239+
filterRoot = filepath.Dir(filterRoot)
240+
} else if strings.HasSuffix(filterRoot, content.XmlFileSuffix) {
241+
filterRoot = strings.ReplaceAll(filterRoot, content.XmlFileSuffix, "")
242+
}
243+
filterRoot = namespacePatternRegex.ReplaceAllString(filterRoot, "/$2:")
244+
filterRoot = strings.ReplaceAll(filterRoot, "/__", "/_")
245+
filterRoot = strings.ReplaceAll(filterRoot, "%3a", ":")
246+
return filterRoot
247+
}
248+
233249
func copyContentFiles(contentPath string, tmpDir string) error {
234250
_, jcrPath, _ := strings.Cut(contentPath, content.JCRRoot)
235251
if pathx.IsDir(contentPath) {
@@ -253,22 +269,6 @@ func copyContentFiles(contentPath string, tmpDir string) error {
253269
return nil
254270
}
255271

256-
func DetermineFilterRoot(contentPath string) string {
257-
_, filterRoot, _ := strings.Cut(contentPath, content.JCRRoot)
258-
filterRoot = strings.ReplaceAll(filterRoot, "\\", "/")
259-
if strings.HasSuffix(filterRoot, content.JCRContentFile) && content.IsContentFile(contentPath) {
260-
filterRoot = strings.ReplaceAll(filterRoot, content.JCRContentFile, content.JCRContentNode)
261-
} else if strings.HasSuffix(filterRoot, content.JCRContentFile) {
262-
filterRoot = filepath.Dir(filterRoot)
263-
} else if strings.HasSuffix(filterRoot, content.XmlFileSuffix) {
264-
filterRoot = strings.ReplaceAll(filterRoot, content.XmlFileSuffix, "")
265-
}
266-
filterRoot = namespacePatternRegex.ReplaceAllString(filterRoot, "/$2:")
267-
filterRoot = strings.ReplaceAll(filterRoot, "/__", "/_")
268-
filterRoot = strings.ReplaceAll(filterRoot, "%3a", ":")
269-
return filterRoot
270-
}
271-
272272
func (pm *PackageManager) Copy(remotePath string, destInstance *Instance) error {
273273
var localPath = pathx.RandomFileName(pm.tmpDir(), "pkg_copy", ".zip")
274274
defer func() {
+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<workspaceFilter version="1.0">[[ if .ExcludePatterns ]]
3-
<filter root="[[ index .FilterRoots 0 ]]">[[ range .ExcludePatterns ]]
4-
<exclude pattern="[[ . ]]"/>[[ end ]]
5-
</filter>[[ else ]][[ range .FilterRoots ]]
6-
<filter root="[[ . ]]"/>[[ end ]][[ end ]]
2+
<workspaceFilter version="1.0">[[if .ExcludePatterns]]
3+
<filter root="[[index .FilterRoots 0]]">[[range .ExcludePatterns]]
4+
<exclude pattern="[[.]]"/>[[end]]
5+
</filter>[[else]][[range .FilterRoots]]
6+
<filter root="[[.]]"/>[[end]][[end]]
77
</workspaceFilter>

0 commit comments

Comments
 (0)