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: mockgen flag --build_constraint to add //go:build directives #191

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

ARR4N
Copy link
Contributor

@ARR4N ARR4N commented Jul 5, 2024

Resolves #190

Note that //go:generate has unusual handling of flags with spaces so the quotes have to include the flag name (example) for complex constraints. This revealed a bug in --write_generate_directive, which just prints space-delimited os.Args.

The workaround of using --copyright_file is neither viable (it adds a space between // and go:build) nor good practice as overloading functionality can result in bugs due to unanticipated usage (e.g. the aforementioned space).

@ARR4N ARR4N marked this pull request as ready for review July 5, 2024 09:47
@CLAassistant
Copy link

CLAassistant commented Jul 5, 2024

CLA assistant check
All committers have signed the CLA.

@jaceee
Copy link

jaceee commented Sep 9, 2024

is this getting reviewed/merged any time soon?

@Gris87
Copy link

Gris87 commented Sep 18, 2024

Hi, we need this functionality too. When we can get it?

Copy link
Contributor

@JacobOaks JacobOaks left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@JacobOaks JacobOaks merged commit 8adc9de into uber-go:main Sep 25, 2024
1 check passed
JacobOaks added a commit to JacobOaks/mock that referenced this pull request Sep 25, 2024
Regenerates generated mocks after uber-go#191, which will fix
failing tests.
JacobOaks added a commit that referenced this pull request Sep 25, 2024
Regenerates generated mocks after #191, which will fix failing tests.
apricote pushed a commit to hetznercloud/fleeting-plugin-hetzner that referenced this pull request Oct 18, 2024
…eting-plugin-hetzner!135)

This MR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [go.uber.org/mock](https://github.com/uber/mock) | require | minor | `v0.4.0` -> `v0.5.0` |

---

### Release Notes

<details>
<summary>uber/mock (go.uber.org/mock)</summary>

### [`v0.5.0`](https://github.com/uber-go/mock/releases/tag/v0.5.0)

[Compare Source](uber-go/mock@v0.4.0...v0.5.0)

#### 0.5.0 (15 Oct 2024)

##### Added

-   [#&#8203;153][]: Add `--write_command_comment` flag to specify whether to include
    `Generated by this command` comment.
-   [#&#8203;191][]: Add `--build_constraint` flag to add `//go:build` directives
    to generated mocks
-   [#&#8203;214][]: Add gob mode to support custom package loading techniques in place
    of --exec_only

##### Changed

-   [#&#8203;181][]: Made mockgen faster by changing flags passed to `go list`.
-   [#&#8203;183][]: Made `Cond` matcher generic.
-   [#&#8203;204][]: Removed `ISGOMOCK()` from generated mocks.
-   [#&#8203;207][]: Deprecated reflect mode and replaced it with the new package mode.

##### Fixed

-   [#&#8203;144][]: Fix a deadlock that can happen when mocking an interface that
    matches `fmt.Stringer`.
-   [#&#8203;168][]: Fix an issue where the "generated by" comment was being included
    in the package comment of generated mocks.

[#&#8203;144]: uber-go/mock#144

[#&#8203;153]: uber-go/mock#153

[#&#8203;168]: uber-go/mock#168

[#&#8203;181]: uber-go/mock#181

[#&#8203;183]: uber-go/mock#183

[#&#8203;191]: uber-go/mock#191

[#&#8203;204]: uber-go/mock#204

[#&#8203;207]: uber-go/mock#207

[#&#8203;214]: uber-go/mock#214

Thanks to [@&#8203;tulzke](https://github.com/tulzke) [@&#8203;JacobOaks](https://github.com/JacobOaks) [@&#8203;ARR4N](https://github.com/ARR4N) [@&#8203;sashamelentyev](https://github.com/sashamelentyev) [@&#8203;sywhang](https://github.com/sywhang) [@&#8203;fasmat](https://github.com/fasmat)
[@&#8203;eyasy1217](https://github.com/eyasy1217) [@&#8203;ghouscht](https://github.com/ghouscht) [@&#8203;tie](https://github.com/tie) [@&#8203;Neo2308](https://github.com/Neo2308) [@&#8203;carson-brill](https://github.com/carson-brill) [@&#8203;alexandear](https://github.com/alexandear) [@&#8203;sodul](https://github.com/sodul)
[@&#8203;nbgraham](https://github.com/nbgraham) for their contributions this release.

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM4LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
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.

Build constraints in generated files
5 participants