From 2c8a408f1c929a82ca8bb575876ac6ea0e026cd3 Mon Sep 17 00:00:00 2001 From: EvanEzell Date: Tue, 23 Oct 2018 16:27:47 -0400 Subject: [PATCH] Fix case when there is no common ancestor between commits There are few cases where the api will return that there is no common ancestor between commits. In my list of releases it was the following: https://api.github.com/repos/Onegini/cordova-plugin-onegini/compare/2.1.0...1.8.7 The propose change will print an error message to standard error when that is the case --- compareRels.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compareRels.py b/compareRels.py index bef6838..279f47a 100644 --- a/compareRels.py +++ b/compareRels.py @@ -59,7 +59,10 @@ def cmp_rel (url): v = get (url) except Exception as e: sys.stderr.write ("Could not get:" + url + ". Exception:" + str(e) + "\n") - print (url+';'+str(v['ahead_by'])+';'+str(v['behind_by'])) + if 'ahead_by' in v and 'behind_by' in v: + print (url+';'+str(v['ahead_by'])+';'+str(v['behind_by'])) + else: + sys.stderr.write ("Could not compare releases for: " + url + "; There exists no common ancestor between the two versions." + "\n") p2r = {}