Skip to content
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

feat: support adding third-party dependencies from git repo with the version field #405

Closed
wants to merge 3 commits into from

Conversation

Gmin2
Copy link
Contributor

@Gmin2 Gmin2 commented Jul 27, 2024

1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

  • N
  • Y

Fixes #266

2. What is the scope of this PR (e.g. component or file name):

pkg/client/client.go
pkg/package/modfile.go
pkg/package/toml.go

3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

TODO:
image

4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

  • N
  • Y

5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

TODO

  • Unit test
  • Integration test
  • Benchmark (add benchmark stats below)
  • Manual test (add detailed scripts or steps below)
  • Other

Screenshot from 2024-07-28 00-17-18

@Gmin2
Copy link
Contributor Author

Gmin2 commented Jul 27, 2024

Do i need to modify all e2e test cases, in this PR or can be done in another one ?

cc @Peefy @zong-zhe

Sum string `json:"-" toml:"sum,omitempty"`
// The actual local path of the package.
// In vendor mode is "current_kcl_package/vendor"
// In non-vendor mode is "$KCL_PKG_PATH"
LocalFullPath string `json:"manifest_path" toml:"-"`
downloader.Source `json:"-"`
Version string `json:"version,omitempty" toml:"version,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change here ?

@@ -85,7 +85,17 @@ func (dep *Dependency) MarshalTOML() string {
source := dep.Source.MarshalTOML()
var sb strings.Builder
if len(source) != 0 {
sb.WriteString(fmt.Sprintf(DEP_PATTERN, dep.Name, source))
sourceWithoutBrace := strings.TrimSuffix(source, "}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the logic of serializing kcl.mod to toml is incorrect, maybe you should add some test cases to make sure this is correct. Because from a functional point of view, you are only adding a field, why are you adding "{}" again here ?

Copy link
Contributor Author

@Gmin2 Gmin2 Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we directly pass it as a field it the kpm.mod will look like,

[dependencies]
catalog = { git = "https://github.com/KusionStack/catalog.git", tag=“0.0.3”}, version = “0.1.1” 

as the other fields are comin in from git source and if we try to append the version in the git source then the kpm.mod.lock will have two version field, as done in this PR(#406 )

cc @zong-zhe

Copy link
Contributor

@zong-zhe zong-zhe Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Gmin2 😃

I see what you mean; what I mean is that if you want to change the process of generating "{}" to the upper level, you should remove the original code for generating "{}" instead of just trimming the string.

I suggest that you write some unit tests for your functional changes first so that I can intuitively judge whether your changes meet the expectations based on the unit tests and then review your specific implementation.

@zong-zhe
Copy link
Contributor

And, add more test cases.

@zong-zhe zong-zhe closed this Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants