Return the current repository branch.

@return mixed current repository branch as a string, or NULL if in
detached HEAD state
343693
public function getCurrentBranch()
    {
        $branches = $this->getClient()->run($this, 'branch');
        $branches = explode("\n", $branches);

        foreach ($branches as $branch) {
            if ('*' === $branch[0]) {
                if (preg_match('/(detached|no branch)/', $branch)) {
                    return null;
                }

                return substr($branch, 2);
            }
        }
    }
27192
public function getRepository()
    {
        if (null == $this->repository) {
            $this->setRepository(
                Orm::getRepository($this->getEntityClassName())
            );
        }
        return $this->repository;
    }
201690
public function current() {
    if ($this->position >= $this->length) {
      return NULL;
    }
    return $this->tokens[$this->position];
  }
621050
public function getRepository()
    {
        if (null == $this->repository) {
            $this->setRepository(Orm::getRepository($this->type));
        }
        return $this->repository;
    }
316055
public function branches()
    {
        $result = $this->execute('list', array('--xml' => true, $this->getUrl() . '/' . $this->basePaths['branches']));

        $logTrunk = $this->log('/', null, 1);
        $logTrunk = reset($logTrunk);

        $branches = array();
        $branches[] = new Reference('trunk', Reference::BRANCH, $logTrunk->getRevision());

        foreach ($result as $fileinfo) {
            $branches[] = new Reference($fileinfo->getFilename(), Reference::BRANCH, $fileinfo->getCommit()->getRevision());
        }

        return $branches;
    }
556857
public function getVersion() {
        if (isset($this->version)) {
            return $this->version;
        }
        $version = $this->get('application.version');
        if (substr($version, 0, 1) === '@' && substr($version, -1) === '@') {
            // Silently try getting the version from Git.
            $tag = (new Shell())->execute(['git', 'describe', '--tags'], CLI_ROOT);
            if ($tag !== false && substr($tag, 0, 1) === 'v') {
                $version = trim($tag);
            }
        }
        $this->version = $version;

        return $version;
    }
423466
public function getRepository()
    {
        $emptyObject = SolutionSchema::getModel($this->modelClassName);

        $repository = $emptyObject->getRepository();

        return $repository;
    }
662882
public function getPanel()
	{
		if ($this->isUnderVersionControl()) {
			$title = '<h1>GIT</h1>';
			$warning = $cntTable = '';

			$branch = $this->getBranchName();
			if ($branch === 'master' || $branch === 'staging') {
				$warning = '<p style="color: #dd4742; font-weight: 700;">Current working in ' . $branch . ' branch</p>';
			}

			// commit message
			if (($commit = $this->getLastCommitMessage()) !== null) {
				$cntTable .= '<tr><td>Last commit</td><td> ' . $commit . ' </td></tr>';
			}

			// heads
			if (($heads = $this->getHeads()) !== null) {
				$cntTable .= '<tr><td>Branches</td><td> ' . $heads . ' </td></tr>';
			}

			// remotes
			if (($remotes = $this->getRemotes()) !== null) {
				$cntTable .= '<tr><td>Remotes</td><td> ' . $remotes . ' </td></tr>';
			}

			// tags
			if (($tags = $this->getTags()) !== null) {
				$cntTable .= '<tr><td>Tags</td><td> ' . $tags . ' </td></tr>';
			}

			$content = '<div class=\"tracy-inner tracy-InfoPanel\"><table><tbody>' .
				$cntTable .
				'</tbody></table></div>';

			return $title . $warning . $content;
		}

		return '';
	}
162248
public function getCurrentRevision()
    {
        if ($this->currentRevision === null) {
            $this->setCurrentRevision($this->revisionRepository->getCurrentByEnvironment($this));
        }
        return $this->currentRevision;
    }
240939
public function getRepository()
    {
        $repositoryGenerator = new RepositoryInterfaceGenerator([
            'name' => $this->name,
        ]);

        $repository = $repositoryGenerator->getRootNamespace() . '\\' . $repositoryGenerator->getName();

        return 'use ' . str_replace([
            "\\",
            '/'
        ], '\\', $repository) . 'Repository;';
    }
1304030
public function key()
    {
        if (is_null($this->current)) {
            $this->current = current($this->branch);
        }
        if ($this->current instanceof RecursiveLeafInterface) {
            return $this->current->key();
        }
    }
925923
public function getRepository()
    {
        if (!$this->_repository instanceof AnDomainRepositoryAbstract) {
            if (!$this->_repository instanceof AnServiceIdentifier) {
                $this->setRepository($this->_repository);
            }

            $this->_repository = AnDomain::getRepository($this->_repository);
        }

        return $this->_repository;
    }
190754
protected function getTagFromBranch($branch)
    {
        $git  = new GitRepository($this->input->getArgument('git-dir'));
        $tag  = trim($git->describe()->tags()->always()->execute($branch));
        $hash = trim($git->revParse()->short(false)->execute($branch));
        return $hash !== $tag ? $tag : null;
    }
645925
public function getVersionsBehind()
    {
        $current = $this->getCurrentVersion();
        $versions = array_filter($this->getVersions(),
                function ($version) use ($current) {
                    return $version > $current;
                }
        );

        return count($versions);
    }
1019193
protected function getRepository()
    {
        if (null === $this->repository) {
            $this->repository = $this->getEntityManager()
                    ->getRepository($this->getModuleNamespace() . '\Entity\\' . $this->getEntityName());
        }
        return $this->repository;
    }
1163632
public function getRepoUrl()
    {
        switch ($this->type) {
            case 'github':
                return "git@github.com:{$this->name}.git";

            case 'github-https':
                return "https://github.com/{$this->name}.git";

            case 'gitlab':
                return "git@gitlab.com:{$this->name}.git";
                break;

            case 'bitbucket':
                return "git@bitbucket.org:{$this->name}.git";

            default:

                // Check of type 'scheme://host/path'
                if (filter_var($this->type, FILTER_VALIDATE_URL)) {
                    return $this->type;
                }

                // Check of type 'user@host'
                if (filter_var($this->type, FILTER_VALIDATE_EMAIL)) {
                    return "{$this->type}:{$this->name}.git";
                }

                return;
                break;
        }
    }
641605
def current_branch(self):
        """"""
        branch_name = git(self.gitdir, self.gitwd, "symbolic-ref", "HEAD")
        return branch_name.replace('refs/heads/', '').strip()