Skip to content

Prevent PR refs being deleted by git push --mirror #18174

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

Closed
xyzroller opened this issue Jan 4, 2022 · 2 comments
Closed

Prevent PR refs being deleted by git push --mirror #18174

xyzroller opened this issue Jan 4, 2022 · 2 comments

Comments

@xyzroller
Copy link

Feature Description

What am I trying to achieve?

My project's "source-of-truth" repositories are on one Gitea server and I would like to mirror them to another Gitea server to enable collaboration there.

E.g., my primary "source of truth" repositories are on a self-hosted Gitea instance and I would like to enable collaboration on Codeberg.

To do this, I add a post-receive GitHook to the primary ("source-of-truth") repository to git push --mirror to the secondary repository.

What's the problem?

When a PR is submitted on the secondary, my workflow on my local machine is to 1) pull main from the primary, 2) check out a new feature branch, 3) pull from the contributor's fork feature branch, 4) merge the feature branch to main and then 5) push main to the primary.

The primary then push mirrors to the secondary and the PR on the secondary is broken and gives a 500 error.

The PR seems to break because mirroring the primary repository to the secondary deletes the refs for the PR on the secondary - the refs aren't present on the primary repo and are therefore deleted when git push --mirror is executed -- see "...deleted refs will be removed from the remote end" in the git-push --mirror docs here

Feature Request - How could/should it work?

The workflow above is working:

  • when the PR is on the primary
  • when the secondary is a GitHub mirror. Probably because "The remote refs/pull/ namespace is read-only" -- see here -- so that the PR refs on GitHub are not deleted when git push --mirror executes on the primary.

In both of these cases, merging a PR feature branch locally leads to the PR being automatically recognised as "manually merged" <-- this is what I am ultimately trying to achieve on a Gitea mirror.

With a Gitea secondary, if instead of using git push --mirror on the primary repository post-receive Git Hook, I use git push --all followed by git push --prune, then the merge on the primary is pushed to the secondary without deleting the PR refs and the PR on the secondary is automatically detected as "manually merged", which is what I want to happen. However, mirroring would be preferred.

So the feature request is: Make PR refs read-only (as GitHub does) so that mirroring does not break PRs on a mirror repository and so that merges via the primary lead to PRs on the seconday being detected as "manually merged".

If it is dangerous to do this by default, this could be a configurable option, e.g. in the Settings --> Repository --> Pull Requests section.

Screenshots

No response

a1012112796 added a commit to a1012112796/gitea that referenced this issue Jan 8, 2022
@SPC-code
Copy link

SPC-code commented Jan 5, 2024

Is there a way to fix this behavior? We use gitea as a stand-alone repository and github as a push mirror. The problem is that all Merge requests on github are automatically closed.

@a1012112796
Copy link
Member

fixd by #31931

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants