| |
@@ -21,6 +21,7 @@
|
| |
import click
|
| |
import pprint
|
| |
|
| |
+ from cranc import utils
|
| |
from libpagure import libpagure
|
| |
from libpagure import exceptions
|
| |
|
| |
@@ -33,6 +34,7 @@
|
| |
def cranc():
|
| |
pass
|
| |
|
| |
+
|
| |
# Creating subgroup 'get'
|
| |
@click.group()
|
| |
def get():
|
| |
@@ -57,6 +59,7 @@
|
| |
_log.exception("Failed to connect to the server")
|
| |
pprint.pprint(prs)
|
| |
|
| |
+
|
| |
# Adding pr_list into the group 'get'
|
| |
get.add_command(pr_list)
|
| |
|
| |
@@ -70,20 +73,33 @@
|
| |
@click.option("--priority")
|
| |
@click.option("--no_stones")
|
| |
@click.option("--since")
|
| |
- #@click.option("--order")
|
| |
- def issue_list(status, tags, assignee, author, milestones, priority, no_stones,
|
| |
- since):
|
| |
+ # @click.option("--order")
|
| |
+ def issue_list(status, tags, assignee, author, milestones, priority, no_stones, since):
|
| |
"""Prints list of issues"""
|
| |
PAGURE = libpagure.Pagure(pagure_token=api_token)
|
| |
try:
|
| |
- issues = PAGURE.list_issues(status=status, tags=tags, assignee=assignee,
|
| |
- author=author, milestones=milestones, priority=priority,
|
| |
- no_stones=no_stones, since=since)
|
| |
+ issues = PAGURE.list_issues(
|
| |
+ status=status,
|
| |
+ tags=tags,
|
| |
+ assignee=assignee,
|
| |
+ author=author,
|
| |
+ milestones=milestones,
|
| |
+ priority=priority,
|
| |
+ no_stones=no_stones,
|
| |
+ since=since,
|
| |
+ )
|
| |
except exceptions.APIError:
|
| |
pagure_noauth = libpagure.Pagure(pagure_repository=project)
|
| |
- issues = pagure_noauth.list_issues(status=status, tags=tags, assignee=assignee,
|
| |
- author=author, milestones=milestones, priority=priority,
|
| |
- no_stones=no_stones, since=since)
|
| |
+ issues = pagure_noauth.list_issues(
|
| |
+ status=status,
|
| |
+ tags=tags,
|
| |
+ assignee=assignee,
|
| |
+ author=author,
|
| |
+ milestones=milestones,
|
| |
+ priority=priority,
|
| |
+ no_stones=no_stones,
|
| |
+ since=since,
|
| |
+ )
|
| |
pprint.pprint(issues)
|
| |
|
| |
|
| |
@@ -99,10 +115,11 @@
|
| |
|
| |
@click.command(name="pr")
|
| |
@click.option("--request_id")
|
| |
- @click.option("--repo")
|
| |
def merge_pr(request_id):
|
| |
"""This command merges a pull request"""
|
| |
- PAGURE = libpagure.Pagure(pagure_token=api_token, pagure_repository=repo)
|
| |
+ PAGURE = libpagure.Pagure(
|
| |
+ pagure_token=api_token, pagure_repository=project, instance_url=instance_url
|
| |
+ )
|
| |
try:
|
| |
request = PAGURE.merge_request(request_id=request_id)
|
| |
pprint.pprint(request)
|
| |
@@ -110,6 +127,7 @@
|
| |
except Exception:
|
| |
_log.exception("Failed to connect to the server")
|
| |
|
| |
+
|
| |
# Adding merge_pr into the group 'merge'
|
| |
merge.add_command(merge_pr)
|
| |
|
| |
@@ -120,22 +138,32 @@
|
| |
|
| |
|
| |
@click.command(name="pr")
|
| |
- @click.option("--repo")
|
| |
+ @click.option("--repo_to")
|
| |
@click.option("--title")
|
| |
@click.option("--branch_to")
|
| |
@click.option("--branch_from")
|
| |
- def create_pr(repo, title, branch_to, branch_from):
|
| |
+ @click.option("--repo_from")
|
| |
+ def create_pr(repo_to, title, branch_to, branch_from, repo_from):
|
| |
"""this command creates a new pull request"""
|
| |
- PAGURE = libpagure.Pagure(pagure_token=api_token, pagure_repository=repo,
|
| |
- fork_username='lenkaseg')
|
| |
+ repo_to = utils.get_dict_from_str(repo_to)
|
| |
+ PAGURE = libpagure.Pagure(
|
| |
+ pagure_token=api_token,
|
| |
+ repo_to=repo_to["repo"],
|
| |
+ fork_username=repo_to["username"],
|
| |
+ namespace=repo_to["namespace"],
|
| |
+ repo_from=utils.get_dict_from_str(repo_from),
|
| |
+ instance_url=instance_url,
|
| |
+ )
|
| |
PAGURE.log_debug(True)
|
| |
try:
|
| |
- request = PAGURE.create_pull_request(title=title, branch_to=branch_to,
|
| |
- branch_from=branch_from)
|
| |
+ request = PAGURE.create_pull_request(
|
| |
+ title=title, branch_to=branch_to, branch_from=branch_from
|
| |
+ )
|
| |
pprint.pprint(request)
|
| |
except Exception:
|
| |
_log.exception("Failed to connect to the server")
|
| |
|
| |
+
|
| |
# Adding create_pr into the group 'create'
|
| |
create.add_command(create_pr)
|
| |
|
| |
Add soft link to libpagure to requirements, to be able to edit libpagure
and have the changes available.