Skip to content
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

Extend fork API to support custom repo name and owner #6442

Closed
yosiov opened this issue Mar 27, 2019 · 5 comments · Fixed by #18066
Closed

Extend fork API to support custom repo name and owner #6442

yosiov opened this issue Mar 27, 2019 · 5 comments · Fixed by #18066
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.

Comments

@yosiov
Copy link

yosiov commented Mar 27, 2019

  • Gitea Version: 1.6.4
  • Git Version: 2.15.3
  • Operating System: Alpine Linux 3.7.1

The current fork API (implemented in routers/api/v1/repo/fork.go) support forking a repo with two restrictions:

  1. The forked repo name remains the same as the source repo name
  2. The forked repo is owned by the API caller

My suggestion is to support a custom repo name for the forked repo, and to allow an admin user to create forks for other users.

Do you think such an extension is reasonable? Should I send a PR for this?

@lunny lunny added the type/proposal The new feature has not been accepted yet but needs to be discussed first. label Mar 27, 2019
@strahe
Copy link

strahe commented May 30, 2019

Good idea, really need it.

@6543 6543 added the modifies/api This PR adds API routes or modifies them label Sep 17, 2020
@6543
Copy link
Member

6543 commented Sep 21, 2020

... "allow an admin user to create forks for other users." -> you can use sudo header

@milichev
Copy link

@yosiov , there is a workaround:

PATCH /repos/owner/old-name

{
  "name": "new-name"
}

Interesting is that successive same requests result with

302 Found
Location: /api/v1/repos/owner/new-name

@pi3ch
Copy link

pi3ch commented Sep 2, 2021

@yosiov , there is a workaround:

PATCH /repos/owner/old-name

{
  "name": "new-name"
}

Interesting is that successive same requests result with

302 Found
Location: /api/v1/repos/owner/new-name

Doesn't look like a workaround to me. It does not fork for a user and set a new name at the same time.

@realaravinth
Copy link
Contributor

Hello, I'm new to the Gitea codebase but I'm willing to submit a patch for this issue.

From what I understand, the necessary plumbing is already available in the web form implementation at routers/web/pull.go.

For the API endpoint, we could respond with 409: Conflict, like the one you get when you try to create a repository with a duplicate name:

{
  "message": "The repository with the same name already exists.",
  "url": "https://git.batsense.net/api/swagger"
}

So that the user can retry their request with an optional name parameter:

curl -X 'POST' \
  'https://git.example.com/api/v1/repos/owner/myrepo/forks' \
  -H 'accept: application/json' \
  -H 'authorization: Basic xxx' \
  -H 'Content-Type: application/json' \
  -d '{
"name": "forkOf-myrepo"
}'

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
modifies/api This PR adds API routes or modifies them type/proposal The new feature has not been accepted yet but needs to be discussed first.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants