Skip to content

Conversation

@alatiera
Copy link
Contributor

@alatiera alatiera commented Nov 27, 2025

builder-manifest: Override branch with --default-branch when specified

Commit 00f63cf added default-branch with the stated intention of being
able to override the branch specified in the manifest. The name is a bit
confusing.

However the scenario tested was only when there was no
specified branch at all, and thus the behavior was a bit buggy.

Till now, if you had both specified "branch": "something" in the
manifest and used --default-branch=test, the end result in the
ostree repo would be for flatpak-builder to use the branch name
specified in the manifest.

$ flatpak-builder --default-branch=test --force-clean --repo=_build/repo/ app/ tests/test-default-branch.json
$ ostree refs --repo=_build/repo/
app/org.test.DefaultBranch/x86_64/something

With this change, we properly pick up default-branch if its set,
since it can only be set through the cli and its the explicit intention
that we want to override it.

$ meson devenv -C _build/ flatpak-builder  --default-branch=test --user --force-clean --repo=repo_test/ app/ ../tests/test-default-branch.json
$ ostree refs --repo=_build/repo_test
app/org.test.DefaultBranch/x86_64/test

@@ -0,0 +1,26 @@
{
"id": "org.test.DefaultBranch",
"runtime": "org.gnome.Platform",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
"runtime": "org.gnome.Platform",
"runtime": "org.test.Platform",

Didn't want to bother figuring out where the test runtime was

@alatiera
Copy link
Contributor Author

I also want to write proper tests for this before we merge it.

The scenarios we need to test are:

  • branch not specified -> master
  • branch not specified && --default-branch -> default-branch
  • branch specified -> specified
  • branch specified && --default-branch -> default-branch

@alatiera
Copy link
Contributor Author

lol I never wrote the commit subject

Commit 00f63cf added default-branch with the stated intention of being
able to override the branch specified in the manifest. The name is a bit
confusing.

However the scenario tested was only when there was no
specified branch at all, and thus the behavior was a bit buggy.

Till now, if you had both specified "branch": "something" in the
manifest and used --default-branch=test, the end result in the
ostree repo would be for flatpak-builder to use the branch name
specified in the manifest.

```
$ flatpak-builder --default-branch=test --force-clean --repo=_build/repo/ app/ tests/test-default-branch.json
$ ostree refs --repo=_build/repo/
app/org.test.DefaultBranch/x86_64/something
```

With this change, we properly pick up default-branch if its set,
since it can only be set through the cli and its the explicit intention
that we want to override it.

```
$ meson devenv -C _build/ flatpak-builder  --default-branch=test --user --force-clean --repo=repo_test/ app/ ../tests/test-default-branch.json
$ ostree refs --repo=_build/repo_test
app/org.test.DefaultBranch/x86_64/test
```
@alatiera alatiera force-pushed the alatiera/default-branch-fix branch from b236e3d to 8e94311 Compare November 27, 2025 09:53
@alatiera alatiera changed the title builder-manifest: Allow builder-manifest: Override branch with --default-branch when specified Nov 27, 2025
@alatiera alatiera marked this pull request as draft November 27, 2025 09:56
return self->runtime_version ? self->runtime_version : "master";
}

/* default-branch can only be set through the cli, where branch

Choose a reason for hiding this comment

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

default-branch can be set through manifest though.

@bbhtt
Copy link
Contributor

bbhtt commented Nov 27, 2025

It was intentional that the branch key in the manifest overrides both the default-branch key and the --default-branch argument.

I don't agree with the complicated design; so my plan was to remove the branch key entirely and just have the default-branch key+arg where the arg overrides the manifest key like everything else.

But I guess making both being overridden by the arg is ok.

In any case this is a breaking change and has to go through unstable branch first.

This also needs coordination at least on Flathub before merging as there are a number of extensions deriving their expected branch from the branch manifest key.

@Erick555
Copy link

Till now, if you had both specified "branch": "something" in the
manifest and used --default-branch=test, the end result in the
ostree repo would be for flatpak-builder to use the branch name
specified in the manifest.

This behavior is documented in docs so you need to update the docs while changing it:

<term><option>branch</option> (string)</term>
<listitem><para>The branch to use when exporting
the application. If this is unset the default
comes from the default-branch option.</para>
<para>This key overrides both the default-branch
key, and the --default-branch commandline
option. Unless you need a very specific branchname
(like for a runtime or an extension) it is
recommended to use the default-branch key instead, as
that can be overridden by the --default-branch option.</para></listitem>

@alatiera
Copy link
Contributor Author

alatiera commented Nov 27, 2025

Indeed, re-reading the manifest it actually works as expected.

This key overrides both the default-branch key, and the --default-branch commandline option.

Where this goes wrong imo is the following then.

  • You can't specify --branch but you can specify --default-branch.
  • If you already have a branch set, --default-branch should have been erroring out since it wouldn't take effect.
  • Initially we only had branch so all our old manifests still use that.

Let's close this PR and instead go fix the manifests then I guess

@alatiera alatiera closed this Nov 27, 2025
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.

3 participants