From e1067d01d86a1b555e3f37024a72e116c94147f9 Mon Sep 17 00:00:00 2001
From: Ralf Jung <jung@mpi-sws.org>
Date: Wed, 24 Feb 2016 10:57:58 +0100
Subject: [PATCH] extractor can now automatically fetch missing new commits

---
 benchmark/gitlab-extract.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/benchmark/gitlab-extract.py b/benchmark/gitlab-extract.py
index 6a8f28c2b..45c5a039f 100755
--- a/benchmark/gitlab-extract.py
+++ b/benchmark/gitlab-extract.py
@@ -3,6 +3,12 @@ import argparse, pprint, subprocess, sys
 import requests
 import parse_log
 
+def last(it):
+    r = first(it) # errors out if it is empty
+    for i in it:
+        r = i
+    return r
+
 def first(it):
     for i in it:
         return i
@@ -32,6 +38,13 @@ parser.add_argument("-c", "--commits",
 args = parser.parse_args()
 log_file = sys.stdout if args.file == "-" else open(args.file, "a")
 
+# determine commit, if missing
+if args.commits is None:
+    if args.file == "-":
+        raise Exception("If you do not give explicit commits, you have to give a logfile so that we can determine the missing commits.")
+    last_result = last(parse_log.parse(open(args.file, "r"), []))
+    args.commits = "{}..origin/master".format(last_result.commit)
+
 projects = req("projects")
 project = first(filter(lambda p: p['path_with_namespace'] == args.project, projects.json()))
 
-- 
GitLab