-
Notifications
You must be signed in to change notification settings - Fork 48
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
[WIP] kpm fixes the order of dependencies and format in kcl.mod and kcl.mod.lock #336
Conversation
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
Pull Request Test Coverage Report for Build 9228658894Details
💛 - Coveralls |
pkg/package/modfile.go
Outdated
@@ -146,6 +147,21 @@ type Dependencies struct { | |||
Deps map[string]Dependency `json:"packages" toml:"dependencies,omitempty"` | |||
} | |||
|
|||
// SortMapByKey will sort the dependencies by key. | |||
func (deps *Dependencies) SortMapByKey() { |
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 we should use an ordered dictionary for serialization/deserialization instead of simply sorting, as KCL users often do not want unexpected changes to occur.
Besides, [dependencies]
section and [profile]
section lost the expect newline.
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.
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.
Add some comments. cc @zong-zhe Could you help review it? |
I will do the required changes. |
pkg/package/package.go
Outdated
@@ -175,6 +175,7 @@ func (kclPkg *KclPkg) LocalVendorPath() string { | |||
// updateModAndLockFile will update kcl.mod and kcl.mod.lock | |||
func (kclPkg *KclPkg) UpdateModAndLockFile() error { | |||
// Generate file kcl.mod. | |||
kclPkg.ModFile.Dependencies.SortMapByKey() |
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.
Hi @officialasishkumar 😃
Good job ! But I have a few different ideas about this feature.
The go community maybe have libraries to help us solve this problem. Try to research some of the libraries and see the possible problems with using them. You can update the results of the research in the issue.
I found a third-party library, https://github.com/elliotchance/orderedmap, but when the library is serialized into a kcl.mod
file, there may be some problems, this need you to continue to research.
It's not that your method is wrong, it's just that we need some evidence to show that this method is more appropriate than other methods.
PR conflict cc @officialasishkumar |
I noticed the function still use the unordered map.
|
@Peefy The migration is not yet completed. |
Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
2042c28
to
cc6485f
Compare
Hi @officialasishkumar 😄 This PR conflicts with the main branch, you may need to squash some commits and rebase the main branch. |
Hi @officialasishkumar 😄 This PR conflicts with the main branch. Are you still working on it? |
Yeah, I will complete it. Sorry my exams were running for a few weeks. Now it's over. |
Hi @officialasishkumar 😄 I finished this issue for the 0.9.0 release, #373 |
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
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):
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: