BobBuildTool / bob

Bob build tool - Functional cross platform build-automation tool
https://bobbuildtool.dev/
GNU General Public License v3.0
76 stars 44 forks source link

gitscm: branch "issue" #551

Closed rhubert closed 9 months ago

rhubert commented 9 months ago

One of my colleagues had a issue compiling our stuff. useCommitOnBranch was enabled and the checkout failed because of a non exiting branch. In this special case the branch was set via an env var, but for the package he wanted to build the env-var was set to a different value than the missing branch. First I wasn't able to reproduce this in my tree until I disabled my rootFilter...

A stripped down repo would be:

a.yaml:

checkoutSCM:
  scm: git
  url: git@foo.com/a.git
  commit: "${COMMIT_A}"
  branch: "${BRANCH_A}"

buildScript: /bin/true
packageScript: /bin/true

assuming there is a branch: c with commit: 0 but no branch b in this repo....

b.yaml:

root: True

environment:
  COMMIT_A: "0000000000000000000000000000000000000000"
  BRANCH_A: "b"

depends:
  - a

buildScript: /bin/true
packageScript: /bin/true

c.yaml:

root: True

environment:
  COMMIT_A: "0000000000000000000000000000000000000000"
  BRANCH_A: "c"

depends:
  - a

buildScript: /bin/true
packageScript: /bin/true

Unfortunately the branch for a is b, except b is filtered by the rootFilter...

$ bob query-scm -f "git={branch}" //a
b

I have a rough idea why this happens but I'm unsure if it's worth adding additional checks for this. What do you think?

jkloetzke commented 9 months ago

The underlying problem is that there is only one package "a":

$ bob ls -d //a
b/a

The reason is that both b/a and c/a create exactly the same result. Such packages are de-duplicated during parsing because otherwise even medium sized projects would not be viable.

I'm not sure that there is anything that can be checked here. The given example configuration could be valid because a commit can belong to any number of branches.