| |
@@ -25,15 +25,11 @@
|
| |
from six import string_types
|
| |
from six.moves import xmlrpc_client
|
| |
|
| |
- from fedscm_admin.config import get_config_item
|
| |
- from fedscm_admin import (
|
| |
- CONFIG, MONITOR_CHOICES, BUGZILLA_CLIENT, FAS_CLIENT, STANDARD_BRANCH_SLAS,
|
| |
- INVALID_EPEL_ERROR, is_epel)
|
| |
- import fedscm_admin.pdc
|
| |
- import fedscm_admin.pagure
|
| |
- import fedscm_admin.git
|
| |
- from fedscm_admin.request_utils import requests_wrapper, get_request_json
|
| |
- from fedscm_admin.exceptions import ValidationError
|
| |
+ from . import CONFIG, BUGZILLA_CLIENT, FAS_CLIENT, INVALID_EPEL_ERROR
|
| |
+ from . import MONITOR_CHOICES, STANDARD_BRANCH_SLAS, git, is_epel, pagure, pdc
|
| |
+ from .config import get_config_item
|
| |
+ from .exceptions import ValidationError
|
| |
+ from .request_utils import get_request_json, requests_wrapper
|
| |
|
| |
|
| |
def login_to_bugzilla_with_user_input():
|
| |
@@ -108,7 +104,7 @@
|
| |
raise ValidationError(
|
| |
'The EOL date "{0}" is in an invalid format'.format(eol))
|
| |
|
| |
- sla_obj = fedscm_admin.pdc.get_sla(sla)
|
| |
+ sla_obj = pdc.get_sla(sla)
|
| |
if not sla_obj:
|
| |
raise ValidationError('The SL "{0}" is not in PDC'.format(sla))
|
| |
|
| |
@@ -179,7 +175,7 @@
|
| |
:return: None
|
| |
"""
|
| |
# Sort the issues so that the oldest get shown first
|
| |
- issues = fedscm_admin.pagure.get_issues()
|
| |
+ issues = pagure.get_issues()
|
| |
for issue in issues:
|
| |
issue_id = issue['id']
|
| |
issue_title = issue['title'].strip()
|
| |
@@ -197,7 +193,7 @@
|
| |
:return: None
|
| |
"""
|
| |
# Sort the issues so that the oldest get processed first
|
| |
- issues = fedscm_admin.pagure.get_issues()
|
| |
+ issues = pagure.get_issues()
|
| |
for issue in issues:
|
| |
process_ticket(issue, auto_approve=auto_approve)
|
| |
|
| |
@@ -353,17 +349,17 @@
|
| |
click.echo('- Checking if user {0} has an account in dist-git.'.format(
|
| |
issue_owner))
|
| |
pagure_url = get_config_item(CONFIG, 'pagure_dist_git_url')
|
| |
- if not fedscm_admin.pagure.user_exists(issue_owner):
|
| |
+ if not pagure.user_exists(issue_owner):
|
| |
sync_comment = ('@{0} needs to login to {1} to sync accounts '
|
| |
'before we can proceed.'.format(issue_owner, pagure_url))
|
| |
question = '{0} Post this comment to the ticket?'.format(sync_comment)
|
| |
if click.confirm(question):
|
| |
- fedscm_admin.pagure.add_comment_to_issue(issue_id, sync_comment)
|
| |
+ pagure.add_comment_to_issue(issue_id, sync_comment)
|
| |
return
|
| |
|
| |
click.echo('- Checking if {0}/{1} already exists in dist-git.'.format(
|
| |
namespace, repo))
|
| |
- project = fedscm_admin.pagure.get_project(namespace, repo)
|
| |
+ project = pagure.get_project(namespace, repo)
|
| |
if project:
|
| |
prompt_to_close_bad_ticket(
|
| |
issue_json, 'The Pagure project already exists')
|
| |
@@ -371,15 +367,15 @@
|
| |
|
| |
description = issue_body_json.get('description', '').strip()
|
| |
upstreamurl = issue_body_json.get('upstreamurl', '').strip()
|
| |
- component_type = fedscm_admin.pdc.component_type_to_singular(namespace)
|
| |
+ component_type = pdc.component_type_to_singular(namespace)
|
| |
master_branch = None
|
| |
if branch_name != 'master':
|
| |
click.echo('- Checking if master already exists in PDC.')
|
| |
- master_branch = fedscm_admin.pdc.get_branch(
|
| |
+ master_branch = pdc.get_branch(
|
| |
repo, 'master', component_type)
|
| |
|
| |
click.echo('- Checking if {0} already exists in PDC.'.format(branch_name))
|
| |
- branch = fedscm_admin.pdc.get_branch(repo, branch_name, component_type)
|
| |
+ branch = pdc.get_branch(repo, branch_name, component_type)
|
| |
|
| |
if master_branch or branch:
|
| |
prompt_to_close_bad_ticket(
|
| |
@@ -387,7 +383,7 @@
|
| |
return
|
| |
|
| |
issue_title = issue_json['title'].strip()
|
| |
- issue_ui_url = fedscm_admin.pagure.get_pagure_issue_url(issue_id)
|
| |
+ issue_ui_url = pagure.get_pagure_issue_url(issue_id)
|
| |
bz_bug_url = ''
|
| |
if bug_id:
|
| |
bz_bug_url = BUGZILLA_CLIENT.get_bug_url(bug_id)
|
| |
@@ -428,27 +424,27 @@
|
| |
# If the global component already exists, this will not create another
|
| |
# Skip for tests namespace
|
| |
if namespace != 'tests':
|
| |
- fedscm_admin.pdc.new_global_component(repo, dist_git_url)
|
| |
+ pdc.new_global_component(repo, dist_git_url)
|
| |
# Pagure uses plural names for namespaces, but PDC does not use the
|
| |
# plural version for branch types
|
| |
- branch_type = fedscm_admin.pdc.component_type_to_singular(namespace)
|
| |
+ branch_type = pdc.component_type_to_singular(namespace)
|
| |
# If the branch requested isn't master, still create a master branch
|
| |
# in PDC anyways.
|
| |
# Skip pdc magic for tests namespace
|
| |
if namespace != 'tests':
|
| |
if branch_name != 'master':
|
| |
- fedscm_admin.pdc.new_branch(repo, 'master', branch_type)
|
| |
- for sla, eol in fedscm_admin.STANDARD_BRANCH_SLAS['master'].items():
|
| |
- fedscm_admin.pdc.new_sla_to_branch(
|
| |
+ pdc.new_branch(repo, 'master', branch_type)
|
| |
+ for sla, eol in STANDARD_BRANCH_SLAS['master'].items():
|
| |
+ pdc.new_sla_to_branch(
|
| |
sla, eol, repo, 'master', branch_type)
|
| |
|
| |
- fedscm_admin.pdc.new_branch(repo, branch_name, branch_type)
|
| |
+ pdc.new_branch(repo, branch_name, branch_type)
|
| |
for sla, eol in issue_body_json['sls'].items():
|
| |
- fedscm_admin.pdc.new_sla_to_branch(
|
| |
+ pdc.new_sla_to_branch(
|
| |
sla, eol, repo, branch_name, branch_type)
|
| |
|
| |
# Create the Pagure repo
|
| |
- fedscm_admin.pagure.new_project(
|
| |
+ pagure.new_project(
|
| |
namespace, repo, description, upstreamurl,
|
| |
initial_commit=initial_commit)
|
| |
# If the branch requested isn't master, create that branch in git. The
|
| |
@@ -456,9 +452,9 @@
|
| |
if branch_name != 'master':
|
| |
new_git_branch(namespace, repo, branch_name, use_master=True)
|
| |
|
| |
- fedscm_admin.pagure.set_monitoring_status(
|
| |
+ pagure.set_monitoring_status(
|
| |
namespace, repo, issue_body_json['monitor'].strip())
|
| |
- fedscm_admin.pagure.change_project_main_admin(
|
| |
+ pagure.change_project_main_admin(
|
| |
namespace, repo, issue_owner)
|
| |
|
| |
if branch_name == 'master':
|
| |
@@ -473,7 +469,7 @@
|
| |
elif action == 'deny':
|
| |
comment_body = click.prompt(
|
| |
'Please enter a comment explaining the denial')
|
| |
- fedscm_admin.pagure.close_issue(issue_id, comment_body, 'Denied')
|
| |
+ pagure.close_issue(issue_id, comment_body, 'Denied')
|
| |
if bug_id:
|
| |
BUGZILLA_CLIENT.comment(bug_id, comment_body)
|
| |
else:
|
| |
@@ -514,7 +510,7 @@
|
| |
bug_id = str(issue_body_json.get('bug_id', '')).strip()
|
| |
create_git_branch = issue_body_json.get('create_git_branch', True)
|
| |
|
| |
- project = fedscm_admin.pagure.get_project(namespace, repo)
|
| |
+ project = pagure.get_project(namespace, repo)
|
| |
if not project:
|
| |
prompt_to_close_bad_ticket(
|
| |
issue_json, 'The Pagure repo does not exist')
|
| |
@@ -530,9 +526,9 @@
|
| |
return
|
| |
# Pagure uses plural names for namespaces, but PDC does not use the
|
| |
# plural version for branch types
|
| |
- branch_type = fedscm_admin.pdc.component_type_to_singular(namespace)
|
| |
+ branch_type = pdc.component_type_to_singular(namespace)
|
| |
click.echo('- Checking if {0} already exists in PDC.'.format(branch_name))
|
| |
- pdc_branch = fedscm_admin.pdc.get_branch(repo, branch_name, branch_type)
|
| |
+ pdc_branch = pdc.get_branch(repo, branch_name, branch_type)
|
| |
if pdc_branch:
|
| |
ticket_text = \
|
| |
"The branch in PDC already exists, you can now create it yourself as follows:\n" \
|
| |
@@ -549,7 +545,7 @@
|
| |
issue_id = issue_json['id']
|
| |
issue_title = issue_json['title'].strip()
|
| |
issue_owner = issue_json['user']['name']
|
| |
- issue_ui_url = fedscm_admin.pagure.get_pagure_issue_url(issue_id)
|
| |
+ issue_ui_url = pagure.get_pagure_issue_url(issue_id)
|
| |
|
| |
# Check if the branch requestor is one of the maintainers or part of the groups
|
| |
click.echo('- Checking if {0} is one of the maintainers of the package'.format(issue_owner))
|
| |
@@ -605,14 +601,14 @@
|
| |
pagure_url.rstrip('/'), namespace, repo)
|
| |
# If the global component already exists, this will not try to create
|
| |
# it
|
| |
- fedscm_admin.pdc.new_global_component(repo, dist_git_url)
|
| |
+ pdc.new_global_component(repo, dist_git_url)
|
| |
# Pagure uses plural names for namespaces, but PDC does not use the
|
| |
# plural version for branch types
|
| |
- branch_type = fedscm_admin.pdc.component_type_to_singular(namespace)
|
| |
+ branch_type = pdc.component_type_to_singular(namespace)
|
| |
|
| |
- fedscm_admin.pdc.new_branch(repo, branch_name, branch_type)
|
| |
+ pdc.new_branch(repo, branch_name, branch_type)
|
| |
for sla, eol in issue_body_json['sls'].items():
|
| |
- fedscm_admin.pdc.new_sla_to_branch(
|
| |
+ pdc.new_sla_to_branch(
|
| |
sla, eol, repo, branch_name, branch_type)
|
| |
|
| |
if create_git_branch:
|
| |
@@ -630,7 +626,7 @@
|
| |
elif action == 'deny':
|
| |
comment_body = click.prompt(
|
| |
'Please enter a comment explaining the denial')
|
| |
- fedscm_admin.pagure.close_issue(issue_id, comment_body, 'Denied')
|
| |
+ pagure.close_issue(issue_id, comment_body, 'Denied')
|
| |
if bug_id:
|
| |
BUGZILLA_CLIENT.comment(bug_id, comment_body)
|
| |
else:
|
| |
@@ -655,7 +651,7 @@
|
| |
:return: None
|
| |
"""
|
| |
if comment is not None:
|
| |
- fedscm_admin.pagure.add_comment_to_issue(issue_id, comment)
|
| |
+ pagure.add_comment_to_issue(issue_id, comment)
|
| |
if bug_id:
|
| |
BUGZILLA_CLIENT.comment(bug_id, comment)
|
| |
click.echo('The following comment was added to the issue "{0}"'
|
| |
@@ -665,7 +661,7 @@
|
| |
if click.confirm('Would you like to add another comment?'):
|
| |
custom_comment = click.prompt('Please enter a comment')
|
| |
|
| |
- fedscm_admin.pagure.close_issue(issue_id, custom_comment, close_status)
|
| |
+ pagure.close_issue(issue_id, custom_comment, close_status)
|
| |
if custom_comment and bug_id:
|
| |
BUGZILLA_CLIENT.comment(bug_id, custom_comment)
|
| |
|
| |
@@ -699,7 +695,7 @@
|
| |
if click.confirm('Would you like to replace the default comment of '
|
| |
'"{0}"?'.format(error)):
|
| |
comment_body = click.prompt('Please enter a comment')
|
| |
- fedscm_admin.pagure.close_issue(issue_id, comment_body, 'Invalid')
|
| |
+ pagure.close_issue(issue_id, comment_body, 'Invalid')
|
| |
if bug_id:
|
| |
BUGZILLA_CLIENT.comment(bug_id, comment_body)
|
| |
|
| |
@@ -778,10 +774,10 @@
|
| |
:return: None or ValidationError
|
| |
"""
|
| |
click.echo('- Verifying that the git repo is initialized')
|
| |
- git_url = fedscm_admin.pagure.get_project_git_url(
|
| |
+ git_url = pagure.get_project_git_url(
|
| |
namespace, repo, url_type='git',
|
| |
username=FAS_CLIENT.client.username)
|
| |
- git_obj = fedscm_admin.git.GitRepo(git_url)
|
| |
+ git_obj = git.GitRepo(git_url)
|
| |
if not git_obj.initialized_remotely:
|
| |
raise ValidationError('The git repository is not initialized. The git '
|
| |
'branch can\'t be created.')
|
| |
@@ -800,21 +796,21 @@
|
| |
:return: None or ValidationError
|
| |
"""
|
| |
if use_master is True:
|
| |
- fedscm_admin.pagure.new_branch(
|
| |
+ pagure.new_branch(
|
| |
namespace, repo, branch, from_branch='master')
|
| |
else:
|
| |
# Even though the branches are created using pagure api which dont
|
| |
# require ssh, but the code supports adding package.cfg file.
|
| |
# This should be pushed using ssh.
|
| |
- git_url = fedscm_admin.pagure.get_project_git_url(
|
| |
+ git_url = pagure.get_project_git_url(
|
| |
namespace, repo, url_type='ssh',
|
| |
username=FAS_CLIENT.client.username)
|
| |
- git_obj = fedscm_admin.git.GitRepo(git_url)
|
| |
+ git_obj = git.GitRepo(git_url)
|
| |
git_obj.clone_repo()
|
| |
if not git_obj.initialized:
|
| |
raise ValidationError('The git repository is not initialized. A '
|
| |
'git branch can\'t be created.')
|
| |
- fedscm_admin.pagure.new_branch(
|
| |
+ pagure.new_branch(
|
| |
namespace, repo, branch, from_commit=git_obj.first_commit)
|
| |
|
| |
|
| |
Previously, tests would break all over the place.