Skip to content

feat(bitbucket): add inline PR comment support for specific lines and files - #1662

Open
mrcrysta1 wants to merge 1 commit into
atlassian-api:masterfrom
mrcrysta1:feat-bitbucket-inline-pr-comments
Open

feat(bitbucket): add inline PR comment support for specific lines and files#1662
mrcrysta1 wants to merge 1 commit into
atlassian-api:masterfrom
mrcrysta1:feat-bitbucket-inline-pr-comments

Conversation

@mrcrysta1

Copy link
Copy Markdown
Contributor

Summary

Adds add_pull_request_inline_comment() method for Bitbucket Server / Data Center REST API, resolving #1439.

This enables adding comments on specific lines or entire files within a pull request diff — a feature previously missing from the Python SDK.

Changes

  • New method: add_pull_request_inline_comment() in Bitbucket class (atlassian/bitbucket/__init__.py)
  • 4 new tests: RANGE comments, COMMIT line-level comments, threaded replies, custom srcPath for renamed files

Usage

from atlassian import Bitbucket

bb = Bitbucket(url="https://bitbucket.example.com", username="admin", password="secret")

# Line-level comment on a specific line
bb.add_pull_request_inline_comment(
    project_key="PRJ",
    repository_slug="my-repo",
    pull_request_id=42,
    text="This line has a potential null reference",
    path="src/main.py",
    from_hash="abc123",
    to_hash="def456",
    line=15,
    line_type="ADDED",
    diff_type="COMMIT",
    file_type="TO",
)

# Whole-file comment
bb.add_pull_request_inline_comment(
    project_key="PRJ",
    repository_slug="my-repo",
    pull_request_id=42,
    text="Overall great refactor!",
    path="src/utils.py",
    from_hash="abc123",
    to_hash="def456",
    diff_type="RANGE",
)

Parameters

Parameter Description
path File path relative to repo root
from_hash Source commit hash (branch HEAD before PR)
to_hash Target commit hash (branch HEAD after PR)
line Line number (required for diffType=COMMIT)
line_type ADDED, REMOVED, or CONTEXT
diff_type RANGE (whole-file) or COMMIT (line-level)
file_type FROM or TO — which side of the diff
src_path Original file path (for renamed files, defaults to path)
parent_id Parent comment ID for threaded replies

Tests

All 15 tests passing (11 existing + 4 new). Lint clean.

Closes

Closes #1439


This is my first contribution to this project. AI assistance (GitHub Copilot) was used for code generation and documentation. All code has been reviewed and tested locally before submission.

… files

Adds add_pull_request_inline_comment() for Bitbucket Server/Data Center
REST API. Supports both RANGE (whole-file) and COMMIT (line-level)
anchor-based comments with configurable line type, file type, and
threaded replies via parent_id. 4 new tests covering range, commit,
parent threading, and custom srcPath scenarios.
@codecov

codecov Bot commented Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 4.16667% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 60.61%. Comparing base (6f49a1a) to head (b8be914).
⚠️ Report is 27 commits behind head on master.

Files with missing lines Patch % Lines
atlassian/bitbucket/__init__.py 4.16% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1662      +/-   ##
==========================================
+ Coverage   59.74%   60.61%   +0.87%     
==========================================
  Files         101      106       +5     
  Lines       16868    18059    +1191     
  Branches     1746     1845      +99     
==========================================
+ Hits        10077    10947     +870     
- Misses       6393     6650     +257     
- Partials      398      462      +64     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bitbucket] Support pull request comments on specific lines

1 participant