Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we commit built_value generated code to git?

built_value generates .g.dart code, but the docs don't give any hints if we should add them to our git repository or not.

I think we should, so devs cloning our repo could be up and running, without having to regenerate the code...But some people say generated code should never be committed, so, what's the recommendation for built_value?

like image 982
Michel Feinstein Avatar asked Mar 15 '19 05:03

Michel Feinstein


1 Answers

If you are building a library package that you want to reuse by other packages and applications, then you should commit it.

Code generation can not generate code in dependencies and pub publish ignores .gitignored files. You would publish invalid packages. Also git-dependencies would not work in such cases.

There are packages that generate code only in the application project, also for code imported from dependencies, like reflectable does. In this case you wouldn't need to commit the generated code.

I always commit such generated code even in application projects. These files have specific extentions like .g.dart that can be excluded from code review to not cause noise or similar.

like image 187
Günter Zöchbauer Avatar answered Nov 18 '22 05:11

Günter Zöchbauer