feat(internal/carver): add tooling to help carve out sub-modules#4417
feat(internal/carver): add tooling to help carve out sub-modules#4417gcf-merge-on-green[bot] merged 9 commits intogoogleapis:masterfrom codyoss:carver
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.
Should dry run print the things it would do if it weren't a dry run?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I was unaware of this package, thanks I will try this out!
There was a problem hiding this comment.
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.
| }) | ||
| } | ||
|
|
||
| func parsePkgName(importPath string) (string, error) { |
There was a problem hiding this comment.
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.
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.
Give path to metadata file? And the import path that was being looked for?
There was a problem hiding this comment.
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.