feat(*): support repositories

Signed-off-by: storyicon <yuanchao@bilibili.com>
This commit is contained in:
storyicon 2021-07-23 14:56:00 +08:00
parent 1c73b92f0f
commit 9a99c53c5b
No known key found for this signature in database
GPG key ID: 245915D985F966CF
18 changed files with 542 additions and 255 deletions

View file

@ -15,6 +15,7 @@
package pluginmanager
import (
"net/url"
"path"
"path/filepath"
@ -46,9 +47,19 @@ func GetPluginPath(path string, version string) (string, error) {
return filepath.Join(enc + "@" + encVer), nil
}
// PathForGoogleAPIs is used to get the google apis path
func PathForGoogleAPIs(storageDir string, commitId string) string {
return filepath.Join(storageDir, "googleapis", commitId)
// PathForGitReposCode returns the code path for git repos
func PathForGitReposCode(storageDir string, uri string, commitId string) (string, error) {
parsed, err := url.Parse(uri)
if err != nil {
return "", err
}
dir := parsed.Host + parsed.Path
return filepath.Join(PathForGitRepos(storageDir, commitId), dir), nil
}
// PathForGitRepos is used to get the git repo local path
func PathForGitRepos(storageDir string, commitId string) string {
return filepath.Join(storageDir, "gits", commitId)
}
// PathForPluginDir is used to get the local directory where the specified version plug-in should be stored