1 |
commit: 9a4cbee8916bebb51ad771a8e05e675b3b3a68b7 |
2 |
Author: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 2 20:53:19 2021 +0000 |
4 |
Commit: Magnus Granberg <zorry <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 2 20:53:19 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=9a4cbee8 |
7 |
|
8 |
Use gitpython instead of pygit2 |
9 |
|
10 |
Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org> |
11 |
|
12 |
buildbot_gentoo_ci/steps/repos.py | 37 +++++++++++++++++++++++-------------- |
13 |
1 file changed, 23 insertions(+), 14 deletions(-) |
14 |
|
15 |
diff --git a/buildbot_gentoo_ci/steps/repos.py b/buildbot_gentoo_ci/steps/repos.py |
16 |
index 5b6b621..a2d46ce 100644 |
17 |
--- a/buildbot_gentoo_ci/steps/repos.py |
18 |
+++ b/buildbot_gentoo_ci/steps/repos.py |
19 |
@@ -2,7 +2,7 @@ |
20 |
# Distributed under the terms of the GNU General Public License v2 |
21 |
|
22 |
import os |
23 |
-import pygit2 |
24 |
+import git |
25 |
|
26 |
from twisted.internet import defer |
27 |
|
28 |
@@ -104,20 +104,31 @@ class CheckRepository(BuildStep): |
29 |
|
30 |
@defer.inlineCallbacks |
31 |
def checkRepos(self, repository_data): |
32 |
+ success = False |
33 |
repository_path = yield os.path.join(self.getProperty("repository_basedir"), repository_data['name']) |
34 |
- repo_path = yield pygit2.discover_repository(repository_path) |
35 |
- print(repo_path) |
36 |
- if repo_path is None: |
37 |
- yield pygit2.clone_repository(repository_data['url'], repository_path) |
38 |
- success = True |
39 |
+ try: |
40 |
+ repo = git.Repo(repository_path) |
41 |
+ except: |
42 |
+ try: |
43 |
+ yield git.Repo.clone_from(repository_data['url'], repository_path) |
44 |
+ except: |
45 |
+ pass |
46 |
+ else: |
47 |
+ repo = git.Repo(repository_path) |
48 |
+ success = True |
49 |
else: |
50 |
- repo = yield pygit2.Repository(repo_path) |
51 |
- commit = repo.get(repo.head.target) |
52 |
- success = yield self.gitPull(repo) |
53 |
- print(commit.hex) |
54 |
- print(commit.commit_time) |
55 |
+ try: |
56 |
+ yield repo.git.pull() |
57 |
+ except: |
58 |
+ pass |
59 |
+ else: |
60 |
+ success = True |
61 |
+ if success: |
62 |
+ headcommit = repo.head.commit |
63 |
+ print(headcommit.hexsha) |
64 |
+ print(headcommit.committed_date) |
65 |
# chmod needed for ebuilds metadata portage.GetAuxMetadata step |
66 |
- yield self.setchmod(repository_path) |
67 |
+ # yield self.setchmod(repository_path) |
68 |
return success |
69 |
|
70 |
@defer.inlineCallbacks |
71 |
@@ -140,8 +151,6 @@ class CheckRepository(BuildStep): |
72 |
if Poller_data['updated_at'] > self.getProperty("commit_time"): |
73 |
return SKIPPED |
74 |
success = yield self.checkRepos(repository_data) |
75 |
- if success is None: |
76 |
- return SKIPPED |
77 |
if not success: |
78 |
return FAILURE |
79 |
if repository_data['type'] == 'gitpuller': |