From 110dcaacf9a12b638881a3f8e5a92f9fde675779 Mon Sep 17 00:00:00 2001
From: Albin Vass <albin.vass@volvocars.com>
Date: Fri, 6 Sep 2019 15:30:17 +0200
Subject: [PATCH] Clean non-bare remote repos

In case of reused workspaces on static nodes remote
non-bare repos needs to be cleaned up to make sure
that any untracked files from any earlier jobs are removed.

Change-Id: I00dda298f499b241a224c19657ebbb8a9015eb4d
---
 roles/mirror-workspace-git-repos/tasks/main.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/roles/mirror-workspace-git-repos/tasks/main.yaml b/roles/mirror-workspace-git-repos/tasks/main.yaml
index 4fe069dc2..41cefa961 100644
--- a/roles/mirror-workspace-git-repos/tasks/main.yaml
+++ b/roles/mirror-workspace-git-repos/tasks/main.yaml
@@ -29,6 +29,8 @@
   shell: |
     # Reset is needed because we pushed to a non-bare repo
     git reset --hard
+    # Clean is needed because we pushed to a non-bare repo
+    git clean -xdf
     # Undo the config setting we did above
     git config --local --unset receive.denyCurrentBranch
     # checkout the branch matching the branch set up by the executor