mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
gitweb: Use privileged decorator for actions
Tests: - Functions tests work - Initial setup works - Global default branch is set to 'main' - Creating an repository works - Cloning a repository works - Progress is shown on the app page - List of repositories is shown properly in the app page - Deleting a repo works - Editing a repository works - Repository information is shown properly in the form - Renaming a repository - Setting description - Setting owner - Setting a repository private/public - Setting default branch (list of branches is shown properly) - Error is thrown properly when a remote repository does not exist - Errors are handled properly when creating/editing/deleting repo Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
a62b7c7522
commit
b91f1cf922
8 files changed
+271
-449
No files matched your search
@@ -3,7 +3,6 @@
|
||||
Django form for configuring Gitweb.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
from urllib.parse import urlparse
|
||||
|
||||
@@ -12,14 +11,14 @@ from django.core.exceptions import ValidationError
|
||||
from django.core.validators import URLValidator
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from plinth import actions
|
||||
from plinth.modules import gitweb
|
||||
|
||||
from . import privileged
|
||||
|
||||
|
||||
def _get_branches(repo):
|
||||
"""Get all the branches in the repository."""
|
||||
branch_data = json.loads(
|
||||
actions.run('gitweb', ['get-branches', '--name', repo]))
|
||||
branch_data = privileged.get_branches(repo)
|
||||
default_branch = branch_data['default_branch']
|
||||
branches = branch_data['branches']
|
||||
|
||||
@@ -113,7 +112,7 @@ class CreateRepoForm(forms.Form):
|
||||
_('A repository with this name already exists.'))
|
||||
|
||||
if is_repo_url(name):
|
||||
if not gitweb.repo_exists(name):
|
||||
if not privileged.repo_exists(name):
|
||||
raise ValidationError('Remote repository is not available.')
|
||||
|
||||
return name
|
||||
|
||||
Reference in new issue
Block a user