mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
2978 files. The fork is 2026-07-15 (rebrand: gitea.dev -> github.com/hanzoai/git), so 2026 is the year, and "Copyright 2026 Hanzo AI, Inc." was already the form used by the handful of files that had ours. Shape is now: // Copyright 2026 Hanzo AI, Inc. All rights reserved. // Copyright 2015 The Gogs Authors. All rights reserved. // Copyright 2019 The Gitea Authors. All rights reserved. // SPDX-License-Identifier: MIT Ours on top, theirs retained verbatim. Retained because MIT requires it, and separately because they are true — those authors did write that code. Not renamed to "The Git Authors": Git is a different project under a different license, and putting its name here would attribute this code to people who have nothing to do with it. Adding our line is the fix; overwriting theirs would have been both a licence violation and a false statement. gofmt still reports import-order drift in some of these files. It predates this change (verified against a stash) and is left alone rather than burying a one-line-per-file legal change under 3000 files of unrelated reordering. Build clean. Co-authored-by: Hanzo Dev <[email protected]>
62 lines
2.0 KiB
Go
62 lines
2.0 KiB
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package setting
|
|
|
|
import (
|
|
repo_model "github.com/hanzoai/git/models/repo"
|
|
"github.com/hanzoai/git/modules/gitrepo"
|
|
"github.com/hanzoai/git/modules/setting"
|
|
"github.com/hanzoai/git/services/context"
|
|
repo_service "github.com/hanzoai/git/services/repository"
|
|
)
|
|
|
|
// AdoptOrDeleteRepository adopts or deletes a repository
|
|
func AdoptOrDeleteRepository(ctx *context.Context) {
|
|
ctx.Data["Title"] = ctx.Tr("settings.adopt")
|
|
ctx.Data["PageIsSettingsRepos"] = true
|
|
allowAdopt := ctx.IsUserSiteAdmin() || setting.Repository.AllowAdoptionOfUnadoptedRepositories
|
|
ctx.Data["allowAdopt"] = allowAdopt
|
|
allowDelete := ctx.IsUserSiteAdmin() || setting.Repository.AllowDeleteOfUnadoptedRepositories
|
|
ctx.Data["allowDelete"] = allowDelete
|
|
|
|
dir := ctx.FormString("id")
|
|
action := ctx.FormString("action")
|
|
|
|
ctxUser := ctx.Doer
|
|
|
|
// check not a repo
|
|
has, err := repo_model.IsRepositoryModelExist(ctx, ctxUser, dir)
|
|
if err != nil {
|
|
ctx.ServerError("IsRepositoryExist", err)
|
|
return
|
|
}
|
|
|
|
exist, err := gitrepo.IsRepositoryExist(ctx, repo_model.StorageRepo(repo_model.RelativePath(ctxUser.Name, dir)))
|
|
if err != nil {
|
|
ctx.ServerError("IsDir", err)
|
|
return
|
|
}
|
|
if has || !exist {
|
|
// Fallthrough to failure mode
|
|
} else if action == "adopt" && allowAdopt {
|
|
if _, err := repo_service.AdoptRepository(ctx, ctxUser, ctxUser, repo_service.CreateRepoOptions{
|
|
Name: dir,
|
|
IsPrivate: true,
|
|
}); err != nil {
|
|
ctx.ServerError("repository.AdoptRepository", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.adopt_preexisting_success", dir))
|
|
} else if action == "delete" && allowDelete {
|
|
if err := repo_service.DeleteUnadoptedRepository(ctx, ctxUser, ctxUser, dir); err != nil {
|
|
ctx.ServerError("repository.AdoptRepository", err)
|
|
return
|
|
}
|
|
ctx.Flash.Success(ctx.Tr("repo.delete_preexisting_success", dir))
|
|
}
|
|
|
|
ctx.Redirect(setting.AppSubURL + "/user/settings/repos")
|
|
}
|