Skip to content

Merge stable into develop - #1385

Merged
infrahub-github-bot-app[bot] merged 1 commit into
developfrom
stable
Oct 1, 2026
Merged

infrahub-github-bot-app[bot] merged 1 commit into
developfrom
stable

Conversation

@infrahub-github-bot-app

@infrahub-github-bot-app infrahub-github-bot-app Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Merging stable into develop after merging pull request #1293.


Summary by cubic

Fixes generators, transforms, and checks targeting the wrong branch, and prevents BranchNotFoundError when run without an explicit branch.

  • Runs without --branch now target the configured default_branch (INFRAHUB_DEFAULT_BRANCH, main by default) instead of the local Git checkout's active branch. Set INFRAHUB_DEFAULT_BRANCH_FROM_GIT=true to keep following the local Git branch.
  • Branch resolution now reads from the operation's root directory instead of the process working directory when default_branch_from_git is enabled.

Written for commit 494e74a. Summary will update on new commits.

Review in cubic

…1293)

* fix: target configured default_branch in generators, transforms and checks

`InfrahubOperation.branch_name` and `InfrahubCheck.branch_name` resolved the
branch from the local Git checkout whenever no explicit branch was passed,
ignoring the client's resolved default branch. Runs against a configured
`default_branch` therefore failed with `BranchNotFoundError` when the local Git
branch did not exist in Infrahub.

Resolve the branch from `client.default_branch` instead, which already honours
the `default_branch_from_git` config flag, so the Git branch is only used when
that flag is enabled.

* fix: resolve the Git default branch from the operation's root directory

`ConfigBase.default_infrahub_branch` always resolved the local Git branch from
the process working directory. Operations and checks are rooted at their own
`root_directory`, so with `default_branch_from_git` enabled they could resolve
against a different repository than the one they run in.

Add `ConfigBase.get_default_infrahub_branch(directory=...)`, which the existing
property now delegates to, and pass `root_directory` from `InfrahubOperation`
and `InfrahubCheck`.

Stub the Git lookup in the branch resolution tests. They previously compared
against `get_branch()` evaluated at assert time, which depends on the state of
the local checkout and fails outright when it has no active branch, as in CI.

* test: cover Git branch resolution from a check's root directory

* docs(changelog): call out default branch behaviour change
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying infrahub-sdk-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 494e74a
Status: ✅  Deploy successful!
Preview URL: https://f1f5ec6f.infrahub-sdk-python.pages.dev

View logs

@infrahub-github-bot-app
infrahub-github-bot-app Bot merged commit 946b6f5 into develop Oct 1, 2026
39 checks passed
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.

1 participant