CodeCommit / Client / get_blob_differences
get_blob_differences¶
- CodeCommit.Client.get_blob_differences(**kwargs)¶
Returns a structured, line-level diff between two blob versions in a repository. The diff is returned as an ordered list of hunks, where each hunk represents a contiguous run of changed lines together with any surrounding unchanged context lines.
Results are paginated. Use
MaxResultsandNextTokento retrieve additional pages.For the typical usage workflow, see GetDifferences.
See also: AWS API Documentation
Request Syntax
response = client.get_blob_differences( repositoryName='string', afterBlobId='string', beforeBlobId='string', contextLines=123, ignoreWhitespace=True|False, MaxResults=123, NextToken='string' )
- Parameters:
repositoryName (string) –
[REQUIRED]
The name of the repository that contains the blobs to compare.
afterBlobId (string) –
[REQUIRED]
The ID of the “after” (destination) blob in the diff. Typically the value of
afterBlob.blobIdfrom aDifferenceobject returned by GetDifferences.beforeBlobId (string) –
The ID of the “before” (source) blob in the diff. Typically the value of
beforeBlob.blobIdfrom aDifferenceobject returned by GetDifferences.If you do not specify a value, the operation returns a diff against an empty before-state. This is equivalent to treating the file as newly added.
contextLines (integer) – The number of unchanged lines of context to include before and after each block of changes in a hunk. Valid values are 0 through 20. Defaults to
3.ignoreWhitespace (boolean) – Specifies whether to ignore whitespace-only changes when computing the diff. When
true, the operation treats lines that differ only in whitespace as unchanged. Defaults tofalse.MaxResults (integer) – The maximum number of
DiffHunkentries to return in a single response page. Defaults to100.NextToken (string) – An enumeration token that returns the next batch of results when present in a request.
- Return type:
dict
- Returns:
Response Syntax
{ 'hunks': [ { 'beforeStartLine': 123, 'beforeLineCount': 123, 'afterStartLine': 123, 'afterLineCount': 123, 'changes': [ { 'type': 'CONTEXT'|'ADD'|'DELETE', 'beforeLineNumber': 123, 'afterLineNumber': 123, 'content': 'string' }, ] }, ], 'isBinary': True|False, 'beforeBlobSize': 123, 'afterBlobSize': 123, 'NextToken': 'string' }
Response Structure
(dict) –
hunks (list) –
An ordered list of diff hunks. Each hunk represents a contiguous run of changed and adjacent context lines. The list is empty when the blobs are identical or when the content is binary. The list is also empty when a paginated request has already returned all hunks in earlier pages, in which case
NextTokenis alsonull.(dict) –
A contiguous run of changed lines from a blob diff, together with any surrounding unchanged context lines. Hunks are returned in order from the start of the file to the end. Adjacent or overlapping hunks are merged into a single hunk in the response.
beforeStartLine (integer) –
The 1-based line number in the before blob where this hunk begins. When the hunk consists entirely of additions,
beforeLineCountis0.beforeLineCount (integer) –
The number of lines from the before blob covered by this hunk, including any context lines.
afterStartLine (integer) –
The 1-based line number in the after blob where this hunk begins. When the hunk consists entirely of deletions,
afterLineCountis0.afterLineCount (integer) –
The number of lines from the after blob covered by this hunk, including any context lines.
changes (list) –
An ordered list of line-level changes that make up this hunk. Each entry indicates whether the line is unchanged context, an addition, or a deletion.
(dict) –
A single line-level entry in a diff hunk. Each
DiffChangedescribes one line and its change type: unchanged context, an addition in the after blob, or a deletion from the before blob.type (string) –
The type of change for this line. Possible values:
CONTEXT– Unchanged line included for surrounding context.ADD– Line added in the after blob.DELETE– Line removed from the before blob.
beforeLineNumber (integer) –
The 1-based line number in the before blob. This field is omitted for
ADDlines.afterLineNumber (integer) –
The 1-based line number in the after blob. This field is omitted for
DELETElines.content (string) –
The text content of the line, without the trailing newline.
isBinary (boolean) –
Specifies whether the operation treated the diff content as binary. When
true, the operation does not compute a line-level diff andhunksis empty.beforeBlobSize (integer) –
The size, in bytes, of the blob identified by
beforeBlobId. Returns0when you do not specifybeforeBlobId.afterBlobSize (integer) –
The size, in bytes, of the blob identified by
afterBlobId.NextToken (string) –
An enumeration token that can be used in a request to return the next batch of
DiffHunkentries.nullwhen the response contains the final page of the diff.
Exceptions
CodeCommit.Client.exceptions.RepositoryNameRequiredExceptionCodeCommit.Client.exceptions.InvalidRepositoryNameExceptionCodeCommit.Client.exceptions.RepositoryDoesNotExistExceptionCodeCommit.Client.exceptions.BlobIdRequiredExceptionCodeCommit.Client.exceptions.InvalidBlobIdExceptionCodeCommit.Client.exceptions.BlobIdDoesNotExistExceptionCodeCommit.Client.exceptions.FileTooLargeExceptionCodeCommit.Client.exceptions.ValidationExceptionCodeCommit.Client.exceptions.InvalidContinuationTokenExceptionCodeCommit.Client.exceptions.InvalidMaxResultsExceptionCodeCommit.Client.exceptions.EncryptionIntegrityChecksFailedExceptionCodeCommit.Client.exceptions.EncryptionKeyAccessDeniedExceptionCodeCommit.Client.exceptions.EncryptionKeyDisabledExceptionCodeCommit.Client.exceptions.EncryptionKeyNotFoundExceptionCodeCommit.Client.exceptions.EncryptionKeyUnavailableException