本文整理汇总了PHP中Branch::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Branch::getName方法的具体用法?PHP Branch::getName怎么用?PHP Branch::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Branch
的用法示例。
在下文中一共展示了Branch::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: synchronize
/**
* @static
* @param GitCommand $gitCommand
* @param Repository $repository
* @param Branch $branch
* @param bool $deleteOnly
* @return void
*/
public static function synchronize(GitCommand $gitCommand, Repository $repository, Branch $branch, $deleteOnly = false)
{
$branchGit = $gitCommand->getNoMergedBranchInfos($repository->getGitDir(), $branch->getBaseBranchName(), $branch->getName());
$branchModel = BranchQuery::create()->filterByRepositoryId($repository->getId())->filterByName($branch->getName())->findOne();
if ($branchModel) {
if (is_null($branchGit)) {
$branchModel->delete();
} elseif (!$branchModel->getIsBlacklisted() && !$deleteOnly) {
$lastSynchronizationCommit = $branchModel->getLastCommit();
$branchModel->setCommitReference($branchGit['commit_reference']);
$branchModel->setLastCommit($branchGit['last_commit']);
$branchModel->setLastCommitDesc($branchGit['last_commit_desc']);
$branchModel->save();
return FilePeer::synchronize($gitCommand, $branchModel, $lastSynchronizationCommit);
}
}
return 0;
}
示例2: synchronize
/**
* @static
* @param GitCommand $gitCommand
* @param Branch $branch
* @param string $lastBranchSynchronizationCommit
* @return int 0 if succeed
*/
public static function synchronize(GitCommand $gitCommand, Branch $branch, $lastBranchSynchronizationCommit = null)
{
$filesGit = $gitCommand->getDiffFilesFromBranch($branch->getRepository()->getGitDir(), $branch->getCommitReference(), $branch->getLastCommit());
if (count($filesGit) > sfConfig::get('app_max_number_of_files_to_review', 4096)) {
return count($filesGit);
}
$filesModel = FileQuery::create()->filterByBranchId($branch->getId())->find();
if (count($filesModel) > 0) {
$diffFilesFromLastSynch = $gitCommand->getDiffFilesFromBranch($branch->getRepository()->getGitDir(), !is_null($lastBranchSynchronizationCommit) ? $lastBranchSynchronizationCommit : $branch->getCommitReference(), $branch->getLastCommit(), false);
}
foreach ($filesModel as $fileModel) {
/** @var $fileModel File */
if (!array_key_exists($fileModel->getFilename(), $filesGit)) {
$fileModel->delete();
} else {
$lastChangeCommit = $gitCommand->getLastModificationCommit($branch->getRepository()->getGitDir(), $branch->getName(), $fileModel->getFilename());
if (isset($diffFilesFromLastSynch[$fileModel->getFilename()])) {
$fileModel->setReviewRequest(true)->setStatus(BranchPeer::A_TRAITER)->setCommitStatusChanged($lastChangeCommit);
} else {
$fileModel->setReviewRequest(false);
}
if ($filesGit[$fileModel->getFilename()]['is-binary']) {
$fileModel->setIsBinary(true)->setNbAddedLines(0)->setNbDeletedLines(0);
} else {
$fileModel->setIsBinary(false)->setNbAddedLines($filesGit[$fileModel->getFilename()]['added-lines'])->setNbDeletedLines($filesGit[$fileModel->getFilename()]['deleted-lines']);
}
$fileModel->setState($filesGit[$fileModel->getFilename()]['state'])->setLastChangeCommit($lastChangeCommit)->setCommitInfos($gitCommand->getCommitInfos($branch->getRepository()->getGitDir(), $lastChangeCommit, "%ce %s"))->setCommitReference($branch->getCommitReference())->save();
}
unset($filesGit[$fileModel->getFilename()]);
}
foreach ($filesGit as $fileGit) {
$lastChangeCommit = $gitCommand->getLastModificationCommit($branch->getRepository()->getGitDir(), $branch->getName(), $fileGit['filename']);
$file = new File();
if ($fileGit['is-binary']) {
$file->setIsBinary(true)->setNbAddedLines(0)->setNbDeletedLines(0);
} else {
$file->setIsBinary(false)->setNbAddedLines($fileGit['added-lines'])->setNbDeletedLines($fileGit['deleted-lines']);
}
$file->setFilename($fileGit['filename'])->setStatus(BranchPeer::A_TRAITER)->setState($fileGit['state'])->setBranchId($branch->getId())->setLastChangeCommit($lastChangeCommit)->setCommitInfos($gitCommand->getCommitInfos($branch->getRepository()->getGitDir(), $lastChangeCommit, "%ce %s"))->setCommitReference($branch->getCommitReference())->setReviewRequest(true)->save();
}
return 0;
}
示例3: getCommits
/**
* @param Branch $branch
*
* @return Commit[]
*/
public function getCommits(Branch $branch)
{
exec(sprintf('git log --pretty=format:"%s" %s', self::PRETTY_FORMAT_STRING, $branch->getName()), $output);
$commits = [];
$commitData = [];
foreach ($output as $line) {
if (empty($line)) {
$commits[$commitData['H']] = new Commit(new Hash($commitData['H']), new User($commitData['aN'], $commitData['aE']), new \DateTime($commitData['ai']), new User($commitData['cN'], $commitData['cE']), new \DateTime($commitData['ci']), $commitData['s']);
continue;
}
if (false === strpos($line, ':')) {
continue;
}
list($key, $value) = explode(':', $line, 2);
$commitData[$key] = $value;
}
return $commits;
}
示例4: executeAddbranch
public function executeAddbranch()
{
$c = new Criteria();
$c->add(BranchPeer::NAME, $this->getRequestParameter('branch'));
$exbranch = BranchPeer::doSelectOne($c);
$c->clear();
$c->add(BranchPeer::CODE, $this->getRequestParameter('code'));
$excode = BranchPeer::doSelectOne($c);
if ($exbranch) {
$this->setFlash('notice', 'Branch could not be added. A branch with this name already exists.');
} elseif ($excode) {
$this->setFlash('notice', 'Branch could not be added. A branch with this code already exists.');
} else {
$branch = new Branch();
$branch->setName($this->getRequestParameter('branch'));
$branch->setCode($this->getRequestParameter('code'));
$branch->save();
$this->setFlash('notice', 'Branch <b>' . $branch->getName() . '</b> with code <b>' . $branch->getCode() . '</b> added successfully.');
}
$this->redirect('/admin/branches');
}