You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by hu...@apache.org on 2018/09/19 07:36:13 UTC

[kibble-scanners] branch master updated: if we've scanned before, only grab latest changes

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kibble-scanners.git


The following commit(s) were added to refs/heads/master by this push:
     new 2c32eea  if we've scanned before, only grab latest changes
2c32eea is described below

commit 2c32eea1ee4e9d81bddac286709290d65a127dab
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Sep 19 09:35:59 2018 +0200

    if we've scanned before, only grab latest changes
---
 src/plugins/scanners/github-issues.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/plugins/scanners/github-issues.py b/src/plugins/scanners/github-issues.py
index cfdc976..961cadd 100644
--- a/src/plugins/scanners/github-issues.py
+++ b/src/plugins/scanners/github-issues.py
@@ -127,6 +127,10 @@ def scan(KibbleBit, source):
         if creds and 'username' in creds:
             auth = (creds['username'], creds['password'])
     KibbleBit.pprint("Scanning for GitHub issues")
+    # Have we scanned before? If so, only do a 3 month scan here.
+    doneBefore = False
+    if source.get('steps') and source['steps'].get('issues'):
+        doneBefore = True
     source['steps']['issues'] = {
             'time': time.time(),
             'status': 'Issue scan started at ' + time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()),
@@ -135,7 +139,14 @@ def scan(KibbleBit, source):
         }
     KibbleBit.updateSource(source)
     try:
-        issues = plugins.utils.github.get_all(source, plugins.utils.github.issues,
+        if doneBefore:
+            since = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime(time.time() - (3*30*86400)))
+            KibbleBit.pprint("Fetching changes since %s" % since)
+            issues = plugins.utils.github.get_all(source, plugins.utils.github.issues,
+                                   params={'filter': 'all', 'state':'all', 'since': since},
+                                   auth=auth)
+        else:
+            issues = plugins.utils.github.get_all(source, plugins.utils.github.issues,
                                    params={'filter': 'all', 'state':'all'},
                                    auth=auth)
         KibbleBit.pprint("Fetched %s issues for %s" %(str(len(issues)), source['sourceURL']))