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: ignore go build constraints #22

Merged
merged 1 commit into from Sep 21, 2023
Merged

feat: ignore go build constraints #22

merged 1 commit into from Sep 21, 2023

Conversation

pascal-hofmann
Copy link
Contributor

@pascal-hofmann pascal-hofmann commented Sep 20, 2023

Hi,
first of all: thanks for this great tool! (I'm using it as part of https://github.com/renovatebot/renovate.)

I noticed that mod does not ignore build constraints when upgrading/downgrading Semantic Import Versioning.

This PR will change mod, so it will ignore go build constraints and upgrade/downgrade Semantic Import Versioning in all .go files. The flag buildflags has been removed, as it makes no sense anymore.

There does not seem to be a way to get the golang.org/x/tools/go/packages to ignore build constraints, so I now only use it to get information about all packages and their GoFiles plus the IgnoredFiles (source files that are not part of the package using the current build configuration but that might be part of the package using other build configurations).

These files are then parsed using go/parser. Apart from this, the update logic has not changed.

Cheers
Pascal

PS: I also replaced the deprecated call to ioutil.WriteFile(…) with os.WriteFile(…).

@pascal-hofmann pascal-hofmann marked this pull request as draft September 20, 2023 09:28
BREAKING CHANGE: mod will now ignore go build constraints and upgrade/downgrade
                 Semantic Import Versioning in all .go files.
                 The flag `buildflags` has been removed.
@pascal-hofmann pascal-hofmann marked this pull request as ready for review September 20, 2023 09:46
@pascal-hofmann
Copy link
Contributor Author

pascal-hofmann commented Sep 21, 2023

@marwan-at-work It would be great to get this merged soon. We have some pending major upgrades in multiple projects that mod/renovate currently can't handle because integration / unit tests are left unchanged (they all have build constraints).

Copy link
Owner

@marwan-at-work marwan-at-work left a comment

Choose a reason for hiding this comment

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

Thanks!

@marwan-at-work marwan-at-work merged commit 899a558 into marwan-at-work:master Sep 21, 2023
@pascal-hofmann pascal-hofmann deleted the feat/ignore-build-tags branch September 21, 2023 10:12
@pascal-hofmann
Copy link
Contributor Author

@marwan-at-work Awesome - thanks for the quick merge! Can you create a new github release?

@pascal-hofmann
Copy link
Contributor Author

@marwan-at-work Any chance to get a new release with this? This would help us a lot with some tedious pending upgrades that renovate could do instead of us doing it manually.

@pascal-hofmann
Copy link
Contributor Author

@marwan-at-work Any update on creating a new release? Is this blocked by something or do you need help with this?

@marwan-at-work
Copy link
Owner

@pascal-hofmann apologies for the delay, here's the release https://github.com/marwan-at-work/mod/releases/tag/v0.6.0

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.

None yet

2 participants