Skip to content

import_srpm: allow to pass a url as source file - #740

Merged
stormi merged 5 commits into
masterfrom
gln/srpm-url-source-qxor
Aug 14, 2026
Merged

stormi merged 5 commits into
masterfrom
gln/srpm-url-source-qxor

Conversation

@glehmann

@glehmann glehmann commented Aug 4, 2025

Copy link
Copy Markdown
Member

This way we don't even have to manually download the srpm.

@glehmann
glehmann requested review from stormi and ydirson August 4, 2025 14:18
Comment thread scripts/import_srpm.py Outdated
@glehmann
glehmann force-pushed the gln/srpm-url-source-qxor branch from 72275f4 to 09f205c Compare August 11, 2025 07:54
@stormi

stormi commented Oct 24, 2025

Copy link
Copy Markdown
Member

@glehmann ready for re-review?

@glehmann
glehmann force-pushed the gln/srpm-url-source-qxor branch from 09f205c to 40a9d07 Compare March 12, 2026 10:05
@stormi

stormi commented Jun 24, 2026

Copy link
Copy Markdown
Member

@glehmann you pushed after my last question but didn't answer nor ask for a re-review. Thus the PR stalled. What's the current status?

@glehmann
glehmann force-pushed the gln/srpm-url-source-qxor branch from 40a9d07 to 1f5fc97 Compare July 7, 2026 10:21
@glehmann
glehmann requested a review from a team as a code owner July 7, 2026 10:21
@glehmann

glehmann commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

The changes were meant to be minimal, hence the lack of temp file removal.
I've updated the PR to properly remove the tempfile, at the cost of an indentation of most of the code

@glehmann
glehmann requested a review from stormi July 10, 2026 08:14
Comment thread scripts/import_srpm.py
source_rpm = args.source_rpm
is_remote_rpm = is_url(source_rpm)

with TemporaryDirectory() if is_remote_rpm else nullcontext() as temp_dir:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe that you could still keep the changes minimal as initially intended by avoiding the use of a context manager. You could use atexit.register(temp_dir.cleanup) to ensure it's cleaned up even in case of a raised exception. Unless I missed something obvious.

Not a blocker comment.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's cleaner that way, so I'd prefer to keep the context manager.
The diff is hard to read in github, but with better diff viewers, it's easy to see that it's mostly indentation changes :)

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.

To make such diffs more readable, a good way is to split things in different commits. Here that could be "add a nullcontext ctxmanager" as a first step.

@glehmann glehmann Jul 15, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So because github is bad at showing this kind of diff, I'm supposed to think about how the diff will be displayed in github and split my work in multiple commits? That seems a bit excessive to me.
Also note that the reviewer would still have to actually look at the diff which indents the code, to make sure nothing is changed.

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.

Note I'm not talking about GH (because we all know how bad they are 😉), but about reviewing with standard git tools.

Comment thread scripts/import_srpm.py
source_rpm = args.source_rpm
is_remote_rpm = is_url(source_rpm)

with TemporaryDirectory() if is_remote_rpm else nullcontext() as temp_dir:

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.

To make such diffs more readable, a good way is to split things in different commits. Here that could be "add a nullcontext ctxmanager" as a first step.

Comment thread scripts/import_srpm.py
Comment on lines +105 to +106
except Exception:
parser.error("Git repository seems to have local modifications.")

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.

That is an unrelated change that does not belong to this commit. Likely a fix for a real bug, since the original code really looks strange:

    except:
        raise
        parser.error("Git repository seems to have local modifications.")

Comment thread scripts/import_srpm.py
Comment on lines +162 to +163
except Exception:
has_changes = True

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.

This too is a separate fix

@glehmann

Copy link
Copy Markdown
Member Author

There was even one more fix, which probably also need its own commit:

image

glehmann added 5 commits July 15, 2026 15:22
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
@glehmann
glehmann force-pushed the gln/srpm-url-source-qxor branch from 1f5fc97 to c404730 Compare July 15, 2026 13:22
@glehmann
glehmann requested a review from ydirson July 15, 2026 13:23

@ydirson ydirson 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.

otherwise ok

Comment thread scripts/import_srpm.py
Comment on lines +82 to +87
with TemporaryDirectory() if is_remote_rpm else nullcontext() as temp_dir:
if is_remote_rpm:
# get the src.rpm locally, and continue with the actual file
local_filename = f'{temp_dir}/{os.path.basename(source_rpm)}'
urlretrieve(source_rpm, local_filename)
source_rpm = local_filename

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.

The non-remote case could possibly be simplified: there seems to be no need to use a context manager at all in that case, if all the actions inside the with block are for the other case:

Suggested change
with TemporaryDirectory() if is_remote_rpm else nullcontext() as temp_dir:
if is_remote_rpm:
# get the src.rpm locally, and continue with the actual file
local_filename = f'{temp_dir}/{os.path.basename(source_rpm)}'
urlretrieve(source_rpm, local_filename)
source_rpm = local_filename
if is_remote_rpm:
with TemporaryDirectory() as temp_dir:
# get the src.rpm locally, and continue with the actual file
local_filename = f'{temp_dir}/{os.path.basename(source_rpm)}'
urlretrieve(source_rpm, local_filename)
source_rpm = local_filename

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it would work: the TemporaryDirectory context manager would delete the directory when exiting the with block, but we still need what this dir contains later in the code

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.

mb, looks like I read that with too little context :(

@stormi
stormi merged commit 30df2c8 into master Aug 14, 2026
3 checks passed
@stormi
stormi deleted the gln/srpm-url-source-qxor branch August 14, 2026 10:05
@glehmann
glehmann restored the gln/srpm-url-source-qxor branch September 29, 2026 09:15
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.

3 participants