Skip to content

headless_api: add merge-remote action (bug 1980701)#516

Open
jcristau wants to merge 2 commits intomozilla-conduit:mainfrom
jcristau:merge-remote
Open

headless_api: add merge-remote action (bug 1980701)#516
jcristau wants to merge 2 commits intomozilla-conduit:mainfrom
jcristau:merge-remote

Conversation

@jcristau
Copy link
Copy Markdown
Contributor

This adds a merge-remote action to the headless API, that takes a git repository URL and commit hash to merge into the target repo. The intended use case is importing code and its history from an existing repository, such as when https://github.com/mozilla/application-services will be merged into https://github.com/mozilla-firefox/firefox.

This adds a merge-remote action to the headless API, that takes a git
repository URL and commit hash to merge into the target repo.  The intended use
case is importing code and its history from an existing repository, such as
when https://github.com/mozilla/application-services will be merged into
https://github.com/mozilla-firefox/firefox.
@jcristau jcristau marked this pull request as ready for review October 22, 2025 16:19
@cgsheeh cgsheeh self-requested a review October 23, 2025 18:32
@shtrom
Copy link
Copy Markdown
Member

shtrom commented Oct 27, 2025

One thing that we should be careful with merges of native git branches is that cinnabar doesn't support signed commits. If we allow any signed commit to land into a repo synced to HgMO with git-hg-sync, this will immediately create a divergence which will be painful to resolve.

I think it might be worth adding a dedicated landing check that would ensure that none of the commits are signed before pushing. -> https://bugzilla.mozilla.org/show_bug.cgi?id=1996492

@shtrom
Copy link
Copy Markdown
Member

shtrom commented Oct 27, 2025

Unfortunately, it seems all commits in application-services are signed, so we'll have to make sure to strip the signatures.

image

Copy link
Copy Markdown
Member

@cgsheeh cgsheeh left a comment

Choose a reason for hiding this comment

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

Looking very good, I think once we have some more test coverage and docs for the ALLOWED_MERGE_REMOTE_REPOS setting this will be good to go. 👍

Comment thread src/lando/settings.py

HTTP_USER_AGENT = f"Lando/{version} ({ENVIRONMENT})"

ALLOWED_MERGE_REMOTE_REPOS = os.getenv("ALLOWED_MERGE_REMOTE_REPOS", "").split(",")
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.

Can we document what values we might expect here? Should this be full paths to repo URLs (https://github.com/mozilla/repo), owner/repo Github paths (mozilla/repo), or are we assuming the local repo has had a git remote add repo-remote https://github.com/mozilla/repo and the value here is repo-remote?



class MergeRemoteAction(Schema):
"""Merge changes from a remote repository"""
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.

Suggested change
"""Merge changes from a remote repository"""
"""Merge changes from a remote repository."""

scm = repo.scm
scm.push = mock.MagicMock()

settings.ALLOWED_MERGE_REMOTE_REPOS = [repo.path]
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 think we should add a test that asserts the merge is rejected on a repo name that isn't in the ALLOWED_MERGE_REMOTE_REPOS setting. If someone removed that check it wouldn't show up in the tests at the moment. :)

@cgsheeh
Copy link
Copy Markdown
Member

cgsheeh commented Nov 3, 2025

Unfortunately, it seems all commits in application-services are signed, so we'll have to make sure to strip the signatures.
image

@shtrom filed https://bugzilla.mozilla.org/show_bug.cgi?id=1996492 to implement a check which ensures signed commits aren't merged into the repo.

@jcristau
Copy link
Copy Markdown
Contributor Author

jcristau commented Nov 4, 2025

Thanks for the reviews. Out of curiosity, is there a reference for the issue with cinnabar and signed commits?

@shtrom
Copy link
Copy Markdown
Member

shtrom commented Nov 5, 2025

Thanks for the reviews. Out of curiosity, is there a reference for the issue with cinnabar and signed commits?

From my end, nothing but conversations with @glandium and pain when rolling out https://github.com/mozilla-conduit/git-hg-sync.

I could perhaps add a warning here: https://moz-conduit.readthedocs.io/en/latest/git-hg-sync.html

@glandium
Copy link
Copy Markdown

glandium commented Nov 5, 2025

cinnabar doesn't support signed commits.

To be pedantic: it ignores the signatures. So when converting to mercurial, the signature is lost. This means on a conversion back to git from mercurial without cinnabar metadata, the resulting git commit is different. With preserved cinnabar metadata, signed commits should be handled just fine. Things get more complicated when identical signed and unsigned git commits exist (same parent, same commit message, same content), because cinnabar can't handle the situation as both commits will map to the same mercurial changeset.

@shtrom
Copy link
Copy Markdown
Member

shtrom commented Nov 7, 2025

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.

4 participants