Skip to content

Commit ae83709

Browse files
committed
Bug fixes
Fix handling missing primary config file Fix handling of services that are not installed
1 parent e515c14 commit ae83709

File tree

5 files changed

+21
-1
lines changed

5 files changed

+21
-1
lines changed

src/Commands/Behaviours/CanUpdateGitRemoteRepository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ protected function changeGitOrigin(Project $project, $cwd, $repo): int
2525
}
2626

2727
if ($this->tools()->git()->{$com}($cwd, 'origin', $repo)) {
28+
$this->tools()->git()->trackRemote($cwd, 'origin/master');
29+
2830
$this->updateProjectConfig($project, 1);
2931

3032
$this->tools()->success('successfully set <info>origin</info> to <info>%s</info>', $repo);

src/Commands/InitCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use function file_exists;
99
use function file_get_contents;
1010
use function file_put_contents;
11+
use function filesize;
1112
use function mkdir;
1213
use const DIRECTORY_SEPARATOR;
1314

@@ -47,6 +48,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
4748
$this->tools()->warning('Configuration at <info>%s</info> already exists', $dir);
4849
}
4950

51+
if (0 == filesize($dir . DIRECTORY_SEPARATOR . 'project_manager.yaml')) {
52+
$this->tools()->warning('Configuration file is empty');
53+
file_put_contents($dir . DIRECTORY_SEPARATOR . 'project_manager.yaml', $this->config());
54+
$this->tools()->success('Configuration re-created at <info>%s</info>', $dir);
55+
}
56+
5057
$this->tools()->newline();
5158

5259
return 0;

src/Services/Config/ConfigParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ConfigParser
4242
*/
4343
public function parse(string $file): Config
4444
{
45-
$config = MutableCollection::create(Yaml::parse($this->readFile($file))['somnambulist']);
45+
$config = MutableCollection::create(Yaml::parse($this->readFile($file))['somnambulist'] ?? []);
4646

4747
$spm = new Config($config->except('templates')->toArray(), $this->getEnvParameters());
4848

src/Services/DockerManager.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ public function bindConsoleHelper(ConsoleHelper $helper): void
7070

7171
public function resolve(Service $service): void
7272
{
73+
if (!$service->isInstalled()) {
74+
return;
75+
}
76+
7377
$env = (new Dotenv())->parse(file_get_contents($service->envFile()));
7478
$name = implode('_', array_filter([$env['COMPOSE_PROJECT_NAME'] ?? '', $service->appContainer()]));
7579

src/Services/GitManager.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ public function addRemote(string $cwd, string $name, string $remote): bool
106106
return $proc->isSuccessful();
107107
}
108108

109+
public function trackRemote(string $cwd, string $remote): bool
110+
{
111+
$proc = $this->exec('git branch -u %s', $cwd, $remote);
112+
113+
return $proc->isSuccessful();
114+
}
115+
109116
public function getRemotes(string $cwd): array
110117
{
111118
$proc = $this->exec('git remote -v', $cwd);

0 commit comments

Comments
 (0)