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: fix-visibility #34

Merged
merged 1 commit into from
Sep 29, 2021
Merged

feat: fix-visibility #34

merged 1 commit into from
Sep 29, 2021

Conversation

f0rmiga
Copy link
Contributor

@f0rmiga f0rmiga commented Sep 25, 2021

No description provided.

@f0rmiga f0rmiga added the WIP label Sep 25, 2021
@f0rmiga f0rmiga force-pushed the fix-visibility branch 2 times, most recently from 908dc2e to 3667c5b Compare September 27, 2021 23:55
@f0rmiga f0rmiga removed the WIP label Sep 28, 2021
Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
}
matches := visibilityIssueRegex.FindSubmatch(bazelEvent.Value)
if len(matches) != 3 {
return nil
Copy link
Member

Choose a reason for hiding this comment

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

should it have some error handling here? or maybe this is a good case for a logger that writes some log file for us to diagnose surprising issues

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I'm doing regex group matching here. Since I have 2 groups, I expect 3 matches (the first being the full string). If there were no matches, we only return nil for the build event message, no errors were involved here.

ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()

// TODO(f0rmiga): check if buildozer is installed, otherwise return an error.
Copy link
Member

Choose a reason for hiding this comment

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

why wouldn't we just link buildozer into our binary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, reading again https://github.com/bazelbuild/buildtools/blob/master/buildozer/main.go, we can probably use it directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do this in a follow-up PR.

return nil
}

func (plugin *FixVisibilityPlugin) hasPrivateVisibility(ctx context.Context, toFix string) (bool, error) {
Copy link
Member

Choose a reason for hiding this comment

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

it might also not be visible because it has some non-private visibility that doesn't include the referrer, do you handle that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is only a check for when it does have the private visibility, in which case, we need to remove it.

type buildozer struct{}

func (b *buildozer) Run(ctx context.Context, args ...string) ([]byte, error) {
cmd := exec.CommandContext(ctx, "buildozer", args...)
Copy link
Member

Choose a reason for hiding this comment

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

yeah I'd love to just link buildozer in :)

@f0rmiga f0rmiga merged commit d0b1ece into main Sep 29, 2021
@f0rmiga f0rmiga deleted the fix-visibility branch September 29, 2021 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants