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

Ensure that imports are not removed in generated code #406

Merged
merged 4 commits into from
Jan 27, 2023

Conversation

nmiyake
Copy link
Contributor

@nmiyake nmiyake commented Jan 23, 2023

Makes it such that the "ptimports.Process" call that is called for individual generated code files does not add or remove imports and then adds a step where "ptimports.Process" is called on all generated code files after they are written. Fixes an issue where generated code would not include imports that referenced packages where the last component of the package path was of the form "v[0-9]+".

Fixes #405

Before this PR

See #405 for details, but before this PR, generating code for Conjure definitions that have packages where the last component is of the form v[0-9]+ (for example, "com.palantir.foo.v2") would not generate the import statement needed to compile (so the first run of the generator would produce code that didn't compile). Running the generator a second time would add the expected imports.

After this PR

==COMMIT_MSG==
Fixes an issue where generated code would not include imports that referenced packages where the last component of the package path was of the form "v[0-9]+".
==COMMIT_MSG==

Possible downsides?

This fix adds a step where, after all the generated files are written, they are all formatted and written again. This process adds computational overhead on the order of the number of files written, but I don't think it should be a major concern as the operation is not too expensive and generating the files is not a hot path (it's an operation that is expected to take a decent amount of time and is run in a one-off manner in workflows).


This change is Reviewable

Makes it such that the "ptimports.Process" call on generated code
does not add or remove imports. Fixes an issue where generated code
would not include imports that referenced packages where the last
component of the package path was of the form "v[0-9]+".

Fixes #405
@changelog-app
Copy link

changelog-app bot commented Jan 23, 2023

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Fixes an issue where generated code would not include imports that referenced packages where the last component of the package path was of the form "v[0-9]+".

Check the box to generate changelog(s)

  • Generate changelog entry

Copy link
Contributor

@bmoylan bmoylan left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r1, 6 of 6 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @tabboud)

@bulldozer-bot bulldozer-bot bot merged commit ffd6daa into develop Jan 27, 2023
@bulldozer-bot bulldozer-bot bot deleted the fixPtImportsFormatOnly branch January 27, 2023 16:59
nmiyake added a commit that referenced this pull request Jan 30, 2023
bulldozer-bot bot pushed a commit that referenced this pull request Feb 1, 2023
…#408)

Reverts the conjure-go behavior change introduced in v6.36.0 to match previous versions: certain named imports generated by Conjure code will only be generated if the Conjure generator is run twice, but once this is done, the output of `conjure.Generate` and `conjure.GenerateOutputFiles` will match, which prevents verification issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants