-
Notifications
You must be signed in to change notification settings - Fork 44
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
[PRETEST]: Added support for bare repo in clone function of git module #419
Conversation
Signed-off-by: Manoramsharma <[email protected]>
Signed-off-by: Manoramsharma <[email protected]>
PR conflicted |
Resolved the conflicts @Peefy. |
@@ -110,14 +110,46 @@ func (cloneOpts *CloneOptions) Validate() error { | |||
return nil | |||
} | |||
|
|||
// CheckoutFromBare checks out the specified reference from a bare repository |
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.
Why comment here?
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 have left this function commented because I need review from @zong-zhe over the checkout implementation from bare, which I don't feel would be achieved something like that I did.
CI failed. |
Signed-off-by: Manoramsharma <[email protected]>
Pull Request Test Coverage Report for Build 10317935447Details
💛 - Coveralls |
Hi @Peefy I have fixed the issues but I don't know why I am facing this license issue. I have modified the clone() function itself to handle the cloning of bare repository rather introducing the new function as you told @zong-zhe . The user can handle the bare clone from the cli itself using clone with options. |
Hi @Manoramsharma 😃 Is this PR ready for review ? |
Hi @zong-zhe I am about to finish the changes , but before that I want to ask about some doubts I am facing in the current implementation of the git module:
|
Hi @Manoramsharma 😃
Yes, the API provided by
Personally, I don't think it's necessary to separate the two public methods, users just need to call one
There is no need to distinguish the bare/normal repository before downloading; failure to download will return an error. The PR's job is to extend the functionality of the git so that kpm can download the bare repo. |
Signed-off-by: Manoramsharma <[email protected]>
Hi @zong-zhe I have updated the But here I am stuck with a test case when handling The test suit is failing with the error below because I think I am not able to handle the local bare repositories path for the non bare cloning in the clone() function in --- FAIL: TestCloneWithOptions (14.40s)
--- FAIL: TestCloneWithOptions/LocalBareCloneAsNonBareWithCommit (3.26s)
/Users/manoramsharma/Desktop/kpm/pkg/git/git_test.go:178: assertion failed: invalid source string: git::/var/folders/4z/k675yy811dv47rnw3tqsmd7w0000gn/T/local_bare_repo972358456?ref=4e59d5852cd76542f9f0ec65e5773ca9f4e02462 (err *errors.errorString) != <nil> (nil <nil>)
FAIL
FAIL kcl-lang.io/kpm/pkg/git 15.344s
FAIL
I am thinking to add a logic to clone() to check the whether the repoURL to be fetched is a localPath to handle the non-bare clone for the bare repository, something like this: // Handle local bare repositories differently for non-bare cloning
if cloneOpts.isLocalPath(cloneOpts.RepoURL) {
cmdArgs := []string{"clone", cloneOpts.RepoURL, cloneOpts.LocalPath}
cmd := exec.Command("git", cmdArgs...)
output, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("failed to clone repository: %s, error: %w", string(output), err)
}
repo, err := git.PlainOpen(cloneOpts.LocalPath)
if err != nil {
return nil, err
}
if cloneOpts.Commit != "" {
w, err := repo.Worktree()
if err != nil {
return nil, err
}
err = w.Checkout(&git.CheckoutOptions{
Hash: plumbing.NewHash(cloneOpts.Commit),
})
if err != nil {
return nil, err
}
}
return repo, nil
} |
Hi @Manoramsharma 😃 I tried the problem you mentioned, and your test case could be written like this: repo, err := CloneWithOpts(
WithRepoURL("file:///Users/xxx/xxx/xxx.git"),
WithCommit("54c083093d"),
WithWriter(&buf),
WithLocalPath("/Users/xxx/"),
) How to add prefilx |
Signed-off-by: Manoramsharma <[email protected]>
Hi @zong-zhe Thanks for the support. I have got all the checks passed 🎉 |
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.
LGTM
Hi @Manoramsharma 😄 Congratulations! you have done this part of the work, next, you can try to complete the content of the second phase, in
Downloader is here: https://github.com/kcl-lang/kpm/blob/main/pkg/downloader/downloader.go |
Hi @zong-zhe This was made possible because of your support. Thanks for all those reviews upon my changes. Actually I was busy in designing the cover letter for submitting as a part LFX mentee application for KCL. I already have an approach in my mind for refactoring of downloader module to support the file path as designed to achieve the local full storage path for a third-party dependencies. Will soon come up with a PR !! 🚀 |
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
Fix #384
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
I have tried to add the support to download a bare repository without introducing a new function but modifying the current clone function making user to access the bare flag based on the cloneOptions.
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: