[PATCH] Allow branch override

2 views
Skip to first unread message

Jan Kiszka

unread,
Sep 4, 2025, 5:09:42 AMSep 4
to kas-...@googlegroups.com, Nicolas Labriet, Felix Moessbauer
From: Nicolas Labriet <nlab...@centralp.fr>

Since eb4d112 when commit and branch are specified, kas checks if the
commit is actually contained in the branch.
This makes it impossible to have a branch set for a repo but use a
commit override to build a merge request on this repo (obviously not
yet on the specified branch).

This change allows the branch property of repos to be overridden to a
specific value, or even to Null.

Signed-off-by: Nicolas Labriet <nlab...@centralp.fr>
---

Forwarded from https://github.com/siemens/kas/pull/167

kas/repos.py | 1 +
kas/schema-kas.json | 4 ++++
2 files changed, 5 insertions(+)

diff --git a/kas/repos.py b/kas/repos.py
index f8151638..187f9430 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -273,6 +273,7 @@ def factory(name, repo_config, repo_defaults, repo_fallback_path,
'for local repositories.')
if refspec is None:
commit = repo_overrides.get('commit', commit)
+ branch = repo_overrides.get('branch', branch)
if commit and get_context().update:
logging.warning(f'Update of "{name}" requested, but repo is '
'pinned to a fixed commit. Not updating.')
diff --git a/kas/schema-kas.json b/kas/schema-kas.json
index e1bff6d0..17471102 100644
--- a/kas/schema-kas.json
+++ b/kas/schema-kas.json
@@ -118,6 +118,10 @@
"type": "object",
"additionalProperties": false,
"properties": {
+ "branch": {
+ "description": "Branch in which to find the overridden commit, can be Null",
+ "type": ["string", "null"]
+ },
"commit": {
"type": "string"
}

MOESSBAUER, Felix

unread,
Sep 9, 2025, 9:17:50 AMSep 9
to Kiszka, Jan, kas-...@googlegroups.com, nlab...@centralp.fr
On Thu, 2025-09-04 at 11:09 +0200, Jan Kiszka wrote:
> From: Nicolas Labriet <nlab...@centralp.fr>
>
> Since eb4d112 when commit and branch are specified, kas checks if the
> commit is actually contained in the branch.
> This makes it impossible to have a branch set for a repo but use a
> commit override to build a merge request on this repo (obviously not
> yet on the specified branch).
>
> This change allows the branch property of repos to be overridden to a
> specific value, or even to Null.
>
> Signed-off-by: Nicolas Labriet <nlab...@centralp.fr>
> ---
>
> Forwarded from https://github.com/siemens/kas/pull/167
>
> kas/repos.py | 1 +
> kas/schema-kas.json | 4 ++++
> 2 files changed, 5 insertions(+)
>
> diff --git a/kas/repos.py b/kas/repos.py
> index f8151638..187f9430 100644
> --- a/kas/repos.py
> +++ b/kas/repos.py
> @@ -273,6 +273,7 @@ def factory(name, repo_config, repo_defaults, repo_fallback_path,
> 'for local repositories.')
> if refspec is None:
> commit = repo_overrides.get('commit', commit)
> + branch = repo_overrides.get('branch', branch)

Hi, where do you intend to add this override to? A lockfile or a
regular kas file? I'm wondering if kas lock --update actually preserves
the manual branch entry (I doubt it, but did not check it).

> if commit and get_context().update:
> logging.warning(f'Update of "{name}" requested, but repo is '
> 'pinned to a fixed commit. Not updating.')
> diff --git a/kas/schema-kas.json b/kas/schema-kas.json
> index e1bff6d0..17471102 100644
> --- a/kas/schema-kas.json
> +++ b/kas/schema-kas.json
> @@ -118,6 +118,10 @@
> "type": "object",
> "additionalProperties": false,
> "properties": {
> + "branch": {
> + "description": "Branch in which to find the overridden commit, can be Null",
> + "type": ["string", "null"]
> + },

Please also add a changelog entry to the format-changelog and bump the
file version.

Apart from that, the change is fine.

Felix

> "commit": {
> "type": "string"
> }

--
Siemens AG
Linux Expert Center
Friedrich-Ludwig-Bauer-Str. 3
85748 Garching, Germany

Jan Kiszka

unread,
Sep 10, 2025, 6:03:49 AMSep 10
to kas-...@googlegroups.com, Felix Moessbauer, Nicolas Labriet
From: Nicolas Labriet <nlab...@centralp.fr>

Since eb4d112 when commit and branch are specified, kas checks if the
commit is actually contained in the branch.
This makes it impossible to have a branch set for a repo but use a
commit override to build a merge request on this repo (obviously not
yet on the specified branch).

This change allows the branch property of repos to be overridden to a
specific value, or even to Null.

Signed-off-by: Nicolas Labriet <nlab...@centralp.fr>
---
docs/format-changelog.rst | 8 ++++++++
kas/repos.py | 1 +
kas/schema-kas.json | 4 ++++
3 files changed, 13 insertions(+)

diff --git a/docs/format-changelog.rst b/docs/format-changelog.rst
index 5dd0c84c..e5d94d3b 100644
--- a/docs/format-changelog.rst
+++ b/docs/format-changelog.rst
@@ -193,3 +193,11 @@ Various keys for signature verification of repositories were added:
- top level ``signers`` object to specify keys for signature verification
- in repo definitions, ``signed`` and ``allowed_signers`` are added to
specify whether a repo is signed and which data to use for verification.
+
+Version 20
+----------
+
+Added
+~~~~~
+
+- The repo key ``branch`` can now be overridden, including to a null-value.
diff --git a/kas/repos.py b/kas/repos.py
index f8151638..187f9430 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -273,6 +273,7 @@ def factory(name, repo_config, repo_defaults, repo_fallback_path,
'for local repositories.')
if refspec is None:
commit = repo_overrides.get('commit', commit)
+ branch = repo_overrides.get('branch', branch)
if commit and get_context().update:
logging.warning(f'Update of "{name}" requested, but repo is '
'pinned to a fixed commit. Not updating.')
diff --git a/kas/schema-kas.json b/kas/schema-kas.json
index e1bff6d0..17471102 100644
--- a/kas/schema-kas.json
+++ b/kas/schema-kas.json
@@ -118,6 +118,10 @@
"type": "object",
"additionalProperties": false,
"properties": {
+ "branch": {
+ "description": "Branch in which to find the overridden commit, can be Null",
+ "type": ["string", "null"]
+ },
"commit": {
"type": "string"
}

MOESSBAUER, Felix

unread,
Sep 11, 2025, 6:39:07 AMSep 11
to Kiszka, Jan, kas-...@googlegroups.com, nlab...@centralp.fr
On Wed, 2025-09-10 at 12:03 +0200, Jan Kiszka wrote:
> From: Nicolas Labriet <nlab...@centralp.fr>
>
> Since eb4d112 when commit and branch are specified, kas checks if the
> commit is actually contained in the branch.
> This makes it impossible to have a branch set for a repo but use a
> commit override to build a merge request on this repo (obviously not
> yet on the specified branch).
>
> This change allows the branch property of repos to be overridden to a
> specific value, or even to Null.

Hi,

thanks for the update. Just one minor thing, which probably Jan can do
when merging:

The minimal config version also needs to be updated in the schema:
https://github.com/siemens/kas/blob/7ecc070d52c16c5aa20101b33da6e69b6f0738eb/kas/schema-kas.json#L29

Reviewed-by: Felix Moessbauer <felix.mo...@siemens.com>

Felix

Felix Moessbauer

unread,
Sep 11, 2025, 9:32:39 AMSep 11
to kas-...@googlegroups.com, jan.k...@siemens.com, Nicolas Labriet, Felix Moessbauer
From: Nicolas Labriet <nlab...@centralp.fr>

Since eb4d112 when commit and branch are specified, kas checks if the
commit is actually contained in the branch.
This makes it impossible to have a branch set for a repo but use a
commit override to build a merge request on this repo (obviously not
yet on the specified branch).

This change allows the branch property of repos to be overridden to a
specific value, or even to Null.

Reviewed-by: Felix Moessbauer <felix.mo...@siemens.com>
Signed-off-by: Nicolas Labriet <nlab...@centralp.fr>
---
Felix: added my reviewed by

docs/format-changelog.rst | 8 ++++++++
kas/repos.py | 1 +
kas/schema-kas.json | 6 +++++-
3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/docs/format-changelog.rst b/docs/format-changelog.rst
index 5dd0c84cf..e5d94d3b7 100644
--- a/docs/format-changelog.rst
+++ b/docs/format-changelog.rst
@@ -193,3 +193,11 @@ Various keys for signature verification of repositories were added:
- top level ``signers`` object to specify keys for signature verification
- in repo definitions, ``signed`` and ``allowed_signers`` are added to
specify whether a repo is signed and which data to use for verification.
+
+Version 20
+----------
+
+Added
+~~~~~
+
+- The repo key ``branch`` can now be overridden, including to a null-value.
diff --git a/kas/repos.py b/kas/repos.py
index f8151638e..187f94305 100644
--- a/kas/repos.py
+++ b/kas/repos.py
@@ -273,6 +273,7 @@ class Repo:
'for local repositories.')
if refspec is None:
commit = repo_overrides.get('commit', commit)
+ branch = repo_overrides.get('branch', branch)
if commit and get_context().update:
logging.warning(f'Update of "{name}" requested, but repo is '
'pinned to a fixed commit. Not updating.')
diff --git a/kas/schema-kas.json b/kas/schema-kas.json
index e1bff6d0e..c9664df8c 100644
--- a/kas/schema-kas.json
+++ b/kas/schema-kas.json
@@ -26,7 +26,7 @@
{
"type": "integer",
"minimum": 1,
- "maximum": 19
+ "maximum": 20
}
]
},
@@ -118,6 +118,10 @@
"type": "object",
"additionalProperties": false,
"properties": {
+ "branch": {
+ "description": "Branch in which to find the overridden commit, can be Null",
+ "type": ["string", "null"]
+ },
"commit": {
"type": "string"
}
--
2.51.0

Jan Kiszka

unread,
Sep 15, 2025, 6:14:32 AMSep 15
to Felix Moessbauer, kas-...@googlegroups.com, Nicolas Labriet
Thanks, applied.

Jan

--
Siemens AG, Foundational Technologies
Linux Expert Center
Reply all
Reply to author
Forward
0 new messages