Allow to specify multiple refSpec values

With this feature we can now also provide a list of value for the
refSpec. This can be useful when, for example, we want to exclude some
refs:

    refSpec:
      - +refs/heads/*:refs/heads/remote/*
      - ^refs/heads/excluded-*

Change-Id: Ibf4d4e9ff64a335929d491b167f0e9c4461c53f0
diff --git a/container-images/fetch-job/README.md b/container-images/fetch-job/README.md
index 8f9e156..9d217fc 100644
--- a/container-images/fetch-job/README.md
+++ b/container-images/fetch-job/README.md
@@ -28,6 +28,11 @@
   - remoteRepo: project3
     localRepo: local/project3
     refSpec: "+refs/heads/*:refs/heads/remote/*"
+  - remoteRepo: project4
+    localRepo: local/project4
+    refSpec:
+      - +refs/heads/*:refs/heads/remote/*
+      - ^refs/heads/excluded-*
 ```
 
 You will need to mount the credentials used to authenticate with remote servers
diff --git a/container-images/fetch-job/fetch-config.example.yaml b/container-images/fetch-job/fetch-config.example.yaml
index 46a1fea..9fa6c77 100644
--- a/container-images/fetch-job/fetch-config.example.yaml
+++ b/container-images/fetch-job/fetch-config.example.yaml
@@ -9,3 +9,8 @@
   - remoteRepo: project3
     localRepo: local/project3
     refSpec: +refs/heads/*:refs/heads/remote/*
+  - remoteRepo: project4
+    localRepo: local/project4
+    refSpec:
+      - +refs/heads/*:refs/heads/remote/*
+      - ^refs/heads/excluded-*
diff --git a/container-images/fetch-job/tools/fetch-job.py b/container-images/fetch-job/tools/fetch-job.py
index ad113f4..7eda19c 100755
--- a/container-images/fetch-job/tools/fetch-job.py
+++ b/container-images/fetch-job/tools/fetch-job.py
@@ -63,16 +63,19 @@
         # exit code 5 means the key did not exist — that is fine on first run
         check=False,
     )
-    subprocess.run(
-        [
-            "git",
-            f"--git-dir={git_dir}",
-            "config",
-            f"remote.{remote_name}.fetch",
-            refspec,
-        ],
-        check=True,
-    )
+    refspecs = refspec if isinstance(refspec, list) else [refspec]
+    for spec in refspecs:
+        subprocess.run(
+            [
+                "git",
+                f"--git-dir={git_dir}",
+                "config",
+                "--add",
+                f"remote.{remote_name}.fetch",
+                spec,
+            ],
+            check=True,
+        )
 
 
 def process_remote(remote):