metadata.squash_notes _with_ metadata.map_references?

47 views
Skip to first unread message

sudoforge

unread,
Mar 9, 2022, 2:09:31 PM3/9/22
to Copybara OSS
I have a workflow that imports a SoT and generates a summary of the changes using metadata.squash_notes(). Often times, these messages can include references like "#34", which left unchecked, would point to issues/PRs within my repository (and not the source of truth, like it should) on most platforms (e.g. GitHub).

To address this, I'd like to change "#34" to "foo/bar#34" within the squashed notes, which would change the reference that is linked on platforms like GitHub to the appropriate issue/PR within the appropriate user/org repository. To accomplish this, I have a pretty simple transformation:

metadata.map_references(
        before = "#${reference}",
        after = "foo/bar#${reference}",
        regex_groups = {
            "before_ref": "[0-9]+",
            "after_ref": "[0-9]+",
        },
)

This transformation does not seem to work in conjunction with metadata.squash_notes(), regardless of the transformation ordering. Is there something I am missing that would help me accomplish my goal?

Miguel Alcon

unread,
Mar 9, 2022, 2:27:47 PM3/9/22
to sudoforge, Copybara OSS
The problem is that currently map_references works for SHAs but not for PR numbers. It was developed for submitted code (e.g "Rollback abca23432"). The idea makes sense but it is not trivial to implement.

--
You received this message because you are subscribed to the Google Groups "Copybara OSS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to copybara-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/copybara-discuss/4d2d7e46-ccaa-4981-9276-43c55bbc32f6n%40googlegroups.com.

Ben Denhartog

unread,
Mar 12, 2022, 11:45:30 AM3/12/22
to Miguel Alcon, Copybara OSS
I'll make some time to look into a solution for this. Does refactoring `map_references()` to address this use case make sense, or is this something better addressed through refactoring `squash_notes()`?

-- 
  Ben Denhartog

Miguel Alcon

unread,
Mar 14, 2022, 3:25:35 PM3/14/22
to Ben Denhartog, Copybara OSS
Squash_notes should be fine. I think the main change is in map_references logic to ask the destination to also ask after that the origin. Also the destination and origins themselves.
Reply all
Reply to author
Forward
0 new messages