Bitbucket Data Center API Client
    Preparing search index...

    Class CommitResource

    Represents a Bitbucket commit resource with chainable async methods.

    Implements PromiseLike<BitbucketCommit> so it can be awaited directly to fetch the commit info, while also exposing sub-resource methods.

    // Await directly to get commit info
    const commit = await bbClient.project('PROJ').repo('my-repo').commit('abc123');

    // Get file changes introduced by this commit
    const changes = await bbClient.project('PROJ').repo('my-repo').commit('abc123').changes();

    // Get the full diff for this commit
    const diff = await bbClient.project('PROJ').repo('my-repo').commit('abc123').diff();

    Implements

    Index

    Methods

    • Adds annotations to a Code Insights report in bulk.

      POST /rest/insights/latest/projects/{key}/repos/{slug}/commits/{id}/reports/{key}/annotations

      Parameters

      Returns Promise<void>

    • Deletes a build status from this commit, identified by its build key.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/builds?key={key}

      Parameters

      • key: string

        The build key to delete

      Returns Promise<void>

    • Deletes a comment from this commit.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/comments/{commentId}

      Parameters

      • commentId: number

        The comment id

      • version: number

        Must match the comment's current version

      Returns Promise<void>

    • Deletes a deployment from this commit, identified by key, environment, and sequence number.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/deployments

      Parameters

      • params: DeploymentLookupParams

        deploymentSequenceNumber, key, and environmentKey — together identify one deployment

      Returns Promise<void>

    • Deletes annotations from a Code Insights report: a single one when externalId is given, or all of the report's annotations when omitted.

      DELETE /rest/insights/latest/projects/{key}/repos/{slug}/commits/{id}/reports/{key}/annotations[?externalId={externalId}]

      Parameters

      • key: string

        The report's key

      • OptionalexternalId: string

        External id of the annotation to delete; omit to delete all

      Returns Promise<void>

    • Deletes a Code Insights report (and its annotations) from this commit.

      DELETE /rest/insights/latest/projects/{key}/repos/{slug}/commits/{id}/reports/{key}

      Parameters

      • key: string

        The report's key

      Returns Promise<void>

    • Fetches the full diff for this commit.

      GET /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/diff/{path}

      The path param (the file to diff) is optional: when omitted, the diff for the whole commit is returned. srcPath is sent as a query parameter and identifies the previous path of a copied, moved or renamed file.

      Parameters

      • Optionalparams: DiffParams

        Optional: path, contextLines, srcPath, since, whitespace

      Returns Promise<BitbucketDiff>

      The diff object

    • Fetches a single build status for this commit, identified by its build key.

      GET /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/builds?key={key}

      This is the modern replacement for CommitResource.buildStatuses; unlike it, this endpoint returns a single build rather than a paged list.

      Parameters

      • key: string

        The build key to look up

      Returns Promise<BitbucketBuild>

      The build status matching the given key

    • Fetches the best common ancestor between this commit and another.

      GET /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/merge-base/{otherCommitId}

      Parameters

      • otherCommitId: string

        SHA of the commit to compare against

      Returns Promise<BitbucketCommit>

      The merge-base commit

    • Creates or replaces a single Code Insights annotation, identified by its external id.

      PUT /rest/insights/latest/projects/{key}/repos/{slug}/commits/{id}/reports/{key}/annotations/{externalId}

      Parameters

      • key: string

        The report's key

      • externalId: string

        The annotation's external id (assigned by the caller)

      • data: AddInsightAnnotationData

        The annotation's message, severity, and optional fields

      Returns Promise<void>

    • Creates or replaces a Code Insights report on this commit.

      PUT /rest/insights/latest/projects/{key}/repos/{slug}/commits/{id}/reports/{key}

      Parameters

      • key: string

        The report's key (assigned by the caller; replaces any existing report with the same key)

      • data: SetInsightReportData

        title and data (at most 6 items), plus optional details, result, reporter, link, logoUrl, createdDate, coverageProviderKey

      Returns Promise<BitbucketReport>

      The stored report

    • Removes the authenticated user as a watcher of this commit.

      DELETE /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/watch

      Returns Promise<void>

    • Updates a comment on this commit.

      PUT /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/comments/{commentId}

      Parameters

      • commentId: number

        The comment id

      • data: UpdateCommitCommentData

        version (must match the comment's current version) and the new text

      Returns Promise<BitbucketPullRequestComment>

      The updated comment

    • Adds the authenticated user as a watcher of this commit.

      POST /rest/api/latest/projects/{key}/repos/{slug}/commits/{id}/watch

      Returns Promise<void>