Skip to content

Conversation

@gmazoyer
Copy link
Contributor

@gmazoyer gmazoyer commented Nov 5, 2025

This PR simply adds the graph_version and status properties on Branch as they will be available in Infrahub 1.5.

Summary by CodeRabbit

  • New Features
    • Branch list/table now shows Graph Version and Status (Open, Needs Rebase, Needs Upgrade Rebase, Deleting).
  • Bug Fixes
    • Non-default branches now display their own Graph Version and Status instead of inheriting the default branch value.
  • Tests
    • Test fixtures updated to include Graph Version and Status for branch data.

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Walkthrough

Adds a BranchStatus enum with values OPEN, NEED_REBASE, NEED_UPGRADE_REBASE, and DELETING. Extends BranchData with graph_version: int | None = None and status: BranchStatus. Updates BRANCH_DATA mapping to include "graph_version": None and "status": None. Test fixtures for branch list queries are expanded to include graph_version and status. The branches CLI list view gains a new Status column and per-row output is updated to populate each branch's status.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding two new properties (graph_version and status) to the branch entity.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gma-20251105-branch-graph-version

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d8fdd7b and 5e8e304.

📒 Files selected for processing (1)
  • infrahub_sdk/ctl/branch.py (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • infrahub_sdk/ctl/branch.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.9)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 5, 2025

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5e8e304
Status: ✅  Deploy successful!
Preview URL: https://f84a9991.infrahub-sdk-python.pages.dev
Branch Preview URL: https://gma-20251105-branch-graph-ve.infrahub-sdk-python.pages.dev

View logs

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

❗ There is a different number of reports uploaded between BASE (b52cd94) and HEAD (5e8e304). Click for more details.

HEAD has 6 uploads less than BASE
Flag BASE (b52cd94) HEAD (5e8e304)
python-3.12 2 1
python-3.10 2 1
python-filler-3.12 2 1
python-3.13 2 1
integration-tests 2 0
@@                 Coverage Diff                  @@
##           infrahub-develop     #600      +/-   ##
====================================================
- Coverage             76.44%   69.67%   -6.78%     
====================================================
  Files                   112      112              
  Lines                 10856     9453    -1403     
  Branches               2335     1879     -456     
====================================================
- Hits                   8299     6586    -1713     
- Misses                 1982     2366     +384     
+ Partials                575      501      -74     
Flag Coverage Δ
integration-tests ?
python-3.10 48.42% <11.11%> (-2.29%) ⬇️
python-3.11 48.45% <11.11%> (-0.04%) ⬇️
python-3.12 48.40% <11.11%> (-2.27%) ⬇️
python-3.13 48.40% <11.11%> (-2.29%) ⬇️
python-3.9 47.06% <11.11%> (?)
python-filler-3.12 24.45% <88.88%> (+0.77%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/branch.py 48.32% <100.00%> (-5.58%) ⬇️
infrahub_sdk/ctl/branch.py 77.46% <100.00%> (+0.32%) ⬆️

... and 34 files with indirect coverage changes

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
infrahub_sdk/branch.py (1)

38-38: LGTM! Optional: Consider field ordering for consistency.

The field is correctly added to the GraphQL query mapping. Optionally, you could reorder it to match the BranchData model definition (placing it between has_schema_changes and origin_branch) for better maintainability, though the current positioning is functionally equivalent.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 115333e and 9692822.

📒 Files selected for processing (2)
  • changelog/+branch-graph-version.added.md (1 hunks)
  • infrahub_sdk/branch.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • infrahub_sdk/branch.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
changelog/+branch-graph-version.added.md (1)

1-1: LGTM!

The changelog entry clearly documents the addition of the graph_version property to the Branch entity.

infrahub_sdk/branch.py (1)

24-24: LGTM!

The graph_version field is properly typed as optional and will be backward compatible with older Infrahub versions that don't return this property.

@gmazoyer gmazoyer requested a review from a team November 5, 2025 11:00
sync_with_git: bool
is_default: bool
has_schema_changes: bool
graph_version: int | None = None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also add status.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, we get that regardless with the query as seen in the integration tests..

@gmazoyer gmazoyer changed the title Add graph_version to branch Add graph_version and status to branch Nov 5, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
infrahub_sdk/ctl/branch.py (1)

78-79: Same None handling issue applies here.

The same concern about converting None to "None" applies here for non-default branches.

Apply the same fix as suggested for lines 62-63:

-            str(branch.graph_version),
+            str(branch.graph_version) if branch.graph_version is not None else "-",
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56f27f1 and 2936873.

📒 Files selected for processing (1)
  • infrahub_sdk/ctl/branch.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • infrahub_sdk/ctl/branch.py
infrahub_sdk/ctl/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

infrahub_sdk/ctl/**/*.py: Build CLI commands with Typer
Organize and keep all CLI commands within infrahub_sdk/ctl/

Files:

  • infrahub_sdk/ctl/branch.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: integration-tests-latest-infrahub
  • GitHub Check: documentation
🔇 Additional comments (1)
infrahub_sdk/ctl/branch.py (1)

49-50: LGTM! New columns added correctly.

The new "Graph Version" and "Status" columns are properly added to the table.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
infrahub_sdk/ctl/branch.py (1)

76-76: Pre-existing bug: Wrong variable used for schema changes.

This line uses default_branch.has_schema_changes instead of branch.has_schema_changes, causing all non-default branches to incorrectly display the default branch's schema changes status. This issue was already flagged in previous reviews.

Apply this diff to fix the bug:

-            "[green]True" if default_branch.has_schema_changes else "[#FF7F50]False",
+            "[green]True" if branch.has_schema_changes else "[#FF7F50]False",
🧹 Nitpick comments (1)
infrahub_sdk/ctl/branch.py (1)

62-63: Consider improving user-friendly display of graph_version and status.

The current implementation has two display concerns:

  1. Using a truthiness check on graph_version works but is less explicit than checking is not None. A graph_version of 0 (though unlikely) would incorrectly display as an empty string.

  2. The status enum will display as the raw enum name (e.g., NEED_REBASE), which is not user-friendly.

Apply this diff to improve both displays:

-        str(default_branch.graph_version) if default_branch.graph_version else "",
-        default_branch.status,
+        str(default_branch.graph_version) if default_branch.graph_version is not None else "-",
+        default_branch.status.value.replace("_", " ").title() if default_branch.status else "-",

Based on learnings.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2936873 and c262240.

📒 Files selected for processing (3)
  • infrahub_sdk/branch.py (3 hunks)
  • infrahub_sdk/ctl/branch.py (3 hunks)
  • tests/unit/ctl/conftest.py (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • tests/unit/ctl/conftest.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • infrahub_sdk/branch.py
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

When implementing Infrahub checks, subclass InfrahubCheck and override validate(data); do not implement or rely on a check() method

Files:

  • infrahub_sdk/ctl/branch.py
infrahub_sdk/ctl/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

infrahub_sdk/ctl/**/*.py: Build CLI commands with Typer
Organize and keep all CLI commands within infrahub_sdk/ctl/

Files:

  • infrahub_sdk/ctl/branch.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: unit-tests (3.13)
  • GitHub Check: unit-tests (3.9)
  • GitHub Check: unit-tests (3.12)
  • GitHub Check: unit-tests (3.11)
  • GitHub Check: unit-tests (3.10)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
infrahub_sdk/ctl/branch.py (1)

49-50: LGTM! New columns added correctly.

The two new columns "Graph Version" and "Status" are properly defined following the existing table column pattern.

@gmazoyer gmazoyer merged commit 9fb8d3c into infrahub-develop Nov 6, 2025
19 of 20 checks passed
@gmazoyer gmazoyer deleted the gma-20251105-branch-graph-version branch November 6, 2025 15:39
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.

4 participants