gapic-generator-python icon indicating copy to clipboard operation
gapic-generator-python copied to clipboard

Update copyright year automatically

Open vchudnov-g opened this issue 1 year ago • 1 comments

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_gapic targets 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/

vchudnov-g avatar Feb 29 '24 20:02 vchudnov-g

Since the work above is not trivial, for the time being I am manually updating the copyright year to 2024 (see #1959)

vchudnov-g avatar Feb 29 '24 20:02 vchudnov-g