Skip to content

fix(link-checker): distinguish empty diffs from unavailable bases - #1418

Open
BichengWang wants to merge 2 commits into
google-gemini:mainfrom
BichengWang:BichengWang/fix-changed-link-base-20261009
Open

BichengWang wants to merge 2 commits into
google-gemini:mainfrom
BichengWang:BichengWang/fix-changed-link-base-20261009

Conversation

@BichengWang

@BichengWang BichengWang commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

--changed falls through to older refs when a successful diff contains no changed Markdown or notebooks. A branch identical to origin/main can consequently audit unrelated notebooks. When every comparison base is unavailable, the fallback also reports no modified files and exits without scanning the repository.

Stop at the first successful diff, including empty and Python-only diffs. Return None when no base is available so the CLI performs the promised full audit. Add selection and CLI regressions, including a fresh Git repository without commits.

Validation:

  • python3 -m unittest tools/test_check_all_links.py -v: 15 tests pass on Python 3.11. The two unavailable-base regressions fail before the fallback fix.
  • Actual --changed CLI, Pyink on changed lines, Python compilation, and git diff --check pass.

Treat a successful diff with no Markdown or notebook changes as authoritative. Falling back to older refs can audit unrelated historical files and report broken links outside the contribution.

Cover empty and Python-only diffs, unavailable-ref fallback, and CLI no-op behavior with offline regressions.
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 improves the reliability of the link checker's --changed flag. Previously, the tool would incorrectly fall back to older commits if a diff contained no changes to documentation files, potentially triggering audits on unrelated broken links. The changes ensure that a successful diff—even if empty or containing only non-documentation files—is respected as the comparison base, while maintaining appropriate fallback behavior for unavailable references.

Highlights

  • Link Checker Logic: Updated the link checker to correctly handle empty diffs when selecting a base, preventing it from falling back to older refs when no relevant Markdown or notebook files have changed.
  • Regression Testing: Added comprehensive unit tests to verify that the tool stops at the first successful diff and correctly handles fallback scenarios when upstream refs are unavailable.
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 the 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 counterproductive. 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.

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. ↩

@github-actions github-actions Bot added the status:awaiting review PR awaiting review from a maintainer label Oct 10, 2026

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

Copy link
Copy Markdown
Contributor

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 updates tools/check_all_links.py to return the list of changed files once a successful comparison base is established, even if the list is empty, and adds comprehensive unit tests in tools/test_check_all_links.py. Feedback on the changes points out that the fallback logic is broken when no base branch can be determined, as returning a falsy value causes the script to exit early instead of falling back to scanning all files. A code suggestion is provided to properly handle this fallback behavior.

Comment thread tools/check_all_links.py
@BichengWang BichengWang changed the title fix(link-checker): honor empty diffs when selecting a base fix(link-checker): distinguish empty diffs from unavailable bases Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:awaiting review PR awaiting review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant