rbtools.commands.post¶
Implementation of rbt post.
Module Attributes
|
A squashed diff that may be the product of one or more revisions. |
A series of diffs that each correspond to a single revision. |
Classes
A series of diffs that each correspond to a single revision. |
|
|
Create and update review requests. |
|
A squashed diff that may be the product of one or more revisions. |
- class rbtools.commands.post.SquashedDiff(diff, parent_diff, base_commit_id, base_dir, commit_id, changenum, review_request_extra_data)[source]¶
Bases:
tuple
A squashed diff that may be the product of one or more revisions.
Changed in version 3.1: Added
review_request_extra_data
.- base_commit_id[source]¶
The ID of the commit that the diff and parent diff are relative to. This is required for SCMs like Mercurial that do not use blob IDs for files.
- Type:
- changenum[source]¶
For SCMs such as Perforce, this is the change number that the diff corresponds to. This is
None
for other SCMs.- Type:
- review_request_extra_data[source]¶
State to store in a review request’s
extra_data
field.New in version 3.1.
- Type:
- __match_args__ = ('diff', 'parent_diff', 'base_commit_id', 'base_dir', 'commit_id', 'changenum', 'review_request_extra_data')[source]¶
- rbtools.commands.post.DiffHistory[source]¶
A series of diffs that each correspond to a single revision.
Changed in version 3.1: Added
review_request_extra_data
.- rbtools.commands.post.entries¶
A list of the history entries. Each of these is a dict with the following keys:
commit_id
(unicode
):The unique identifier for the commit. For an SCM like Git, this is a SHA-1 hash.
parent_id
(unicode
):The unique identifier of the parent commit.
diff
(bytes
):The contents of the diff.
commit_message
(unicode
):The message associated with the commit.
author_name
(unicode
):The name of the author.
author_email
(unicode
):The e-mail address of the author.
author_date
(unicode
):The date and time the commit was authored in ISO 8601 format.
committer_name
(unicode
):The name of the committer (if applicable).
committer_email
(unicode
):The e-mail address of the committer (if applicable).
committer_date
(unicode
):The date and time the commit was committed in ISO 8601 format (if applicable).
- rbtools.commands.post.base_commit_id¶
The ID of the commit that the diff and parent diff are relative to. This is required for SCMs like Mercurial that do not use blob IDs for files.
- Type:
- rbtools.commands.post.validation_info¶
Validation metadata from the commit validation resource.
- class rbtools.commands.post.Post(transport_cls: Type[Transport] = <class 'rbtools.api.transport.sync.SyncTransport'>, stdout: TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, stderr: TextIO = <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>, stdin: TextIO = <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>)[source]¶
Bases:
BaseCommand
Create and update review requests.
- description: str = 'Uploads diffs to create and update review requests.'[source]¶
A short description of the command, suitable for display in usage text.
- Type:
- needs_diffs: bool = True[source]¶
Whether the command needs to generate diffs.
If this is set, the initialization of the command will check for the presence of a diff tool compatible with the chosen type of repository.
This depends on
needs_repository
andneeds_scm_client
both being set toTrue
.New in version 4.0.
- Type:
- needs_api: bool = True[source]¶
Whether the command needs the API client.
If this is set, the initialization of the command will set
api_client
andapi_root
.New in version 3.0.
- Type:
- needs_repository: bool = True[source]¶
Whether the command needs the remote repository object.
If this is set, the initialization of the command will set
repository
.Setting this will imply setting both
needs_api
andneeds_scm_client
toTrue
.New in version 3.0.
- Type:
- needs_scm_client: bool = True[source]¶
Whether the command needs the SCM client.
If this is set, the initialization of the command will set
repository_info
andtool
.New in version 3.0.
- Type:
- reserved_fields = ('description', 'testing-done', 'summary')[source]¶
Reserved built-in fields that can be set using the
--field
argument.
- args: str = '[revisions]'[source]¶
Usage text for what arguments the command takes.
Arguments for the command are anything passed in other than defined options (for example, revisions passed to rbt post).
- Type:
- option_list: List[Union[Option, OptionGroup]] = [<rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>, <rbtools.commands.base.options.OptionGroup object>][source]¶
Command-line options for this command.
- Type:
list
ofOption
orOptionGroup
- can_upload_binary_files: bool¶
Whether both the server and tool can upload binary files to diffs.
New in version 5.0.
- diff_file_attachments_resource: Optional[DiffFileAttachmentListResource]¶
The DiffFileAttachments resource for the repository.
New in version 5.0.
- post_process_options()[source]¶
Post-process options for the command.
This can validate and update options before the command is invoked.
- Raises:
rbtools.commands.base.errors.CommandError – There was an error found with an option.
- post_request(review_request: Optional[ReviewRequestResource] = None, diff_history: Optional[DiffHistory] = None, squashed_diff: Optional[SquashedDiff] = None, submit_as: Optional[str] = None) tuple[int, str] [source]¶
Create or update a review request, uploading a diff in the process.
- Parameters:
review_request (
rbtools.api.resources.ReviewRequestResource
, optional) –The review request to update.
If not provided, a new review request will be created.
diff_history (
DiffHistory
, optional) –The diff history to post for multi-commit review requests.
Exactly one of
diff_history
andsquashed_diff
must be specified.squashed_diff (
SquashedDiff
, optional) –The squashed diff information to upload when uploading a traditional-style review request.
Exactly one of
diff_history
andsquashed_diff
must be specified.submit_as (
str
, optional) – The username to submit the review request as.
- Returns:
A 2-tuple of:
The review request ID.
The review request URL.
- Return type:
- Raises:
rbtools.commands.CommandError – An error occurred while posting the review request.
ValueError – The function was called without one of
diff_history
orsquashed_diff
.
- check_guess_fields()[source]¶
Checks and handles field guesses for the review request.
This will attempt to guess the values for the summary and description fields, based on the contents of the commit message at the provided revisions, if requested by the caller.
If the backend doesn’t support guessing, or if guessing isn’t requested, or if explicit values were set in the options, nothing will be set for the fields.