Snapdiff - Use public git cache if local is not exists 77/175977/1 release-20180511 release-pylint accepted/tizen/devbase/services/20190930.043343 accepted/tizen/devbase/tools/20190927.045019 accepted/tizen/devbase/tools/20190930.094924 submit/devel/20190730.075508 submit/trunk/20190927.012743 submit/trunk/20190927.012842 submit/trunk/20190930.011717 submit/trunk/20190930.015214 submit/trunk/20191021.051025 submit/trunk/20191021.061922 submit/trunk/20191021.083710
authorhyokeun <hyokeun.jeon@samsung.com>
Mon, 16 Apr 2018 04:58:21 +0000 (13:58 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Mon, 16 Apr 2018 04:58:21 +0000 (13:58 +0900)
Change-Id: I204465c3786643a51a561bcc3f1b3731f8704d19

snapdiff/__init__.py

index 785ca8c..6501d2e 100644 (file)
@@ -74,8 +74,9 @@ def diff_to_json(old_url, new_url, **kwargs):
     added, removed, modified, rebuilded = [], [], [], []
     package_names = set(old.__dict__.keys() + new.__dict__.keys())
 
-    def _get_commit_log_delta(old_proj, new_proj, old_commit_id, new_commit_id):
-        cache_dir = os.getenv('GIT_CACHE_DIR')
+    def _get_commit_log_delta_internal(old_proj, new_proj, old_commit_id, new_commit_id, cache_dir):
+        if cache_dir is None:
+            cache_dir = os.getenv('GIT_CACHE_DIR')
         git_dir = os.path.join(cache_dir, new_proj)
         log_filename = 'git_log'
 
@@ -110,6 +111,17 @@ def diff_to_json(old_url, new_url, **kwargs):
         f.close()
         return data
 
+    def _get_commit_log_delta(old_proj, new_proj, old_commit_id, new_commit_id):
+        cache_dir = os.getenv('GIT_CACHE_DIR')
+        logs = _get_commit_log_delta_internal(old_proj, new_proj, old_commit_id, new_commit_id, cache_dir)
+        if not logs or len(logs) <= 0:
+            cache_dir_public = os.getenv('PUBLIC_GIT_CACHE_DIR')
+            if cache_dir_public is None or cache_dir == cache_dir_public:
+                return logs
+            logs2 = _get_commit_log_delta_internal(old_proj, new_proj, old_commit_id, new_commit_id, cache_dir_public)
+            return logs2
+        return logs
+
     def _get_git_web(url):
         matchdomain = re.match(r"http[s]?://[a-z0-9\.]*", url)
         if not matchdomain:
@@ -550,3 +562,4 @@ def diff_to_dist(old_url, new_url, dist_path, **kwargs):
     with io.open(os.path.join(dist_path, '%s.csv' % diff_name), 'w', encoding='utf-8', errors='ignore') as fname:
         fname.write(output)
     return dist_path
+