Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd-diff: support lightweight ostree import for RPM diff #4030

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

dustymabe
Copy link
Member

@dustymabe dustymabe commented Feb 26, 2025

Being able to diff two builds is now a very lightweight:

cosa buildfetch --build=A
cosa buildfetch --build=B
cosa diff --rpms --from=A --to=B

Previously this was hundreds of MiB and now it's in the KiB range.

EDIT: Added another commit:

cmd-diff: support showing source-control diffs for two builds

Useful for trying to determine the changes that occured for two builds
that were outside of RPM changes. Example:

$ cosa diff --source-control --from=42.20240919.91.0 --to=42.20240920.91.0
https://github.com/coreos/fedora-coreos-config: 80f646d..051fb67
    --> https://github.com/coreos/fedora-coreos-config/compare/80f646d...051fb67
https://github.com/coreos/coreos-assembler.git: d3302e0..d3302e0
    --> https://github.com/coreos/coreos-assembler/compare/d3302e0...d3302e0

Since python has propoer boolean types we should be using that here.
Being able to diff two builds is now a very lightweight:

```
cosa buildfetch --build=A
cosa buildfetch --build=B
cosa diff --rpms --from=A --to=B
```

Previously this was hundreds of MiB and now it's in the KiB range.
```
DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for
removal in a future version. Use timezone-aware objects to represent datetimes
in UTC: datetime.datetime.now(datetime.UTC).
```
I think it's of limited use that we arbitrarily hit some threshold
and then are urged to write more tests by a percentage metric here.
Let's just drop it.
@dustymabe
Copy link
Member Author

If you want to see these commands in action you can check out the few comments starting at containers/podman#25121 (comment)

Useful for trying to determine the changes that occured for two builds
that were outside of RPM changes. Example:

```
$ cosa diff --source-control --from=42.20240919.91.0 --to=42.20240920.91.0
https://github.com/coreos/fedora-coreos-config: 80f646d..051fb67
    --> coreos/fedora-coreos-config@80f646d...051fb67
https://github.com/coreos/coreos-assembler.git: d3302e0..d3302e0
    --> coreos/coreos-assembler@d3302e0...d3302e0
```
@@ -31,7 +31,7 @@ class DiffBuildTarget:
class Differ:
name: str
description: str
needs_ostree: bool
needs_ostree: str
Copy link
Member

Choose a reason for hiding this comment

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

This would be cleaner as an enum.

Comment on lines +79 to +88
ostree_import = ''
for differ in active_differs:
if differ.needs_ostree == 'yes':
ostree_import = 'full'
# If we need a full import for one then we don't
# need to check the others.
break
elif differ.needs_ostree == 'partial':
ostree_import = 'partial'
if ostree_import != '':
Copy link
Member

Choose a reason for hiding this comment

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

If we change it to an enum as suggested in the previous comment, then this could be e.g.

ostree_import = max([d.needs_ostree for d in active_differs])
if ostree_import > OstreeImport.NONE:
    ...
        ..., partial_import=(ostree_import == OstreeImport.PARTIAL))

if not config_shared_history:
# If they weren't from the same repo/branch, etc then
# there's not really any way to compare them easily
# so just output the details gorry details and move on.
Copy link
Member

Choose a reason for hiding this comment

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

details twice
also s/gorry/gory/

@@ -114,6 +114,30 @@ def parse_args():
return parser.parse_args()


def diff_source_control(diff_from, diff_to):
Copy link
Member

Choose a reason for hiding this comment

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

This is fine and clearly useful as is, but assuming that it's on GitHub seems like a leap for the developer case, no? It seems like it'd be cleaner to just do the git diff ourselves given that we have src/config.

I guess for the cosa case, the GitHub link is the best we can do.

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.

2 participants