@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.

Fixes T6637, "closing by commit" should update task status and specify responsible commit, but drop the artificial comment.

Summary: When updating the status of a task via commit, transaction should show responsible commit and status update if it was changed.

Test Plan: Push a commit "Fixes Txx", transaction should include status update and commit number.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T6637

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

authored by

lkassianik and committed by
epriestley
204ae221 ad1da6ec

+121 -41
+116 -28
src/applications/maniphest/storage/ManiphestTransaction.php
··· 114 114 $phids[] = $phid; 115 115 } 116 116 break; 117 + case self::TYPE_STATUS: 118 + $commit_phid = $this->getMetadataValue('commitPHID'); 119 + if ($commit_phid) { 120 + $phids[] = $commit_phid; 121 + } 122 + break; 117 123 } 118 124 119 125 return $phids; ··· 121 127 122 128 public function shouldHide() { 123 129 switch ($this->getTransactionType()) { 130 + case PhabricatorTransactions::TYPE_EDGE: 131 + $commit_phid = $this->getMetadataValue('commitPHID'); 132 + $edge_type = $this->getMetadataValue('edge:type'); 133 + 134 + if ($edge_type == ManiphestTaskHasCommitEdgeType::EDGECONST) { 135 + if ($commit_phid) { 136 + return true; 137 + } 138 + } 139 + break; 124 140 case self::TYPE_DESCRIPTION: 125 141 case self::TYPE_PRIORITY: 126 142 case self::TYPE_STATUS: ··· 385 401 $old_name = ManiphestTaskStatus::getTaskStatusName($old); 386 402 $new_name = ManiphestTaskStatus::getTaskStatusName($new); 387 403 404 + $commit_phid = $this->getMetadataValue('commitPHID'); 405 + 388 406 if ($new_closed && !$old_closed) { 389 407 if ($new == ManiphestTaskStatus::getDuplicateStatus()) { 408 + if ($commit_phid) { 409 + return pht( 410 + '%s closed this task as a duplicate by committing %s.', 411 + $this->renderHandleLink($author_phid), 412 + $this->renderHandleLink($commit_phid)); 413 + } else { 414 + return pht( 415 + '%s closed this task as a duplicate.', 416 + $this->renderHandleLink($author_phid)); 417 + } 418 + } else { 419 + if ($commit_phid) { 420 + return pht( 421 + '%s closed this task as "%s" by committing %s.', 422 + $this->renderHandleLink($author_phid), 423 + $new_name, 424 + $this->renderHandleLink($commit_phid)); 425 + } else { 426 + return pht( 427 + '%s closed this task as "%s".', 428 + $this->renderHandleLink($author_phid), 429 + $new_name); 430 + } 431 + } 432 + } else if (!$new_closed && $old_closed) { 433 + if ($commit_phid) { 390 434 return pht( 391 - '%s closed this task as a duplicate.', 392 - $this->renderHandleLink($author_phid)); 435 + '%s reopened this task as "%s" by committing %s.', 436 + $this->renderHandleLink($author_phid), 437 + $new_name, 438 + $this->renderHandleLink($commit_phid)); 393 439 } else { 394 440 return pht( 395 - '%s closed this task as "%s".', 441 + '%s reopened this task as "%s".', 396 442 $this->renderHandleLink($author_phid), 397 443 $new_name); 398 444 } 399 - } else if (!$new_closed && $old_closed) { 400 - return pht( 401 - '%s reopened this task as "%s".', 402 - $this->renderHandleLink($author_phid), 403 - $new_name); 404 445 } else { 405 - return pht( 406 - '%s changed the task status from "%s" to "%s".', 407 - $this->renderHandleLink($author_phid), 408 - $old_name, 409 - $new_name); 446 + if ($commit_phid) { 447 + return pht( 448 + '%s changed the task status from "%s" to "%s" by committing %s.', 449 + $this->renderHandleLink($author_phid), 450 + $old_name, 451 + $new_name, 452 + $this->renderHandleLink($commit_phid)); 453 + } else { 454 + return pht( 455 + '%s changed the task status from "%s" to "%s".', 456 + $this->renderHandleLink($author_phid), 457 + $old_name, 458 + $new_name); 459 + } 410 460 } 411 461 412 462 case self::TYPE_UNBLOCK: ··· 590 640 $old_name = ManiphestTaskStatus::getTaskStatusName($old); 591 641 $new_name = ManiphestTaskStatus::getTaskStatusName($new); 592 642 643 + $commit_phid = $this->getMetadataValue('commitPHID'); 644 + 593 645 if ($new_closed && !$old_closed) { 594 646 if ($new == ManiphestTaskStatus::getDuplicateStatus()) { 647 + if ($commit_phid) { 648 + return pht( 649 + '%s closed %s as a duplicate by committing %s.', 650 + $this->renderHandleLink($author_phid), 651 + $this->renderHandleLink($object_phid), 652 + $this->renderHandleLink($commit_phid)); 653 + } else { 654 + return pht( 655 + '%s closed %s as a duplicate.', 656 + $this->renderHandleLink($author_phid), 657 + $this->renderHandleLink($object_phid)); 658 + } 659 + } else { 660 + if ($commit_phid) { 661 + return pht( 662 + '%s closed %s as "%s" by committing %s.', 663 + $this->renderHandleLink($author_phid), 664 + $this->renderHandleLink($object_phid), 665 + $new_name, 666 + $this->renderHandleLink($commit_phid)); 667 + } else { 668 + return pht( 669 + '%s closed %s as "%s".', 670 + $this->renderHandleLink($author_phid), 671 + $this->renderHandleLink($object_phid), 672 + $new_name); 673 + } 674 + } 675 + } else if (!$new_closed && $old_closed) { 676 + if ($commit_phid) { 595 677 return pht( 596 - '%s closed %s as a duplicate.', 678 + '%s reopened %s as "%s" by committing %s.', 597 679 $this->renderHandleLink($author_phid), 598 - $this->renderHandleLink($object_phid)); 680 + $this->renderHandleLink($object_phid), 681 + $new_name, 682 + $this->renderHandleLink($commit_phid)); 599 683 } else { 600 684 return pht( 601 - '%s closed %s as "%s".', 685 + '%s reopened %s as "%s".', 602 686 $this->renderHandleLink($author_phid), 603 687 $this->renderHandleLink($object_phid), 604 688 $new_name); 605 689 } 606 - } else if (!$new_closed && $old_closed) { 607 - return pht( 608 - '%s reopened %s as "%s".', 609 - $this->renderHandleLink($author_phid), 610 - $this->renderHandleLink($object_phid), 611 - $new_name); 612 690 } else { 613 - return pht( 614 - '%s changed the status of %s from "%s" to "%s".', 615 - $this->renderHandleLink($author_phid), 616 - $this->renderHandleLink($object_phid), 617 - $old_name, 618 - $new_name); 691 + if ($commit_phid) { 692 + return pht( 693 + '%s changed the status of %s from "%s" to "%s" by committing %s.', 694 + $this->renderHandleLink($author_phid), 695 + $this->renderHandleLink($object_phid), 696 + $old_name, 697 + $new_name, 698 + $this->renderHandleLink($commit_phid)); 699 + } else { 700 + return pht( 701 + '%s changed the status of %s from "%s" to "%s".', 702 + $this->renderHandleLink($author_phid), 703 + $this->renderHandleLink($object_phid), 704 + $old_name, 705 + $new_name); 706 + } 619 707 } 620 708 621 709 case self::TYPE_UNBLOCK:
+5 -13
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 466 466 $xactions = array(); 467 467 468 468 $edge_type = ManiphestTaskHasCommitEdgeType::EDGECONST; 469 - $xactions[] = id(new ManiphestTransaction()) 469 + $edge_xaction = id(new ManiphestTransaction()) 470 470 ->setTransactionType(PhabricatorTransactions::TYPE_EDGE) 471 471 ->setMetadataValue('edge:type', $edge_type) 472 472 ->setNewValue( ··· 481 481 if ($task->getStatus() != $status) { 482 482 $xactions[] = id(new ManiphestTransaction()) 483 483 ->setTransactionType(ManiphestTransaction::TYPE_STATUS) 484 + ->setMetadataValue('commitPHID', $commit->getPHID()) 484 485 ->setNewValue($status); 485 486 486 - $commit_name = $repository->formatCommitName( 487 - $commit->getCommitIdentifier()); 488 - 489 - $status_message = pht( 490 - 'Closed by commit %s.', 491 - $commit_name); 492 - 493 - $xactions[] = id(new ManiphestTransaction()) 494 - ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT) 495 - ->attachComment( 496 - id(new ManiphestTransactionComment()) 497 - ->setContent($status_message)); 487 + $edge_xaction->setMetadataValue('commitPHID', $commit->getPHID()); 498 488 } 499 489 } 490 + 491 + $xactions[] = $edge_xaction; 500 492 501 493 $content_source = PhabricatorContentSource::newForSource( 502 494 PhabricatorContentSource::SOURCE_DAEMON,