From dbd9c2a57bc559ef94ad7085896d6c7c34286b26 Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Thu, 26 Sep 2019 11:07:28 +0200
Subject: [PATCH] Make sure git init was called before any other git command

---
 Utils.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/Utils.php b/Utils.php
index 34c5d0b..845f68d 100644
--- a/Utils.php
+++ b/Utils.php
@@ -179,10 +179,20 @@ final class Utils {
     return $this;
   }
 
+  /**
+   * Make sure that git init was called.
+   */
+  protected static function gitInit() {
+    if (!file_exists('.git')) {
+      passthru(escapeshellcmd('git init'));
+    }
+  }
+
   /**
    * @param string $command
    */
   public static function git($command) {
+    self::gitInit();
     passthru(escapeshellcmd('git -c "user.email=composer@lakedrops.com" ' . $command));
   }
 
@@ -212,6 +222,7 @@ final class Utils {
    */
   public static function gitLFS($pattern) {
     if (self::$lfsGitPatterns === NULL) {
+      self::gitInit();
       $output = [];
       exec('git lfs track', $output);
       self::$lfsGitPatterns = implode(PHP_EOL, $output);
-- 
GitLab