Unable to delete repositories / groups?

We created a test group with a single repository inside, created a fork of this repository in a different group, with a number of files, pull requests and comments. Outcome:

/group1/repo-original

/group2/repo-fork

We attempted to delete the original repository (repository settings > advance > delete repository), with detach fork option enabled, at this point, we received an error message:
“Cannot delete repo-original it still contains 1 attached pull requests. Consider archiving the repository instead.”

Please note that the pull request was closed before attempting to delete.

After doing what the message says, we archived the repository. However, when attempting to delete the group1 we receive this message:
“This repository group contains 1 repositories and cannot be deleted.”

How do you actually delete a repository?

Hi,

This is expected behaviour. We want to limit the ability to loose any data, and history from anything stored in RhodeCode. This is why we prevent in certain cases deletion of objects. Like in your case deleting the repository would lead to deleting the pull request connected to it.

If you really want to do this delete and remove any connected objects etc, you’d need to use the low-level ishell interface.

For example:

rccontrol ishell community-1

In [1]: from rhodecode.model.repo import RepoModel
In [2]: repo = Repository.get_by_repo_name('test_repos_4/test_repo_951_hg5f18d')
In [3]: RepoModel().delete(repo, forks='detach', pull_requests='delete')
In [4]: Session().commit()
1 Like

Oh I see, that makes sense. We were playing around with it before starting to use it properly. Did not want to drop the database and reinstall.

That worked nicely. Thank you!