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

fix: overwrite attribute values when not mergeable #1952

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jbedard
Copy link
Contributor

@jbedard jbedard commented Oct 9, 2024

Fix #1962

What type of PR is this?

Bug fix

What package or component does this PR mostly affect?

all

What does this PR do? Why is it needed?

Allow updating non-mergeable/resolveable attributes.

Which issues(s) does this PR fix?

Fixes #1962

Other notes for review

@jbedard jbedard force-pushed the set-unknown-attributes branch 8 times, most recently from 1a675a4 to 06fe94e Compare October 21, 2024 07:47
merger/merger.go Outdated
}
}

isManaged := func(r *rule.Rule, attr string) bool {
// Name and visibility are uniquely managed by gazelle.
if attr == "name" || attr == "visibility" {
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 actually don't think visibility should be here but it causes too many changes in this repo atm. I think those changes are actually correct but they could be breaking such as reducing the visibility of //internal/....

@jbedard jbedard force-pushed the set-unknown-attributes branch from 06fe94e to 5a35779 Compare October 21, 2024 08:08
@jbedard jbedard marked this pull request as ready for review October 21, 2024 08:08
@fmeum fmeum force-pushed the set-unknown-attributes branch from 5a35779 to 697c5bf Compare October 23, 2024 09:37
rule/merge.go Outdated Show resolved Hide resolved
@jbedard jbedard force-pushed the set-unknown-attributes branch 6 times, most recently from 23e8768 to 40bd8f4 Compare October 23, 2024 21:04
@jbedard jbedard requested a review from fmeum October 23, 2024 21:14
Copy link
Member

@fmeum fmeum left a comment

Choose a reason for hiding this comment

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

@tyler-french Could you test this at Uber?

rule/merge.go Outdated Show resolved Hide resolved
rule/merge.go Outdated
@@ -41,6 +41,9 @@ import (
// marked with a "# keep" comment, values in the attribute not marked with
// a "# keep" comment will be dropped. If the attribute is empty afterward,
// it will be deleted.
//
// If src has an attribute not present in 'mergeable' and not marked with a
Copy link
Member

Choose a reason for hiding this comment

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

Should this be

Suggested change
// If src has an attribute not present in 'mergeable' and not marked with a
// If dst has an attribute not present in 'mergeable' and not marked with a

Copy link
Contributor Author

@jbedard jbedard Oct 25, 2024

Choose a reason for hiding this comment

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

I think this comment is correct as-is, although maybe confusing.

This is pointing out that attributes in src will overwrite those in dst if they are unknown and the value in dst is not marked as # keep.

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've updated the comment a bit. See the fixup commits.

@jbedard jbedard force-pushed the set-unknown-attributes branch from 40bd8f4 to e710945 Compare October 25, 2024 22:48
@jbedard jbedard requested a review from fmeum October 25, 2024 23:31
@fmeum fmeum force-pushed the set-unknown-attributes branch from 08ca365 to 02d0808 Compare October 30, 2024 09:55
@tyler-french
Copy link
Contributor

@tyler-french Could you test this at Uber?

I'm seeing 1000s of build files behaving differently, need to dig a bit deeper. Please hold off on merging for now

@jbedard
Copy link
Contributor Author

jbedard commented Oct 30, 2024

@tyler-french what types of changes are you seeing? Are effected attributes in the KindInfo anywhere?

@jbedard
Copy link
Contributor Author

jbedard commented Dec 2, 2024

@tyler-french have you had a chance to look at this? I don't understand why you'd ever want SetAttr to not update the attribute?

@stoiky
Copy link

stoiky commented Dec 4, 2024

@tyler-french any news on this? We've been waiting for this fix at Adobe.

Thank you @jbedard and @fmeum!

@tyler-french
Copy link
Contributor

The main issues we are seeing are:

  • Things being removed from data attributes of go_test rules (specifically targets added are removed) and replaced with whatever gazelle applies.
  • Non-deterministic changes to the ordering of fields, (specifically for ordered, non-sorted string_list attributes
  • Changes to the behavior of the self_import attribute in the gomock rule (paths changing)
  • Random new additions to certain fields

I will try to make reproductions with public code sometime soon

@jbedard
Copy link
Contributor Author

jbedard commented Dec 4, 2024

Are those changes all in rules_go targets or in custom languages you have?

@jbedard jbedard force-pushed the set-unknown-attributes branch from 02d0808 to 87ba5e7 Compare December 17, 2024 00:42
@jbedard
Copy link
Contributor Author

jbedard commented Dec 17, 2024

@tyler-french any updates here? Even just ideas for tests I could write to reproduce the issues you're finding...

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.

unknown attributes only set on initial generated
4 participants