Get the patch (including the commit message(s)) for a merge proposal?

Asked by Thomas Bechtold on 2021-04-15

Is there a way to get the full patch (including the commit messages) for a git merge proposal?

Similar to appending .patch to a github PR url (eg. https://github.com/canonical/multipass/pull/2056.patch )

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:

I don't think we have a URL like this today, but it should be possible get something similar using launchpadlib:

$ lp-shell production devel

mp = lp.load('~toabctl/cloud-init/+git/cloud-init/+merge/363590')
print(f"From {mp.merged_revision_id} {mp.date_merged}")
print(f"From: {mp.merge_reporter.name} ({mp.merge_reporter.preferred_email_address.email})")
print(mp.commit_message)
with mp.preview_diff.diff_text.open() as fd:
    print(fd.read().decode('utf8'))

See https://launchpad.net/+apidoc/devel.html#branch_merge_proposal for available attributes on the MP object.

And feel free to open a bug requesting such URL if the API is not enough.

Can you help with this problem?

Provide an answer of your own, or ask Thomas Bechtold for more information if necessary.

To post a message you must log in.