feature: work in progress
This commit is contained in:
parent
58fce87f39
commit
203936cbd8
2 changed files with 12 additions and 12 deletions
|
|
@ -1359,6 +1359,8 @@ def delete_repo(request, apiuser, repoid, forks=Optional("")):
|
|||
_perms = ("repository.admin",)
|
||||
validate_repo_permissions(apiuser, repoid, repo, _perms)
|
||||
|
||||
deprecation_warning = "NOTE: 'forks' option will be deprecated."
|
||||
|
||||
try:
|
||||
handle_forks = Optional.extract(forks)
|
||||
_forks_msg = ""
|
||||
|
|
@ -1378,7 +1380,7 @@ def delete_repo(request, apiuser, repoid, forks=Optional("")):
|
|||
|
||||
ScmModel().mark_for_invalidation(repo_name, delete=True)
|
||||
Session().commit()
|
||||
return {"msg": f"Deleted repository `{repo_name}`{_forks_msg}", "success": True}
|
||||
return {"msg": f"Deleted repository `{repo_name}`{_forks_msg}; {deprecation_warning}", "success": True}
|
||||
except Exception:
|
||||
log.exception("Exception occurred while trying to delete repo")
|
||||
raise JSONRPCError(f"failed to delete repository `{repo_name}`")
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
# This program is dual-licensed. If you wish to learn more about the
|
||||
# RhodeCode Enterprise Edition, including its added features, Support services,
|
||||
# and proprietary license terms, please see https://rhodecode.com/licenses/
|
||||
|
||||
import itertools
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
|
|
@ -69,7 +69,6 @@ from rhodecode.model.db import (
|
|||
UserLog,
|
||||
)
|
||||
from rhodecode.model.permission import PermissionModel
|
||||
from rhodecode.model.settings import VcsSettingsModel
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -769,6 +768,10 @@ class RepoModel(BaseModel):
|
|||
if not repo:
|
||||
return False
|
||||
|
||||
if not forks: # left for backward compatibility
|
||||
is_private = repo.private
|
||||
forks = "delete" if is_private else "detach"
|
||||
|
||||
if forks == "detach":
|
||||
for r in repo.forks:
|
||||
r.fork = None
|
||||
|
|
@ -782,15 +785,10 @@ class RepoModel(BaseModel):
|
|||
# check for pull requests
|
||||
pr_sources = repo.pull_requests_source
|
||||
pr_targets = repo.pull_requests_target
|
||||
if pull_requests != "delete" and (pr_sources or pr_targets):
|
||||
raise AttachedPullRequestsError()
|
||||
|
||||
artifacts_objs = repo.artifacts
|
||||
if artifacts == "delete":
|
||||
for a in artifacts_objs:
|
||||
self.sa.delete(a)
|
||||
elif [a for a in artifacts_objs]:
|
||||
raise AttachedArtifactsError()
|
||||
artifacts = repo.artifacts
|
||||
# FIXME: continue here
|
||||
for pr in itertools.chain(pr_sources, pr_targets, artifacts):
|
||||
self.sa.delete(pr)
|
||||
|
||||
old_repo_dict = repo.get_dict()
|
||||
if call_events:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue