mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-09-15 18:56:59 +00:00
feat: sync forks (#2364)
This allows syncing a branch of a fork with a branch of the base repo. It looks like this:  This is only possible, if the fork don't have commits that are not in the main repo. The feature is already working, but it is missing Finetuning, a better API, translations and tests, so this is currently WIP. It is also not tested with go-git. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - Features - [PR](https://codeberg.org/forgejo/forgejo/pulls/2364): <!--number 2364 --><!--line 0 --><!--description c3luYyBmb3Jrcw==-->sync forks<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2364 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: JakobDev <jakobdev@gmx.de> Co-committed-by: JakobDev <jakobdev@gmx.de>
This commit is contained in:
parent
3272e3588a
commit
8296a23d79
15 changed files with 723 additions and 4 deletions
|
@ -782,3 +782,27 @@ func PrepareBranchList(ctx *context.Context) {
|
|||
}
|
||||
ctx.Data["Branches"] = brs
|
||||
}
|
||||
|
||||
func SyncFork(ctx *context.Context) {
|
||||
redirectURL := fmt.Sprintf("%s/src/branch/%s", ctx.Repo.RepoLink, util.PathEscapeSegments(ctx.Repo.BranchName))
|
||||
branch := ctx.Params("branch")
|
||||
|
||||
syncForkInfo, err := repo_service.GetSyncForkInfo(ctx, ctx.Repo.Repository, branch)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetSyncForkInfo", err)
|
||||
return
|
||||
}
|
||||
|
||||
if !syncForkInfo.Allowed {
|
||||
ctx.Redirect(redirectURL)
|
||||
return
|
||||
}
|
||||
|
||||
err = repo_service.SyncFork(ctx, ctx.Doer, ctx.Repo.Repository, branch)
|
||||
if err != nil {
|
||||
ctx.ServerError("SyncFork", err)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.Redirect(redirectURL)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue