vektra / mockery

A mock code autogenerator for Go
https://vektra.github.io/mockery/
BSD 3-Clause "New" or "Revised" License
6.15k stars 412 forks source link

`disable-version-string` not respected in packages config #785

Open LandonTClipp opened 5 months ago

LandonTClipp commented 5 months ago

https://github.com/vektra/mockery/discussions/783#discussioncomment-9682934

Tochemey commented 5 months ago

@LandonTClipp I can take a look at this in the weekend if you don't mind. You can assign it to me.

LandonTClipp commented 5 months ago

That would be great! Thanks @Tochemey .

Tochemey commented 5 months ago

@LandonTClipp I took a look at the code and I can see the prologue is always displayed. Something that is necessary. However disabling the version number seems be odd to me because I believe having to know which version of the tool is used is really important for migration or any update or bug fixes that will be needed by the developer.

I am of the opinion we should not even allow this flag to be there at all.

Tochemey commented 5 months ago

@LandonTClipp what is your take on this suggestion?

LandonTClipp commented 5 months ago

Hi @Tochemey , I think there is a legitimate use-case for developers. Often, projects will specify the exact version of mockery to use, and they will have a Makefile that does something like go run github.com/vektra/mockery which will pull down the specific version specified in go.mod. Some projects like to regularly update mockery, but doing so without disabling the version string can result in huge PRs that do not have any real changes. Some people just don't like that.

BenjaminNolan commented 3 months ago

If it'd help, I can pick this up, as it generates a lot of boilerplate PR lines for us.

diff --git a/mocks/db/Querier.go b/mocks/db/Querier.go
index e2a6681..8f75751 100644
--- a/mocks/db/Querier.go
+++ b/mocks/db/Querier.go
@@ -1,4 +1,4 @@
-// Code generated by mockery v2.43.1. DO NOT EDIT.
+// Code generated by mockery v2.43.2. DO NOT EDIT.

 package mocks

diff --git a/mocks/db/DBTX.go b/mocks/db/DBTX.go
index f1b0504..404ac86 100644
--- a/mocks/db/DBTX.go
+++ b/mocks/db/DBTX.go
@@ -1,4 +1,4 @@
-// Code generated by mockery v2.43.1. DO NOT EDIT.
+// Code generated by mockery v2.43.2. DO NOT EDIT.

 package mocks

diff --git a/mocks/db/Querier.go b/mocks/db/Querier.go
index fa5fe8c..d309ede 100644
--- a/mocks/db/Querier.go
+++ b/mocks/db/Querier.go
@@ -1,4 +1,4 @@
-// Code generated by mockery v2.43.1. DO NOT EDIT.
+// Code generated by mockery v2.43.2. DO NOT EDIT.

 package mocks

diff --git a/mocks/registerServiceFunc.go b/mocks/registerServiceFunc.go
index 0ff27d1..f7820f2 100644
--- a/mocks/registerServiceFunc.go
+++ b/mocks/registerServiceFunc.go
@@ -1,4 +1,4 @@
-// Code generated by mockery v2.43.1. DO NOT EDIT.
+// Code generated by mockery v2.43.2. DO NOT EDIT.

 package mocks

Just four out of about 3000 in our project. :)

I've actually added a line to our make mocks target which removes the version number, but it's really slow so getting the flag to work is preferable:

@mockery --all --keeptree --dir=./internal --output=./mocks
@for i in $$(grep -HlRE 'Code generated by mockery v[0-9]+\.[0-9]+\.[0-9]+\. DO NOT EDIT\.' mocks); do \
    sed -i'' -e 's/Code generated by mockery v[0-9]\+\.[0-9]\+\.[0-9]\+\. DO NOT EDIT\./Code generated by mockery. DO NOT EDIT./g' $$i; \
done

So, yeah, LMK if you want / need me to jump in. :)

LandonTClipp commented 3 months ago

Please do go for it, it should be a very simple change. I cannot sit down at a computer for the next few days.