Skip to content

Add script to check that deleted slides have redirects#3174

Open
bridadan wants to merge 1 commit intogoogle:mainfrom
bridadan:check_redirects
Open

Add script to check that deleted slides have redirects#3174
bridadan wants to merge 1 commit intogoogle:mainfrom
bridadan:check_redirects

Conversation

@bridadan
Copy link
Copy Markdown

Fixes #1417.

This adds a script and a CI job to ensure that slides that are deleted have a matching redirect entry in bool.toml.

If a redirect entry is not found (for example, for src/hello-world.md), the following is printed before exiting with a status of 1:

The following deleted files have missing redirect entries in book.toml:                                                                                                       
src/hello-world.md

fetch-depth: 0

- name: Check redirects
run: python3 .github/workflows/check-redirects.py . origin/main
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It looks like this only looks at the diff in a single revision. For PRs with multiple commits, will it find the full diff?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I just tested this locally on a branch with two commits, each committing deleting one slide. The script properly detected both deleted slides, so it should work fine in CI:

$ git log
commit a1a3e4115a6a6fede4dda6518a4203c034173349 (HEAD -> check_redirects)
Author: Brian Daniels <briandaniels@google.com>
Date:   Mon Apr 27 13:53:37 2026 +0000

    Remove testing

commit 134f009a6d068a3c060729ab1c0abaa5a57128c2
Author: Brian Daniels <briandaniels@google.com>
Date:   Mon Apr 27 13:53:28 2026 +0000

    Remove hello-world

commit d2f0872c3af1b78405df6d8adaa20725454703b8 (bridadan/check_redirects)
Author: Brian Daniels <briandaniels@google.com>
Date:   Fri Apr 17 20:21:55 2026 +0000

    Add script to check that deleted slides have redirects

commit 03130e81a8e2aa732fbaeac8016ae94193c9bb0b (origin/main, origin/HEAD)
Author: Nicole L <dlegare.1001@gmail.com>
Date:   Tue Apr 14 13:13:48 2026 -0700

    Idiomatic: Use reference-style links in signposting slide (#3161)

    Using inline links in doc comments can result in really long lines that
    are unwieldy and hard to parse when looking at the unrendered source
    comments. I'd like to show students that you can use the reference style
    links to keep the source comment readable while still taking advantage
    of markdown links to point readers to external resources.

$ python .github/workflows/check-redirects.py . origin/main
The following deleted files are missing a redirect entry in book.toml:
src/hello-world.md
src/testing.md

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Awesome, thanks for checking!

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.

Detect deletion of slides without corresponding book.toml entry

2 participants