Platformsh\Cli\Helper\GitHelper::getMergedBranches PHP Method

getMergedBranches() public method

Get a list of branches merged with a specific ref.
public getMergedBranches ( string $ref = 'HEAD', boolean $remote = false, null $dir = null, boolean $mustRun = false ) : string[]
$ref string
$remote boolean
$dir null
$mustRun boolean
return string[]
    public function getMergedBranches($ref = 'HEAD', $remote = false, $dir = null, $mustRun = false)
    {
        $args = ['branch', '--list', '--no-column', '--merged', $ref];
        if ($remote) {
            $args[] = '--remote';
        }
        $mergedBranches = $this->execute($args, $dir, $mustRun);
        $array = array_map(function ($element) {
            return trim($element, ' *');
        }, explode("\n", $mergedBranches));
        return $array;
    }

Usage Example

 /**
  * Test GitHelper::getMergedBranches().
  */
 public function testGetMergedBranches()
 {
     $this->gitHelper->checkOutNew('branch1');
     $this->gitHelper->checkOutNew('branch2');
     $this->assertEquals(['branch1', 'branch2', 'master'], $this->gitHelper->getMergedBranches('master'));
 }