Skip to content

Differentiate archives and regular files in XML diffs#19372

Open
Sahitya0805 wants to merge 1 commit intoopenSUSE:masterfrom
Sahitya0805:feature/issue-18399-xml-diff-kind
Open

Differentiate archives and regular files in XML diffs#19372
Sahitya0805 wants to merge 1 commit intoopenSUSE:masterfrom
Sahitya0805:feature/issue-18399-xml-diff-kind

Conversation

@Sahitya0805
Copy link
Copy Markdown
Contributor

@Sahitya0805 Sahitya0805 commented Mar 1, 2026

Differentiate archives and regular files in XML diffs

Description

Currently, when requesting an XML diff of a package, the <file> nodes do not distinguish between archive files (like .tar.gz, .zip) and regular text files. This makes it difficult for API consumers to know if a diff contains individual file changes or if it's a diff of an archive's contents without fetching the file directly.

This PR introduces a kind attribute to the file element in the XML diff output. The kind attribute can have the value archive for known archive formats or file for regular text files.

This change modifies:

  • src/backend/BSXML.pm: Updated the sourcediff schema to include the kind attribute.
  • src/backend/BSSrcServer/Srcdiff.pm: Added an is_archive helper and updated datadiff to populate the kind attribute based on file extensions.

Why this change?

To improve API usability by providing more metadata about files in a diff result, enabling clients to handle different file types appropriately without extra requests.

How to verify this change?

To verify this backend change, you can use osc to check the XML output structure.

  1. Setup a test package with at least one archive file (e.g., test.tar.gz) and one regular file (e.g., test.patch).
  2. Request an XML diff of the package:
    osc api "/source/<project>/<package>?cmd=diff&view=xml"
  3. Check the output for the kind attribute:
    <file state="changed" kind="archive">
      <old name="test.tar.gz" .../>
      <new name="test.tar.gz" .../>
    </file>
    <file state="changed" kind="file">
      <old name="test.patch" .../>
      <new name="test.patch" .../>
    </file>

Performance considerations

The change adds a simple regex check for file extensions during diff generation, which has negligible performance impact.

Side effects

None expected. The XML schema change is additive and backward compatible.

Closes

Closes #18399.

@github-actions github-actions bot added Frontend Things related to the OBS RoR app Backend Things regarding the OBS backend labels Mar 1, 2026
@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch from 12898fe to cfff135 Compare March 1, 2026 05:36
@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch 2 times, most recently from f8ec27c to 18f4161 Compare March 9, 2026 04:48
@Sahitya0805 Sahitya0805 marked this pull request as draft March 9, 2026 04:51
@Sahitya0805 Sahitya0805 marked this pull request as ready for review March 9, 2026 05:16
@Sahitya0805 Sahitya0805 marked this pull request as draft March 13, 2026 01:15
@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch from 18f4161 to 3dee083 Compare March 14, 2026 19:00
@hennevogel hennevogel removed the Frontend Things related to the OBS RoR app label Mar 16, 2026
@Sahitya0805
Copy link
Copy Markdown
Contributor Author

This change was made to fix the OBS build for obs-bundled-gems. The previous strict version pins were causing dependency issues during the build, so I relaxed them to >= to allow compatible versions.

If you'd prefer, I can move this change into a separate PR so this one only contains the XML diff kind attribute changes.

@hennevogel
Copy link
Copy Markdown
Member

@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch 2 times, most recently from e20f272 to b3e644f Compare March 16, 2026 12:39
@Sahitya0805 Sahitya0805 marked this pull request as ready for review March 16, 2026 13:19
@Sahitya0805
Copy link
Copy Markdown
Contributor Author

I've updated the implementation to include the kind attribute (file or archive) in the XML diff output. This should allow API consumers to distinguish between regular files and archives as described in #18399.

I also refactored the archive detection into an is_archive helper to avoid repeating the regex checks.

@hennevogel hennevogel dismissed their stale review March 16, 2026 15:47

This PR is only about backend code by now, not my area of expertise...

@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch from d98274e to 3971878 Compare March 19, 2026 04:33
@Sahitya0805 Sahitya0805 force-pushed the feature/issue-18399-xml-diff-kind branch from 2322959 to ab57f5d Compare March 22, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backend Things regarding the OBS backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Differentiate archives and regular diffs in the xml diffs

2 participants