[GH-ISSUE #214] Forks overwriting original repos #226

Closed
opened 2026-04-11 09:10:37 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @m8tec on GitHub (Mar 6, 2026).
Original GitHub issue: https://github.com/RayLabsHQ/gitea-mirror/issues/214

Originally assigned to: @arunavo4 on GitHub.

It seems the tool tries to be a bit too smart when handling forks. If it mirrors a fork, it looks at the original creator (the parent) and saves the fork under the parent's namespace in Gitea, instead of the person who actually owns the fork.

Here is what happened to me:

  • I am m8tec and I have my original repository m8tec/nice-repo.
  • Another user named nice-user forked it, creating nice-user/nice-repo.
  • My GitHub token has access to his fork. So your tool naturally picks it up to mirror it.
  • The Disaster: Instead of creating nice-user/nice-repo in my Gitea, the tool sees that I (m8tec) am the original author of that code. So it takes nice-user's forked code and pushes it straight into m8tec/nice-repo in my Gitea, overwriting the original repo.

Possible fixes:

  • When "Preserve Structure" is on, a fork should just be saved under the namespace of the person who forked it. nice-user/nice-repo needs to go to nice-user/nice-repoin Gitea.
  • Add option to not mirror forks from other users, only my own forks.

It looks like the code is accidentally grabbing the source or parent owner from the GitHub API, instead of just using the direct owner.login of the current repo.

Also: shouldn't "Duplicate name handling" prevent this?

Originally created by @m8tec on GitHub (Mar 6, 2026). Original GitHub issue: https://github.com/RayLabsHQ/gitea-mirror/issues/214 Originally assigned to: @arunavo4 on GitHub. It seems the tool tries to be a bit too smart when handling forks. If it mirrors a fork, it looks at the original creator (the parent) and saves the fork under the parent's namespace in Gitea, instead of the person who actually owns the fork. Here is what happened to me: - I am m8tec and I have my original repository m8tec/nice-repo. - Another user named nice-user forked it, creating nice-user/nice-repo. - My GitHub token has access to his fork. So your tool naturally picks it up to mirror it. - The Disaster: Instead of creating nice-user/nice-repo in my Gitea, the tool sees that I (m8tec) am the original author of that code. So it takes nice-user's forked code and pushes it straight into m8tec/nice-repo in my Gitea, overwriting the original repo. Possible fixes: - When "Preserve Structure" is on, a fork should just be saved under the namespace of the person who forked it. nice-user/nice-repo needs to go to nice-user/nice-repoin Gitea. - Add option to not mirror forks from other users, only my own forks. It looks like the code is accidentally grabbing the source or parent owner from the GitHub API, instead of just using the direct owner.login of the current repo. Also: shouldn't "Duplicate name handling" prevent this?
GiteaMirror added the enhancementbug labels 2026-04-11 09:10:37 -05:00
Author
Owner

@arunavo4 commented on GitHub (Mar 6, 2026):

@m8tec I think the issue happened casue you had access to both the forks. Did not think about this before. Let me look into it. Thanks for reporting.

<!-- gh-comment-id:4009268627 --> @arunavo4 commented on GitHub (Mar 6, 2026): @m8tec I think the issue happened casue you had access to both the forks. Did not think about this before. Let me look into it. Thanks for reporting.
Author
Owner

@arunavo4 commented on GitHub (Mar 6, 2026):

@m8tec in #215 now preserve mode forks from other users now stay in that user’s namespace (instead of falling into your default owner and risking overwrite).

and reagrding duplicate handling, that setting is for name collisions, not owner-namespace routing.

v3.12.4: https://github.com/RayLabsHQ/gitea-mirror/releases/tag/v3.12.4

<!-- gh-comment-id:4009540774 --> @arunavo4 commented on GitHub (Mar 6, 2026): @m8tec in #215 now `preserve` mode forks from other users now stay in that user’s namespace (instead of falling into your default owner and risking overwrite). and reagrding duplicate handling, that setting is for name collisions, not owner-namespace routing. v3.12.4: https://github.com/RayLabsHQ/gitea-mirror/releases/tag/v3.12.4
Author
Owner

@m8tec commented on GitHub (Mar 6, 2026):

Awesome, it works! Thanks for the incredibly fast fix. Really appreciate the support and the great tool!

<!-- gh-comment-id:4009641049 --> @m8tec commented on GitHub (Mar 6, 2026): Awesome, it works! Thanks for the incredibly fast fix. Really appreciate the support and the great tool!
Author
Owner

@arunavo4 commented on GitHub (Mar 6, 2026):

Perfect! Thank you for helping test and find the issue.

<!-- gh-comment-id:4009745933 --> @arunavo4 commented on GitHub (Mar 6, 2026): Perfect! Thank you for helping test and find the issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea-mirror#226