-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sparse checkout feature - Download subdirectory #387
Changes from 1 commit
7b5b05e
b9b5671
6c017d3
62717e0
db7b6ef
5244d67
f69e9c2
d5d6a41
d138f96
ff66f85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,22 +20,27 @@ func ForceProtocol(url, protocol string) string { | |
return protocol + url | ||
} | ||
|
||
// ForceGitUrl will add the branch, tag or commit to the git URL and force it to the git protocol | ||
// `<URL>` will return `Git::<URL>?ref=<branch|tag|commit>` | ||
// ForceGitUrl will add the subpackage and branch, tag or commit to the git URL and force it to the git protocol | ||
// `<URL>` will return `Git::<URL>//<SubPackage>?ref=<branch|tag|commit>` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might need to make sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
func (cloneOpts *CloneOptions) ForceGitUrl() (string, error) { | ||
if err := cloneOpts.Validate(); err != nil { | ||
return "", nil | ||
} | ||
|
||
newRepoUrl := "" | ||
if cloneOpts.SubPackage != "" { | ||
newRepoUrl = cloneOpts.RepoURL + "//" + cloneOpts.SubPackage | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation idea here is still wrong, the idea we mentioned before is clone the entire repo. Recursively finds the dependency with the specified package name and loads it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay will open a PR with that changes. I am still not sure why we are discarding downloading a subdirectory (this method )? In case of large repo (let's say 100 MB +) with only one directory of kcl dependecies, it will defeat the purpose of sparse checkout since it will download the entire repo when the user only needs that particular subdirectory any day in the future. |
||
|
||
var attributes = []string{cloneOpts.Branch, cloneOpts.Commit, cloneOpts.Tag} | ||
for _, attr := range attributes { | ||
if attr != "" { | ||
return ForceProtocol( | ||
cloneOpts.RepoURL+fmt.Sprintf(constants.GIT_PROTOCOL_URL_PATTERN, attr), | ||
newRepoUrl+fmt.Sprintf(constants.GIT_PROTOCOL_URL_PATTERN, attr), | ||
GIT_PROTOCOL, | ||
), nil | ||
} | ||
} | ||
|
||
return ForceProtocol(cloneOpts.RepoURL, GIT_PROTOCOL), nil | ||
return ForceProtocol(newRepoUrl, GIT_PROTOCOL), nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ import ( | |
"path/filepath" | ||
"strings" | ||
|
||
orderedmap "github.com/elliotchance/orderedmap/v2" | ||
"github.com/BurntSushi/toml" | ||
orderedmap "github.com/elliotchance/orderedmap/v2" | ||
|
||
"kcl-lang.io/kcl-go/pkg/kcl" | ||
|
||
|
@@ -459,10 +459,11 @@ func (deps *Dependencies) loadLockFile(filepath string) error { | |
func ParseOpt(opt *opt.RegistryOptions) (*Dependency, error) { | ||
if opt.Git != nil { | ||
gitSource := downloader.Git{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add more test cases for |
||
Url: opt.Git.Url, | ||
Branch: opt.Git.Branch, | ||
Commit: opt.Git.Commit, | ||
Tag: opt.Git.Tag, | ||
Url: opt.Git.Url, | ||
Branch: opt.Git.Branch, | ||
Commit: opt.Git.Commit, | ||
Tag: opt.Git.Tag, | ||
SubPackage: opt.Git.SubPackage, | ||
} | ||
|
||
gitRef, err := gitSource.GetValidGitReference() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think use
package
is better.