@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow demoted builds to automatically promote if builds pass after a restart

Summary:
Ref T13124. See PHI584. When you create a draft revision and it automatically demotes to "Changes Planned + Draft" because builds fail, let it promote to "Needs Review" automatically if builds pass. Usually, this will be because someone restarted the builds and they worked the second time.

Although I'm a little wary about adding even more state transitions to the diagram in T13110#237736, I think this one is reasonably natural and not ambiguous.

Test Plan:
- Created a failing build plan with a "Throw Exception" step.
- Created a revision which hit the build plan, saw it demote to "Changes Planned" when Harbormaster failed.
- Edited the build plan to remove the "Throw Exception" step, restarted the build, got a pass.
- Saw revision promote again:

{F5526104}

I didn't exhaustively test that the other 40 state transitions still work properly, but I think the scope of this change is small enough that it's unlikely I did much collateral damage.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13124

Differential Revision: https://secure.phabricator.com/D19380

+31 -5
+31 -5
src/applications/differential/editor/DifferentialTransactionEditor.php
··· 1555 1555 $auto_undraft = false; 1556 1556 } 1557 1557 1558 - if ($object->isDraft() && $auto_undraft) { 1558 + $can_promote = false; 1559 + $can_demote = false; 1560 + 1561 + // "Draft" revisions can promote to "Review Requested" after builds pass, 1562 + // or demote to "Changes Planned" after builds fail. 1563 + if ($object->isDraft()) { 1564 + $can_promote = true; 1565 + $can_demote = true; 1566 + } 1567 + 1568 + // See PHI584. "Changes Planned" revisions which are not yet broadcasting 1569 + // can promote to "Review Requested" if builds pass. 1570 + 1571 + // This pass is presumably the result of someone restarting the builds and 1572 + // having them work this time, perhaps because the builds are not perfectly 1573 + // reliable or perhaps because someone fixed some issue with build hardware 1574 + // or some other dependency. 1575 + 1576 + // Currently, there's no legitimate way to end up in this state except 1577 + // through automatic demotion, so this behavior should not generate an 1578 + // undue level of confusion or ambiguity. Also note that these changes can 1579 + // not demote again since they've already been demoted once. 1580 + if ($object->isChangePlanned()) { 1581 + if (!$object->getShouldBroadcast()) { 1582 + $can_promote = true; 1583 + } 1584 + } 1585 + 1586 + if (($can_promote || $can_demote) && $auto_undraft) { 1559 1587 $status = $this->loadCompletedBuildableStatus($object); 1560 1588 1561 1589 $is_passed = ($status === HarbormasterBuildableStatus::STATUS_PASSED); 1562 1590 $is_failed = ($status === HarbormasterBuildableStatus::STATUS_FAILED); 1563 1591 1564 - if ($is_passed) { 1592 + if ($is_passed && $can_promote) { 1565 1593 // When Harbormaster moves a revision out of the draft state, we 1566 1594 // attribute the action to the revision author since this is more 1567 1595 // natural and more useful. ··· 1593 1621 // batch of transactions finishes so that Herald can fire on the new 1594 1622 // revision state. See T13027 for discussion. 1595 1623 $this->queueTransaction($xaction); 1596 - } else if ($is_failed) { 1624 + } else if ($is_failed && $can_demote) { 1597 1625 // When demoting a revision, we act as "Harbormaster" instead of 1598 1626 // the author since this feels a little more natural. 1599 1627 $harbormaster_phid = id(new PhabricatorHarbormasterApplication()) ··· 1607 1635 ->setNewValue(true); 1608 1636 1609 1637 $this->queueTransaction($xaction); 1610 - 1611 - // TODO: Notify the author (only) that we did this. 1612 1638 } 1613 1639 } 1614 1640