Skip to content

Commit

Permalink
Use build in php-function to detect scheme, hostname and port in repo…
Browse files Browse the repository at this point in the history
… url (#2668)

* Use PHP biuld in funtion to detect scheme, hostname and port in repo url. refs #2667

* Updated changelog

* Add missing reference to changelog

* Unrelated issue, in order to make phpstan happy.
  • Loading branch information
Sander-Toonen authored Sep 23, 2021
1 parent d14c65c commit 1c8e23f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
- Support passing `null` as default in get(). [#2545]
- Shopware recipe: First activate plugins THEN build them to avoid breaking theme:compile with unbuild themes (which were activated AFTER build).
- Shopware recipe sw:plugin:upgrade:all task.
- Only perform keyscan for repos that are pulled over ssh. Better detection of hostname. [#2667]

### Removed
- Removed the `artisan:public_disk` task. Use the `artisan:storage:link` task instead. [#2488]
Expand Down Expand Up @@ -627,6 +628,7 @@
- Fixed `DotArray` syntax in `Collection`.


[#2667]: https://github.com/deployphp/deployer/pull/2667
[#2549]: https://github.com/deployphp/deployer/issues/2549
[#2545]: https://github.com/deployphp/deployer/issues/2545
[#2525]: https://github.com/deployphp/deployer/issues/2525
Expand Down
3 changes: 2 additions & 1 deletion recipe/deploy/release.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@
$releasesList = get('releases_list');

$table = [];
$tz = !empty(getenv('TIMEZONE')) ? getenv('TIMEZONE') : date_default_timezone_get();

foreach ($releasesLog as &$metainfo) {
$tz = !empty(getenv('TIMEZONE')) ? getenv('TIMEZONE') : date_default_timezone_get();
$date = \DateTime::createFromFormat(\DateTimeInterface::ISO8601, $metainfo['created_at']);
$date->setTimezone(new \DateTimeZone($tz));
$status = $release = $metainfo['release_name'];
Expand Down
9 changes: 5 additions & 4 deletions recipe/deploy/update_code.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@
}
}

// Populate known hosts.
if (preg_match('/(?:@|\/\/)([^\/:]+)(?:\:(\d{1,5}))?/', $repository, $matches)) {
$repositoryHostname = $matches[1];
$portOptions = isset($matches[2]) ? "-p {$matches[2]}" : null;
$url = parse_url($repository);

if (isset($url['scheme']) && $url['scheme'] === 'ssh') {
$repositoryHostname = $url['host'];
$portOptions = $url['port'] !== 22 ? "-p {$url['port']}" : null;
try {
run("ssh-keygen -F $repositoryHostname");
} catch (RunException $e) {
Expand Down

0 comments on commit 1c8e23f

Please sign in to comment.