From c4f67cf0775ecbfd358720583e2bc7f7d11adfc3 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Wed, 5 Sep 2018 16:03:14 +0200
Subject: [PATCH] refactor: measure git clone time

---
 lib/platform/git/storage.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/platform/git/storage.js b/lib/platform/git/storage.js
index f8112dc1df..7383871c03 100644
--- a/lib/platform/git/storage.js
+++ b/lib/platform/git/storage.js
@@ -2,6 +2,7 @@ const fs = require('fs-extra');
 const { join } = require('path');
 const tmp = require('tmp-promise');
 const Git = require('simple-git/promise');
+const convertHrtime = require('convert-hrtime');
 
 class Storage {
   constructor() {
@@ -29,11 +30,16 @@ class Storage {
 
     async function initRepo(args) {
       cleanRepo();
-      logger.info('Git FS mode enabled');
+      logger.info('Initialising git repository');
       config = { ...args };
       repoDir = await tmp.dir({ unsafeCleanup: true });
       git = Git(repoDir.path).silent(true);
+      const cloneStart = process.hrtime();
       await git.clone(config.url, '.', ['--depth=2', '--no-single-branch']);
+      const cloneSeconds = Math.round(
+        convertHrtime(process.hrtime(cloneStart)).seconds
+      );
+      logger.info({ cloneSeconds }, 'git clone completed');
 
       if (config.gitAuthor) {
         await git.raw(['config', 'user.name', config.gitAuthor.name]);
-- 
GitLab