From e8814be71b12e43f45a51e1c8e97b2bcc546c9a9 Mon Sep 17 00:00:00 2001
From: Michael Kriese <michael.kriese@visualon.de>
Date: Wed, 15 May 2019 12:03:28 +0200
Subject: [PATCH] feat(gitFs): small refactorings (#3701)

---
 lib/platform/git/storage.js | 49 ++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/lib/platform/git/storage.js b/lib/platform/git/storage.js
index c19e00e0f9..e4b400e8b1 100644
--- a/lib/platform/git/storage.js
+++ b/lib/platform/git/storage.js
@@ -8,6 +8,7 @@ const convertHrtime = require('convert-hrtime');
 class Storage {
   constructor() {
     let config = {};
+    /** @type {Git.SimpleGit} */
     let git = null;
     let cwd = null;
 
@@ -157,7 +158,7 @@ class Storage {
       await git.reset('hard');
       await git.raw(['clean', '-fd']);
       await git.checkout(['-B', branchName, sha]);
-      await git.push(['origin', branchName, '--force']);
+      await git.push('origin', branchName, { '--force': true });
       config.branchExists[branchName] = true;
     }
 
@@ -347,12 +348,10 @@ class Storage {
           }
         }
         await git.commit(message);
-        await git.push([
-          'origin',
-          `${branchName}:${branchName}`,
-          '--force',
-          '-u',
-        ]);
+        await git.push('origin', `${branchName}:${branchName}`, {
+          '--force': true,
+          '-u': true,
+        });
       } catch (err) /* istanbul ignore next */ {
         logger.debug({ err }, 'Error commiting files');
         if (err.message.includes('.github/main.workflow')) {
@@ -369,28 +368,28 @@ class Storage {
 
     function cleanRepo() {}
   }
+
+  static getUrl({ gitFs, auth, hostname, host, repository }) {
+    let protocol = gitFs || 'https';
+    // istanbul ignore if
+    if (protocol.toString() === 'true') {
+      protocol = 'https';
+    }
+    if (protocol === 'ssh') {
+      return `git@${hostname}:${repository}.git`;
+    }
+    return URL.format({
+      protocol,
+      auth,
+      hostname,
+      host,
+      pathname: repository + '.git',
+    });
+  }
 }
 
 function localName(branchName) {
   return branchName.replace(/^origin\//, '');
 }
 
-Storage.getUrl = ({ gitFs, auth, hostname, host, repository }) => {
-  let protocol = gitFs || 'https';
-  // istanbul ignore if
-  if (protocol.toString() === 'true') {
-    protocol = 'https';
-  }
-  if (protocol === 'ssh') {
-    return `git@${hostname}:${repository}.git`;
-  }
-  return URL.format({
-    protocol,
-    auth,
-    hostname,
-    host,
-    pathname: repository + '.git',
-  });
-};
-
 module.exports = Storage;
-- 
GitLab