Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

Support for repositories accessible via SSH. #20

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Expand Up @@ -56,6 +56,9 @@ By default, Sismo reads its configuration from ``~/.sismo/config.php``::
// add a remote Github repository
$projects[] = new Sismo\GithubProject('Twig', 'fabpot/Twig', $notifier);

// add a repository accessible via SSH
$projects[] = new Sismo\Project('Twig' 'git@github.com:fabpot/Twig.git');

// add a project with custom settings
$sf2 = new Sismo\Project('Symfony');
$sf2->setRepository('https://github.com/symfony/symfony.git');
Expand Down
1 change: 1 addition & 0 deletions compile
Expand Up @@ -110,6 +110,7 @@ $classes = array(
'Sismo\Storage',
'Sismo\Builder',
'Sismo\Project',
'Sismo\HTTPProject',
'Sismo\GithubProject',
'Sismo\Notifier',
'Sismo\GrowlNotifier',
Expand Down
2 changes: 1 addition & 1 deletion src/Sismo/GithubProject.php
Expand Up @@ -18,7 +18,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class GithubProject extends Project
class GithubProject extends HTTPProject
{
public function setRepository($url)
{
Expand Down
41 changes: 41 additions & 0 deletions src/Sismo/HTTPProject.php
@@ -0,0 +1,41 @@
<?php

/*
* This file is part of the Sismo utility.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sismo;

use Symfony\Component\Process\Process;

/**
* Describes a project which uses Git URLs in the form
* of https://example.com/username/MyProject.git@mybranch
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Rich Sage <rich.sage@gmail.com>
*/
class HTTPProject extends Project
{
/**
* Sets the repository URL after splitting to
* find the branch (where present)
*
* @param $url
* @return void
*/
public function setRepository($url)
{
if (false !== strpos($url, '@')) {
list($url, $branch) = explode('@', $url);
$this->setBranch($branch);
}

parent::setRepository($url);
}
}
5 changes: 0 additions & 5 deletions src/Sismo/Project.php
Expand Up @@ -158,11 +158,6 @@ public function getRepository()

public function setRepository($url)
{
if (false !== strpos($url, '@')) {
list($url, $branch) = explode('@', $url);
$this->branch = $branch;
}

$this->repository = $url;
}

Expand Down
25 changes: 25 additions & 0 deletions tests/Sismo/Tests/HTTPProjectTest.php
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the Sismo utility.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Sismo\Tests;

use Sismo\HTTPProject;

class HTTPProjectTest extends \PHPUnit_Framework_TestCase
{
public function testSetRepository()
{
$project = new HTTPProject('Twig Local');
$project->setRepository('https://github.com/fabpot/Twig.git@feat');
$this->assertEquals('https://github.com/fabpot/Twig.git', $project->getRepository());
$this->assertEquals('feat', $project->getBranch());
}
}
8 changes: 4 additions & 4 deletions tests/Sismo/Tests/ProjectTest.php
Expand Up @@ -32,8 +32,8 @@ public function testConstructor()
$this->assertEquals('master', $project->getBranch());

$project = new Project('Twig Local', 'repo@feat');
$this->assertEquals('repo', $project->getRepository());
$this->assertEquals('feat', $project->getBranch());
$this->assertEquals('repo@feat', $project->getRepository());
$this->assertEquals('master', $project->getBranch());

$project = new Project('Twig Local', 'repo', array(
$notifier1 = $this->getMock('Sismo\Notifier'),
Expand Down Expand Up @@ -170,8 +170,8 @@ public function testRepository()
$this->assertEquals('https://github.com/fabpot/Twig.git', $project->getRepository());

$project->setRepository('https://github.com/fabpot/Twig.git@feat');
$this->assertEquals('https://github.com/fabpot/Twig.git', $project->getRepository());
$this->assertEquals('feat', $project->getBranch());
$this->assertEquals('https://github.com/fabpot/Twig.git@feat', $project->getRepository());
$this->assertEquals('master', $project->getBranch());
}

public function testCommand()
Expand Down