From 580f0006d6506008b8d0b55b1bae326b994a43b5 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 15 Nov 2024 14:08:32 +0100 Subject: [PATCH] Ensure we run git commands for bin/compile inside the root of the git repo, refs #12194 --- src/Composer/Compiler.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Compiler.php b/src/Composer/Compiler.php index e85329c6d..591132c7f 100644 --- a/src/Composer/Compiler.php +++ b/src/Composer/Compiler.php @@ -51,19 +51,19 @@ class Compiler $process = new ProcessExecutor(); - if (0 !== $process->execute(['git', 'log', '--pretty=%H', '-n1', 'HEAD'], $output, __DIR__)) { + if (0 !== $process->execute(['git', 'log', '--pretty=%H', '-n1', 'HEAD'], $output, dirname(dirname(__DIR__)))) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.'); } $this->version = trim($output); - if (0 !== $process->execute(['git', 'log', '-n1', '--pretty=%ci', 'HEAD'], $output, __DIR__)) { + if (0 !== $process->execute(['git', 'log', '-n1', '--pretty=%ci', 'HEAD'], $output, dirname(dirname(__DIR__)))) { throw new \RuntimeException('Can\'t run git log. You must ensure to run compile from composer git repository clone and that git binary is available.'); } $this->versionDate = new \DateTime(trim($output)); $this->versionDate->setTimezone(new \DateTimeZone('UTC')); - if (0 === $process->execute(['git', 'describe', '--tags', '--exact-match', 'HEAD'], $output, __DIR__)) { + if (0 === $process->execute(['git', 'describe', '--tags', '--exact-match', 'HEAD'], $output, dirname(dirname(__DIR__)))) { $this->version = trim($output); } else { // get branch-alias defined in composer.json for dev-main (if any)