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

Implement the ~ merge operation #234

Merged
merged 1 commit into from
Jun 5, 2024
Merged

Implement the ~ merge operation #234

merged 1 commit into from
Jun 5, 2024

Conversation

lukaszachy
Copy link
Collaborator

@lukaszachy lukaszachy commented Apr 18, 2024

WDYT?

Todo:

  • find BETTER_NAME for this helper function
  • Documentation
  • smuggle '-~' operator (delete if matches regexp)

@lukaszachy lukaszachy added this to the 1.4 milestone Apr 18, 2024
@lukaszachy lukaszachy added enhancement New feature or request tree labels Apr 18, 2024
fmf/utils.py Outdated Show resolved Hide resolved
examples/merge/parent.fmf Outdated Show resolved Hide resolved
@lukaszachy lukaszachy requested review from psss and happz April 18, 2024 16:17
@lukaszachy
Copy link
Collaborator Author

lukaszachy commented Apr 22, 2024

~ should be done now

I'll add tests and docs for -~ tomorrow.

tests/unit/test_utils.py Outdated Show resolved Hide resolved
@lukaszachy lukaszachy marked this pull request as ready for review April 23, 2024 13:52
@psss psss changed the title Add '~' merge operation Implement the ~ merge operation May 13, 2024
fmf/base.py Outdated Show resolved Hide resolved
@thrix
Copy link
Collaborator

thrix commented May 28, 2024

@LecrisUT can you resolve comments which you are happy about pls?

docs/features.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@thrix thrix left a comment

Choose a reason for hiding this comment

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

LGTM

@LecrisUT
Copy link
Contributor

@LecrisUT can you resolve comments which you are happy about pls?

Issue is that I can't. I can only resolve comments on PRs that I have opened.

I'll give it one more look again tomorrow, but I think all of the issues are resolved. I think the only part is about "\\1", which might be better replaced with '\1' to be inline with the comment:

In the fmf file it is better to use single quotes ``'`` as they do not need such intensive escaping::

(actually maybe should still keep at least one case with "\\1" to be extra safe)

@lukaszachy
Copy link
Collaborator Author

Issue is that I can't. I can only resolve comments on PRs that I have opened.

Yeah. This limitation from github is really strange:/ I have no idea that why anyone who can comment is not suddenly allowed to resolve conversation they started.

@lukaszachy
Copy link
Collaborator Author

/examples/merge/parent.fmf now uses also single quotes so the \1 doesn't need to be escaped

Copy link
Contributor

@LecrisUT LecrisUT left a comment

Choose a reason for hiding this comment

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

Sorry for the late review, just a few minor touches and it's all 👍. You can resolve all of my previous discussions.

fmf/base.py Show resolved Hide resolved
fmf/utils.py Outdated Show resolved Hide resolved
tests/unit/test_utils.py Outdated Show resolved Hide resolved
@martinhoyer
Copy link
Contributor

I like the functionality, but this might be too much regex magic from my PoV. It might get messy with the escapes, etc.
That said, I'm sure you all regex wizards know what you're doing :) Fwiw though, I'd be willing to rewrite it without usage of re module.

@LecrisUT
Copy link
Contributor

LecrisUT commented Jun 3, 2024

I like the functionality, but this might be too much regex magic from my PoV. It might get messy with the escapes, etc.

That was an initial concern for me as well, but check the implementation of fmf.utils.split_pattern_repl. There there is no escaping (other than that coming from yaml, but that's why there is is the documentation suggestion of using ' to reduce escaping).

Fwiw though, I'd be willing to rewrite it without usage of re module

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@martinhoyer
Copy link
Contributor

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

@LecrisUT
Copy link
Contributor

LecrisUT commented Jun 3, 2024

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

An example is worth a hundred words :P. See the () in the search string and the $1 in the replace.

@martinhoyer
Copy link
Contributor

Problem would be with regex groups (named/unnamed). I think that's an important feature to support for this.

@LecrisUT No idea what what those are. Any chance you could enlighten me by pointing to how are they being used here, pretty please?

An example is worth a hundred words :P. See the () in the search string and the $1 in the replace.

Thanks. I still don't get why it's needed, but guessing it is important when you want the users to be able to use regex. I was thinking more about allowing just some "simple" substitutions. :)

@psss
Copy link
Collaborator

psss commented Jun 4, 2024

Fixed a few typos and proposing some minor adjustments in 3a8ee40.

Copy link
Collaborator

@psss psss left a comment

Choose a reason for hiding this comment

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

Just a few minor suggestions.

fmf/utils.py Show resolved Hide resolved
fmf/base.py Outdated Show resolved Hide resolved
fmf/base.py Show resolved Hide resolved
@lukaszachy
Copy link
Collaborator Author

Does someone explain how can fedora-40 and c9s fail on TypeError: adjust() got an unexpected keyword argument 'additional_rules' but rawhide and f-39 pass?

@LecrisUT
Copy link
Contributor

LecrisUT commented Jun 4, 2024

Could be a race condition. Packit uses the merge commit and not the source commit iirc. But the srpm should be the same for all builds so not quite sure

@lukaszachy
Copy link
Collaborator Author

@thrix ? The passing job https://artifacts.dev.testing-farm.io/156d927c-3f15-47f6-8729-adcd97d0ef5f/#artifacts-/plans/features has

git -C testcode fetch https://github.com/teemtee/fmf 33c920df4b1481e14c0c707b0c5469961736a88e:gluetool/33c920df4b1481e14c0c707b0c5469961736a88e
git -C testcode checkout gluetool/33c920df4b1481e14c0c707b0c5469961736a88e
git -C testcode fetch https://github.com/teemtee/fmf 3a8ee401fbaa776f112a7d7948aa8eef935d0743:gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743
git -C testcode merge --no-edit gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743

but failing one https://artifacts.dev.testing-farm.io/9db4c21f-82b9-4f8d-bceb-806577dec328/#artifacts-/plans/features has

git -C testcode fetch https://github.com/teemtee/fmf 673c83ca1cb35256690677c1cddc88a4a2025586:gluetool/673c83ca1cb35256690677c1cddc88a4a2025586
git -C testcode checkout gluetool/673c83ca1cb35256690677c1cddc88a4a2025586
git -C testcode fetch https://github.com/teemtee/fmf 3a8ee401fbaa776f112a7d7948aa8eef935d0743:gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743
git -C testcode merge --no-edit gluetool/3a8ee401fbaa776f112a7d7948aa8eef935d0743

Shouldn't be it the same?

@lukaszachy
Copy link
Collaborator Author

Could be a race condition. Packit uses the merge commit and not the source commit iirc. But the srpm should be the same for all builds so not quite sure

Ah, I guess you are right. Job ran 4h ago and merge (introducing additional_rules) happened also around that time.

@lukaszachy
Copy link
Collaborator Author

@psss I used 'repl' because re.sub(pattern, repl, string, count=0, flags=0) is used in Python itself. But OK to keep longer name.

@lukaszachy lukaszachy requested a review from psss June 5, 2024 07:14
docs/features.rst Outdated Show resolved Hide resolved
Copy link
Collaborator

@psss psss left a comment

Choose a reason for hiding this comment

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

Thanks for all the adjustments!

Co-authored-by: Cristian Le <[email protected]>
Co-authored-by: Petr Šplíchal <[email protected]>
@psss psss self-assigned this Jun 5, 2024
@psss psss merged commit bf511f5 into main Jun 5, 2024
10 checks passed
@psss psss deleted the merge-regexp branch June 5, 2024 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request tree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants