gapic-generator-python
gapic-generator-python copied to clipboard
Update copyright year automatically
Our policy is that we can update the copyright year every time we re-generate a file. We certainly need to have the current year on new files.
To update the year automatically, we should have it fetched from the system time in the template https://github.com/googleapis/gapic-generator-python/blob/main/gapic/templates/_license.j2
At the same time, we shouldn't have to manually update all the golden files every January to reflect the new year.
Some ideas:
- We could either replace the year before we compare golden files to generated output in system tests
- When running system tests, we could mock the system time to a fixed value (eg
2345-06-07). This may involve adding a generator option for the mock time and changing the*_py_gapictargets in https://github.com/googleapis/gapic-generator-python/blob/main/tests/integration/BUILD.bazel- We can probably simply use a function that will return a string representation of the year from the value provided in the new mock-time generator option, and if no such value was provided, just the system year.
- For completeness: there is time mocking library that is probably more heavyweight than we need at https://pypi.org/project/time-machine/
Since the work above is not trivial, for the time being I am manually updating the copyright year to 2024 (see #1959)