Gitea Version
1.27.2
What happened?
An owner (user or org) can only ever have one fork of a given source repository, regardless of what name they'd give it. This is enforced in GetUserFork (models/repo/fork.go), which queries WHERE fork_id = ? AND owner_id = ? with no name in the check, and is used by ForkRepository (services/repository/fork.go) to reject a second fork attempt with ErrForkAlreadyExist.
Note: ALLOW_FORK_INTO_SAME_OWNER doesn't affect this, but it only controls CanUserForkBetweenOwners (forking from yourself), a separate, earlier check. It doesn't relax GetUserFork at all.
Use case
I want to fork the same upstream repo repeatedly under different names to create independent variants/snapshots for different purposes (e.g. upstream/tool → myorg/tool-variant-a, myorg/tool-variant-b). Today the second attempt is always rejected, even though the destination names don't collide.
Proposed change
Scope the restriction to (fork_id, owner_id, name) instead of just (fork_id, owner_id), i.e. an owner can't fork the same source twice under the same name, but can under different names. This would mean updating GetUserFork's query and reviewing the other call sites that assume "one fork per owner" (HasForkedRepo in routers/web/repo/fork.go, routers/web/repo/branch.go, services/context/repo.go) for the same relaxation.
How are you running Gitea?
No response
Gitea Version
1.27.2
What happened?
An owner (user or org) can only ever have one fork of a given source repository, regardless of what name they'd give it. This is enforced in
GetUserFork(models/repo/fork.go), which queriesWHERE fork_id = ? AND owner_id = ?with nonamein the check, and is used byForkRepository(services/repository/fork.go) to reject a second fork attempt withErrForkAlreadyExist.Note:
ALLOW_FORK_INTO_SAME_OWNERdoesn't affect this, but it only controlsCanUserForkBetweenOwners(forking from yourself), a separate, earlier check. It doesn't relaxGetUserForkat all.Use case
I want to fork the same upstream repo repeatedly under different names to create independent variants/snapshots for different purposes (e.g.
upstream/tool→myorg/tool-variant-a,myorg/tool-variant-b). Today the second attempt is always rejected, even though the destination names don't collide.Proposed change
Scope the restriction to
(fork_id, owner_id, name)instead of just(fork_id, owner_id), i.e. an owner can't fork the same source twice under the same name, but can under different names. This would mean updatingGetUserFork's query and reviewing the other call sites that assume "one fork per owner" (HasForkedRepoinrouters/web/repo/fork.go,routers/web/repo/branch.go,services/context/repo.go) for the same relaxation.How are you running Gitea?
No response