Skip to content

Conversation

@zhumin8
Copy link
Contributor

@zhumin8 zhumin8 commented Jan 20, 2026

Preserve original copyright years by detecting and retaining existing headers during YAML write operations. The performance impact of the extra read should be negligible compared YAML marshaling and formatting.

An cleaner alternative is to refactor yaml.Read and Write to accept a receiver. Did not take this route to keep scope of this change small, but probably worth explore it when we want to attempt #3149.

Fix #3514

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zhumin8, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where writing YAML files would inadvertently update the copyright year in the header to the current year, even if an older year was present. The changes ensure that the original copyright year is detected and retained when a YAML file is written back, maintaining the integrity of existing copyright notices. This is achieved by reading the file's current content to extract the year before writing, with a negligible performance impact on typical configuration files.

Highlights

  • Copyright Year Preservation: The Write function for YAML files now reads the existing file to detect and preserve the original copyright year, preventing it from being overwritten with the current year.
  • Dynamic Copyright Header: Introduced a new Header function in internal/yaml/copyright.go that generates the copyright string with a specified year, replacing the previous static copyright constant.
  • Regex for Year Extraction: A regular expression (yearRegex) was added to internal/yaml/yaml.go to efficiently parse and extract the copyright year from existing file headers.
  • New Test Case: A dedicated test, TestWrite_PreservesYear, was added to internal/yaml/yaml_test.go to ensure the copyright year preservation logic functions correctly.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a nice improvement to preserve the copyright year when updating YAML files. The implementation is sound, and the addition of a new test case to cover this behavior is excellent. I have one suggestion in internal/yaml/yaml.go to refactor a nested block of code to improve readability and maintainability, in line with the project's Go style guide.

@codecov
Copy link

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 78.57143% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.21%. Comparing base (819270f) to head (559b209).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
internal/yaml/yaml.go 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3656      +/-   ##
==========================================
- Coverage   82.50%   82.21%   -0.30%     
==========================================
  Files         140      143       +3     
  Lines       12761    13221     +460     
==========================================
+ Hits        10529    10869     +340     
- Misses       1736     1827      +91     
- Partials      496      525      +29     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

librarian: remove hard coded copyright year for librarian.yaml header

1 participant