gitweb: Add tests for actions script

- add tests for create, edit and delete repository functions
- modify actions script to allow run actions without root privileges:
  - add argument --git-repo-root to overwrite the default root directory
    of repositories
  - add option --keep-ownership to the create-repo command to skip
    changing ownership to www-data
- actions script, repo-info command: instead of returning empty values,
  raise an error if the repository doesn't exist

Closes #1667

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
[sunil@medhas.org Remove unneeded #! directive]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa authored and Sunil Mohan Adapa committed 2019-10-26 21:27:28 -07:00
1 parent 314e30d034
commit c8eb5bb3ca
2 files changed
+102 -1

No files matched your search

+9 -1
View File
@@ -49,6 +49,9 @@ def parse_arguments():
subparser.add_argument(
'--is-private', required=False, default=False, action='store_true',
help='Allow only authorized users to access this repository')
subparser.add_argument(
'--keep-ownership', required=False, default=False, action="store_true",
help='Do not chanege ownership of the repository directory')
subparser = subparsers.add_parser(
'repo-info', help='Get information about the repository')
@@ -187,6 +190,10 @@ def subcommand_set_repo_access(arguments):
def subcommand_repo_info(arguments):
"""Get information about repository."""
repo_path = os.path.join(GIT_REPO_PATH, arguments.name + '.git')
if not os.path.exists(repo_path):
raise RuntimeError('Repository not found')
print(
json.dumps(
dict(name=arguments.name, description=_get_repo_description(
@@ -199,7 +206,8 @@ def subcommand_create_repo(arguments):
os.chdir(GIT_REPO_PATH)
repo_name = arguments.name + '.git'
subprocess.check_call(['git', 'init', '--bare', repo_name])
subprocess.check_call(['chown', '-R', 'www-data:www-data', repo_name])
if not arguments.keep_ownership:
subprocess.check_call(['chown', '-R', 'www-data:www-data', repo_name])
_set_repo_description(arguments.name, arguments.description)
_set_repo_owner(arguments.name, arguments.owner)
if arguments.is_private: