siemens / kas

Setup tool for bitbake based projects
MIT License
371 stars 148 forks source link

KAS checkout can't handle fast-forward merges #122

Closed lms-jk closed 3 months ago

lms-jk commented 3 months ago

Our workflow involves fast-forward merges. Switching a meta-layer branch from a merged feature-branch back to the release branch does not work with kas checkout.

As an example, scarthgap is the release branch and devel is the feature branch of a meta-layer repository bsp. During development, the meta-layer was configured to track the feature branch devel in the config file:

...
repos:
  bsp:
    url: "<our_internal_git_server>"
    branch: devel
    commit: "fab4308300b7b7df5dec4e88bdea2b8c8c91f2cc"
    path: "layers/meta-lms-nvidia-bsp"
...

After merging the meta-layer with a fast-forward merge (which does not change the commit hash), the release branch is tracked again:

...
repos:
  bsp:
    url: "<our_internal_git_server>"
    branch: scarthgap
    commit: "fab4308300b7b7df5dec4e88bdea2b8c8c91f2cc"
    path: "layers/meta-lms-nvidia-bsp"
...

This change will produce the following error message, although "fab4308300b7b7df5dec4e88bdea2b8c8c91f2cc" does exist in branch scarthgap now:

2024-04-10 13:56:34 - ERROR - Branch "scarthgap" in repository "bsp" does not contain commit "fab4308300b7b7df5dec4e88bdea2b8c8c91f2cc"

My hypothesis is, that KAS does not fetch the latest revisions from repository bsp, because the commit hash already matches. This also means, that KAS misses the update of branch scarthgap and complains, that said commit is not contained in the branch.

fmoessbauer commented 3 months ago

Hi!

My hypothesis is, that KAS does not fetch the latest revisions from repository bsp, because the commit hash already matches. This also means, that KAS misses the update of branch scarthgap and complains, that said commit is not contained in the branch.

This is likely the reason. We indeed need to check if we have the commit on that branch as well and execute the fetch operation otherwise. I just want to double check if this is a regression in 4.3, or if this has always been like that. Did that work in the 4.1 / 4.2 version?

lms-jk commented 3 months ago

I will check and come back to you.

lms-jk commented 3 months ago

First I need to add, that appending --update to either kas checkout or kas build fixes this issue.

Testing for regressions:

fmoessbauer commented 3 months ago

First I need to add, that appending --update to either kas checkout or kas build fixes this issue.

Yes, that's what I expected. Our short circuit to avoid the remote fetching was simply not precise enough. When adding --update, a fetch is always performed.

I just pushed a fix to the ML (you are in CC): https://groups.google.com/g/kas-devel/c/UmRKGPu_hPo. Please give it a try.

lms-jk commented 3 months ago

Works perfectly. Thank you!