Skip to content

Add update/unchanged file reporting to update-po command#461

Merged
swissspidy merged 12 commits intomainfrom
copilot/fix-1570774-111592377-8d1e68ec-3eae-4dfa-abd4-ecdb9fb7198f
Jan 25, 2026
Merged

Add update/unchanged file reporting to update-po command#461
swissspidy merged 12 commits intomainfrom
copilot/fix-1570774-111592377-8d1e68ec-3eae-4dfa-abd4-ecdb9fb7198f

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

Implement feature to report updated vs unchanged PO files in update-po command

  • Explore repository structure and understand the UpdatePoCommand
  • Review existing test scenarios
  • Implement change detection in UpdatePoCommand.php
    • Clone original translations before merging
    • Compare Translation objects to detect actual changes
    • Track updated vs unchanged file counts separately
    • Update success message to show both updated and unchanged files
    • Simplify message formatting logic
  • Add new test scenarios for the change detection feature
    • Test when no files change (POT unchanged)
    • Test when some files change and some don't
  • Update documentation examples in the command docblock
  • Fix change detection to compare objects instead of file content
    • Avoids false positives from timestamp/formatting changes
    • Compares actual translation data, references, and comments
  • Fix method name: use getComments() instead of non-existent getTranslatorComments()
  • Remove redundant loop in translations_differ() method for performance
  • Fix test expectation for PO-Revision-Date scenario (file with new string should report as updated)

Summary

This PR implements the feature request from issue #333 to improve the update-po command reporting.

Changes Made

  1. UpdatePoCommand.php:

    • Clone original translations before merging
    • Compare Translation objects instead of file content to detect actual changes
    • Added translations_differ() method that compares:
      • Translation counts
      • Individual translation strings and plurals
      • Source code references
      • Extracted comments and translator comments
    • Updated success message to show both updated and unchanged counts
    • Fixed to use correct getComments() method
    • Removed redundant second loop that checked for new translations (already covered by count check + first loop)
  2. updatepo.feature:

    • Added test scenario for unchanged files when POT hasn't changed
    • Added test scenario for mixed updated/unchanged files
    • Fixed test expectation for "Updates PO-Revision-Date" scenario - when a new string is added to POT, the file should be reported as updated

Output Examples

  • Success: Updated 0 files. 1 file unchanged. - When no files need updating
  • Success: Updated 1 file. - When one file is updated, none unchanged
  • Success: Updated 4 files. 2 files unchanged. - When multiple files, some updated some not

How It Works

The implementation now properly detects changes by comparing Translation objects instead of raw file content. This avoids false positives from timestamp updates or formatting changes that the gettext library makes when writing PO files.

Original prompt

This section details on the original issue you should resolve

<issue_title>update-po: Update/no changes report</issue_title>
<issue_description>## Feature Request

Describe your use case and the problem you are facing
(Side note: The new update-po subcommand is awesome!)

Currently it will report that the PO files were updated, even they hadn't changed (because the POT file hadn't changed).

Describe the solution you'd like
update-po should either report updated files or files that didn't need an update/changing.

Some examples:

Success: Updated 0 files. 1 file unchanged.
Success: Updated 1 file.
Success: Updated 4 files. 2 files unchanged.

This also helps spotting the need for adding/updating translations without using something like a diff tool or inspecting the last modified date of the POT file(s).</issue_description>

Comments on the Issue (you are @copilot in this section)

@swissspidy Thanks for sharing this suggestion 👍

Would need to check if it's easily possible to detect changes/modifications like that.</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 3, 2025 14:00
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] update-po: Update/no changes report Add update/unchanged file reporting to update-po command Nov 3, 2025
Copilot AI requested a review from swissspidy November 3, 2025 14:06
@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

❌ Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/UpdatePoCommand.php 85.36% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

… content

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy swissspidy marked this pull request as ready for review January 25, 2026 15:34
@swissspidy swissspidy requested a review from a team as a code owner January 25, 2026 15:34
@swissspidy swissspidy merged commit 511666d into main Jan 25, 2026
58 of 59 checks passed
@swissspidy swissspidy deleted the copilot/fix-1570774-111592377-8d1e68ec-3eae-4dfa-abd4-ecdb9fb7198f branch January 25, 2026 15:38
@swissspidy swissspidy added this to the 2.6.7 milestone Jan 25, 2026
@strarsis
Copy link
Contributor

Awesome 🎆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

update-po: Update/no changes report

3 participants