-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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(internal/carver): add tooling to help carve out sub-modules #4417
Conversation
Here is an example PR that was raised the code: #4419 Steps:
go run cmd/main.go \
-parent=/path/to/google-cloud-go \
-child=asset \
-repo-metadata=/path/to/google-cloud-go/internal/.repo-metadata-full.json
|
} | ||
childPrefix := strings.TrimPrefix(strings.TrimPrefix(c.childModPath, rootMod.filePath), "/") | ||
log.Println("Commiting changes") | ||
if !c.dryRun { |
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.
Should dry run print the things it would do if it weren't a dry run?
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 am not sure I understand. Are you suggestioning to print more or less when it is a dry run? Right now it does some light printing. I had added this originally to test to see what tags were chosen which I thought was useful.
// sortTags does a best effort sort based on semver. It was made a function for | ||
// testing. Only the top result will ever be used. | ||
func sortTags(tags []string) { | ||
sort.Slice(tags, func(i, j int) bool { |
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.
I was unaware of this package, thanks I will try this out!
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.
After trying this out it does sort by semver but not in the way I needed. The main difference between the two results is that I derank pre-releases a whole major version as we don't want to find those tags when picking a base tag to work off of.
internal/carver/cmd/main.go
Outdated
}) | ||
} | ||
|
||
func parsePkgName(importPath string) (string, error) { |
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.
This is more like guessPkgName
since the name may not always be the final element of the import path. Is there a better way?
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 renamed the variable. This is actually the child modules filepath. Which I believe the last element will always be the name of the package found at that level. Can you think of a case where this is not true?
if name == "" { | ||
name = meta[importPath] | ||
if name == "" { | ||
return fmt.Errorf("unable to determine a name from API metadata, please set -name flag") |
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.
Give path to metadata file? And the import path that was being looked for?
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.
In this case metadata file exists but does not contain the right info to split out the module. I think there are some cases where we might have a structure of:
/
/baz
/foo
/apiv1
/bar
/apiv2
If we specified baz as the level to split the module out the metadata lookup fails.
Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com>
Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com>
Co-authored-by: Tyler Bui-Palsulich <26876514+tbpg@users.noreply.github.com>
No description provided.