Page MenuHomePhabricator

Add Herald condition to act on pushing commits that have more than 1 parent
Closed, ResolvedPublic

Description

We want to enforce a linear history on master i.e. no merges. Seems like this can't be enforced with Herald today as there's no way to detect the condition of a pushed commit with more than 1 parent.

Event Timeline

"Is merge commit" detects this.

Screen Shot 2016-03-22 at 6.48.04 PM.png (366ร—816 px, 34 KB)

case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
  $parents = id(new DiffusionLowLevelParentsQuery())
    ->setRepository($repository)
    ->withIdentifier($this->getObject()->getRefNew())
    ->execute();

  return (count($parents) > 1);

Does that solve your problem?

Oops... sorry, can't believe I missed that! I was looking in "Commit Hook: Branches/Tags/Bookmarks" instead of "Commit Content".

Looks like I can't close this task myself? Anyway, we're good, feel free to close.

epriestley claimed this task.

I added you to Community so you should have task edit powers now.

Thanks! I shall use these powers responsibly ๐Ÿ˜„