Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from __future__ import print_function, unicode_literals
from rbtools.commands import Command, CommandError, Option
from rbtools.utils.commands import get_review_request
SUBMITTED = 'submitted'
DISCARDED = 'discarded'
class Close(Command):
"""Close a specific review request as discarded or submitted.
By default, the command will change the status to submitted. The
user can provide an optional description for this action.
"""
name = 'close'
author = 'The Review Board Project'
args = ''
option_list = [
Option('--close-type',
dest='close_type',
default=SUBMITTED,
help='Either `submitted` or `discarded`.'),
Option('--description',
dest='description',
default=None,
import logging
import os
import re
import sys
from rbtools.api.errors import APIError
from rbtools.commands import Command, CommandError, Option, OptionGroup
from rbtools.utils.commands import get_review_request
from rbtools.utils.console import confirm
from rbtools.utils.review_request import (get_commit_message,
get_draft_or_current_value,
get_revisions,
guess_existing_review_request_id)
class Post(Command):
"""Create and update review requests."""
name = 'post'
author = 'The Review Board Project'
description = 'Uploads diffs to create and update review requests.'
args = '[revisions]'
GUESS_AUTO = 'auto'
GUESS_YES = 'yes'
GUESS_NO = 'no'
GUESS_YES_INPUT_VALUES = (True, 'yes', 1, '1')
GUESS_NO_INPUT_VALUES = (False, 'no', 0, '0')
GUESS_CHOICES = (GUESS_AUTO, GUESS_YES, GUESS_NO)
option_list = [
OptionGroup(
name='Posting Options',
from __future__ import print_function
from rbtools.api.errors import APIError
from rbtools.commands import Command, CommandError
from rbtools.utils.commands import get_review_request
class Publish(Command):
"""Publish a specific review request from a draft."""
name = "publish"
author = "The Review Board Project"
args = ""
option_list = [
Command.server_options,
Command.repository_options,
]
def main(self, request_id):
"""Run the command."""
repository_info, tool = self.initialize_scm_tool(
client_name=self.options.repository_type)
server_url = self.get_server_url(repository_info, tool)
api_client, api_root = self.get_api(server_url)
from __future__ import print_function
import os
from rbtools.api.errors import APIError
from rbtools.commands import Command, CommandError, Option
from rbtools.utils.commands import get_review_request
class Attach(Command):
"""Attach a file to a review request."""
name = "attach"
author = "The Review Board Project"
args = " "
option_list = [
Option("--filename",
dest="filename",
default=None,
help="custom filename for file attachment"),
Option("--caption",
dest="caption",
default=None,
help="caption for file attachment"),
Command.server_options,
Command.repository_options,
]
from __future__ import unicode_literals
from rbtools.clients import print_clients
from rbtools.commands import Command
class ListRepoTypes(Command):
"""List available repository types."""
name = 'list-repo-types'
author = 'The Review Board Project'
description = 'Print a list of supported repository types.'
def main(self, *args):
print_clients(self.config, self.options)
from rbtools.commands import Command, CommandError
import six
class Diff(Command):
"""Prints a diff to the terminal."""
name = 'diff'
author = 'The Review Board Project'
args = '[revisions]'
option_list = [
Command.server_options,
Command.diff_options,
Command.branch_options,
Command.repository_options,
Command.git_options,
Command.perforce_options,
Command.subversion_options,
Command.tfs_options,
]
def main(self, *args):
"""Print the diff to terminal."""
# The 'args' tuple must be made into a list for some of the
# SCM Clients code. See comment in post.
args = list(args)
if self.options.revision_range:
raise CommandError(
'The --revision-range argument has been removed. To create a '
'diff for one or more specific revisions, pass those '
class Attach(Command):
"""Attach a file to a review request."""
name = 'attach'
author = 'The Review Board Project'
args = ' '
option_list = [
Option('--filename',
dest='filename',
default=None,
help='Custom filename for the file attachment.'),
Option('--caption',
dest='caption',
default=None,
help='Caption for the file attachment.'),
Command.server_options,
Command.repository_options,
]
def main(self, request_id, path_to_file):
self.repository_info, self.tool = self.initialize_scm_tool(
client_name=self.options.repository_type)
server_url = self.get_server_url(self.repository_info, self.tool)
api_client, api_root = self.get_api(server_url)
request = get_review_request(request_id, api_root)
try:
with open(path_to_file, 'rb') as f:
content = f.read()
except IOError:
raise CommandError('%s is not a valid file.' % path_to_file)
class Login(Command):
"""Logs into a Review Board server.
The user will be prompted for a username and password, unless otherwise
passed on the command line, allowing the user to log in and save a
session cookie without needing to be in a repository or posting to
the server.
If the user is already logged in, this won't do anything.
"""
name = 'login'
author = 'The Review Board Project'
option_list = [
Command.server_options,
]
def main(self):
"""Run the command."""
server_url = self.get_server_url(None, None)
api_client, api_root = self.get_api(server_url)
session = api_root.get_session(expand='user')
was_authenticated = session.authenticated
if not was_authenticated:
session = get_authenticated_session(api_client, api_root,
auth_required=True,
session=session)
if session.authenticated:
import logging
from rbtools.api.errors import APIError
from rbtools.commands import Command, CommandError, Option
from rbtools.utils.commands import get_review_request
class Publish(Command):
"""Publish a specific review request from a draft."""
name = 'publish'
author = 'The Review Board Project'
args = ''
option_list = [
Command.server_options,
Command.repository_options,
Option('-t', '--trivial',
dest='trivial_publish',
action='store_true',
default=False,
help='Publish the review request without sending an e-mail '
'notification.',
added_in='0.8.0'),
Option('--markdown',
dest='markdown',
action='store_true',
config_key='MARKDOWN',
default=False,
help='Specifies if the change description should should be '
'interpreted as Markdown-formatted text.',
added_in='0.8.0'),
Option('-m', '--change-description',
from __future__ import print_function, unicode_literals
import logging
from rbtools.api.errors import APIError
from rbtools.commands import Command, CommandError, Option
from rbtools.utils.commands import get_review_request
class Publish(Command):
"""Publish a specific review request from a draft."""
name = 'publish'
author = 'The Review Board Project'
args = ''
option_list = [
Command.server_options,
Command.repository_options,
Option('-t', '--trivial',
dest='trivial_publish',
action='store_true',
default=False,
help='Publish the review request without sending an e-mail '
'notification.',
added_in='0.8.0'),
Option('--markdown',
dest='markdown',