Merge "Fix issue with sparse-checkout of include-vars"

This commit is contained in:
Zuul
2025-02-11 14:36:52 +00:00
committed by Gerrit Code Review
4 changed files with 24 additions and 0 deletions

View File

@@ -0,0 +1 @@
foo: project2

View File

@@ -0,0 +1,10 @@
- job:
name: test-workspace-checkout-multi-include-vars
parent: test-workspace-checkout-false
files: '.*' # Reset parent file matcher
include-vars: zuul.include/vars.yaml
- project:
check:
jobs:
- test-workspace-checkout-multi-include-vars

View File

@@ -1473,3 +1473,15 @@ class TestExecutorWorkspaceCheckout(ZuulTestCase, ExecutorReposMixin):
for f, expected in file_checks.items():
exists = os.path.exists(os.path.join(path, f))
self.assertEqual(expected, exists, f)
def test_workspace_checkout_multi_include_vars(self):
A = self.fake_gerrit.addFakeChange('org/project2', 'master', 'A')
self.fake_gerrit.addEvent(A.getPatchsetCreatedEvent(1))
self.waitUntilSettled()
self.assertHistory([
dict(
name='test-workspace-checkout-multi-include-vars',
result='SUCCESS'
),
], ordered=False)

View File

@@ -2321,6 +2321,7 @@ class AnsibleJob(object):
for iv in self.job.include_vars:
# For each include-vars, add the contining dir
key = (iv['connection'], iv['project'])
paths = self.repo_sparse_paths[key]
ivpath = os.path.dirname(iv['name'])
# Remove any / at the start and add one at the end.
ivpath = ivpath.lstrip('/') + '/'