commit:     9a4cbee8916bebb51ad771a8e05e675b3b3a68b7
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  2 20:53:19 2021 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Sat Oct  2 20:53:19 2021 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=9a4cbee8

Use gitpython instead of pygit2

Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>

 buildbot_gentoo_ci/steps/repos.py | 37 +++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/buildbot_gentoo_ci/steps/repos.py 
b/buildbot_gentoo_ci/steps/repos.py
index 5b6b621..a2d46ce 100644
--- a/buildbot_gentoo_ci/steps/repos.py
+++ b/buildbot_gentoo_ci/steps/repos.py
@@ -2,7 +2,7 @@
 # Distributed under the terms of the GNU General Public License v2
 
 import os
-import pygit2
+import git
 
 from twisted.internet import defer
 
@@ -104,20 +104,31 @@ class CheckRepository(BuildStep):
 
     @defer.inlineCallbacks
     def checkRepos(self, repository_data):
+        success = False
         repository_path = yield 
os.path.join(self.getProperty("repository_basedir"), repository_data['name'])
-        repo_path = yield pygit2.discover_repository(repository_path)
-        print(repo_path)
-        if repo_path is None:
-            yield pygit2.clone_repository(repository_data['url'], 
repository_path)
-            success = True
+        try:
+            repo = git.Repo(repository_path)
+        except:
+            try:
+                yield git.Repo.clone_from(repository_data['url'], 
repository_path)
+            except:
+                pass
+            else:
+                repo = git.Repo(repository_path)
+                success = True
         else:
-            repo = yield pygit2.Repository(repo_path)
-            commit = repo.get(repo.head.target)
-            success = yield self.gitPull(repo)
-            print(commit.hex)
-            print(commit.commit_time)
+            try:
+                yield repo.git.pull()
+            except:
+                pass
+            else:
+                success = True
+        if success:
+            headcommit = repo.head.commit
+            print(headcommit.hexsha)
+            print(headcommit.committed_date)
         # chmod needed for ebuilds metadata portage.GetAuxMetadata step
-        yield self.setchmod(repository_path)
+        # yield self.setchmod(repository_path)
         return success
 
     @defer.inlineCallbacks
@@ -140,8 +151,6 @@ class CheckRepository(BuildStep):
         if Poller_data['updated_at'] > self.getProperty("commit_time"):
             return SKIPPED
         success = yield self.checkRepos(repository_data)
-        if success is None:
-            return SKIPPED
         if not success:
             return FAILURE
         if repository_data['type'] == 'gitpuller':

Reply via email to