Merge "Only depend-on open changes" into feature/zuulv3
diff --git a/tests/unit/test_scheduler.py b/tests/unit/test_scheduler.py
index 70f3fb7..f33d964 100755
--- a/tests/unit/test_scheduler.py
+++ b/tests/unit/test_scheduler.py
@@ -3841,19 +3841,23 @@
self.create_branch('org/project2', 'mp')
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
B = self.fake_gerrit.addFakeChange('org/project2', 'master', 'B')
- C = self.fake_gerrit.addFakeChange('org/project2', 'mp', 'C')
- C.data['id'] = B.data['id']
+ C1 = self.fake_gerrit.addFakeChange('org/project2', 'mp', 'C1')
+ C2 = self.fake_gerrit.addFakeChange('org/project2', 'mp', 'C2',
+ status='ABANDONED')
+ C1.data['id'] = B.data['id']
+ C2.data['id'] = B.data['id']
+
A.addApproval('Code-Review', 2)
B.addApproval('Code-Review', 2)
- C.addApproval('Code-Review', 2)
+ C1.addApproval('Code-Review', 2)
- # A Depends-On: B+C
+ # A Depends-On: B+C1
A.data['commitMessage'] = '%s\n\nDepends-On: %s\n' % (
A.subject, B.data['id'])
self.executor_server.hold_jobs_in_build = True
B.addApproval('Approved', 1)
- C.addApproval('Approved', 1)
+ C1.addApproval('Approved', 1)
self.fake_gerrit.addEvent(A.addApproval('Approved', 1))
self.waitUntilSettled()
@@ -3869,10 +3873,10 @@
self.assertEqual(A.data['status'], 'MERGED')
self.assertEqual(B.data['status'], 'MERGED')
- self.assertEqual(C.data['status'], 'MERGED')
+ self.assertEqual(C1.data['status'], 'MERGED')
self.assertEqual(A.reported, 2)
self.assertEqual(B.reported, 2)
- self.assertEqual(C.reported, 2)
+ self.assertEqual(C1.reported, 2)
changes = self.getJobFromHistory(
'project-merge', 'org/project1').changes
diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py
index 460eabb..35137c7 100644
--- a/zuul/driver/gerrit/gerritconnection.py
+++ b/zuul/driver/gerrit/gerritconnection.py
@@ -470,6 +470,9 @@
self.log.debug("Updating %s: Getting git-dependent change %s,%s" %
(change, dep_num, dep_ps))
dep = self._getChange(dep_num, dep_ps, history=history)
+ # This is a git commit dependency. So we only ignore it if it is
+ # already merged. So even if it is "ABANDONED", we should not
+ # ignore it.
if (not dep.is_merged) and dep not in needs_changes:
needs_changes.append(dep)
@@ -481,7 +484,7 @@
"change %s,%s" %
(change, dep_num, dep_ps))
dep = self._getChange(dep_num, dep_ps, history=history)
- if (not dep.is_merged) and dep not in needs_changes:
+ if dep.open and dep not in needs_changes:
needs_changes.append(dep)
change.needs_changes = needs_changes
@@ -493,7 +496,7 @@
self.log.debug("Updating %s: Getting git-needed change %s,%s" %
(change, dep_num, dep_ps))
dep = self._getChange(dep_num, dep_ps, history=history)
- if (not dep.is_merged) and dep.is_current_patchset:
+ if dep.open and dep.is_current_patchset:
needed_by_changes.append(dep)
for record in self._getNeededByFromCommit(data['id'], change):
@@ -509,7 +512,7 @@
refresh = (dep_num, dep_ps) not in history
dep = self._getChange(
dep_num, dep_ps, refresh=refresh, history=history)
- if (not dep.is_merged) and dep.is_current_patchset:
+ if dep.open and dep.is_current_patchset:
needed_by_changes.append(dep)
change.needed_by_changes = needed_by_changes