Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/hosts.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ The typed setter methods give better IDE autocompletion:
```php
host('example.org')
->setHostname('example.cloud.google.com')
->setRemoteUser('deployer');
->setRemoteUser('deployer')
->setBranch('production');
```

---
Expand Down Expand Up @@ -130,6 +131,7 @@ set('default_selector', "stage=prod&role=web,role=special");
| **`ssh_multiplexing`** | Enable SSH multiplexing for performance. Default is `true`. |
| **`shell`** | Shell to use. Default is `bash -ls`. |
| **`deploy_path`** | Directory for deployments. E.g., `~/myapp`. |
| **`branch`** | Git branch to deploy for this host. Overrides the global `branch` config when set. Use `setBranch()` for a typed setter. |
| **`labels`** | Key-value pairs for host selection. |
| **`ssh_arguments`** | Additional SSH options. E.g., `['-o UserKnownHostsFile=/dev/null']`. |
| **`ssh_control_path`** | Control path for SSH multiplexing. Default is `~/.ssh/%C` or `/dev/shm/%C` in CI environments. |
Expand Down
11 changes: 11 additions & 0 deletions src/Host/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ public function getDeployPath(): ?string
return $this->config->get('deploy_path', null);
}

public function setBranch(string $branch): self
{
$this->config->set('branch', $branch);
return $this;
}

public function getBranch(): ?string
{
return $this->config->get('branch', null);
}

public function setLabels(array $labels): self
{
$this->config->set('labels', $labels);
Expand Down
4 changes: 3 additions & 1 deletion tests/src/Host/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public function testHost()
->setConfigFile('~/.ssh/config')
->setIdentityFile('~/.ssh/id_rsa')
->setForwardAgent(true)
->setSshMultiplexing(true);
->setSshMultiplexing(true)
->setBranch('develop');

self::assertEquals('host', $host->getAlias());
self::assertStringContainsString('host', $host->getTag());
Expand All @@ -45,6 +46,7 @@ public function testHost()
self::assertEquals('~/.ssh/id_rsa', $host->getIdentityFile());
self::assertEquals(true, $host->getForwardAgent());
self::assertEquals(true, $host->getSshMultiplexing());
self::assertEquals('develop', $host->getBranch());
}

public function testConfigurationAccessor()
Expand Down