diff options
author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2024-02-10 14:15:53 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-13 13:51:41 +0000 |
commit | 97eebe59d7ba9d7eb647a2f2a0353fc2424e9827 (patch) | |
tree | 796b53ae4bf83d08aa64721ceac2065780322c98 | |
parent | 9b5b62879979de3488c920f21ea358e72ff1e443 (diff) | |
download | poky-97eebe59d7ba9d7eb647a2f2a0353fc2424e9827.tar.gz |
oeqa/selftest/oelib/buildhistory: git default branch
On hosts with git defaulting to main branch the following exception
occures:
File .../buildhistory.py", line 99, in test_compare_dict_blobs_default
blob1 = self.repo.heads.master.commit.tree.blobs[0]
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/git/util.py", line 1114, in __getattr__
return list.__getattribute__(self, attr)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'IterableList' object has no attribute 'master'
Support main and master branch for these test cases.
Note: setting the default branch with --initial-branch requires git
version 2.28 or later. Some of the still supported host distros do not
provide this feature yet.
(From OE-Core rev: 7df99843d8f31d8e0c2872ff625f4a5abf28f740)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py index c3c15d83c0..042ccdd2b4 100644 --- a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py +++ b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | |||
@@ -30,6 +30,16 @@ class TestBlobParsing(OESelftestTestCase): | |||
30 | import shutil | 30 | import shutil |
31 | shutil.rmtree(self.repo_path) | 31 | shutil.rmtree(self.repo_path) |
32 | 32 | ||
33 | @property | ||
34 | def heads_default(self): | ||
35 | """ | ||
36 | Support repos defaulting to master or to main branch | ||
37 | """ | ||
38 | try: | ||
39 | return self.repo.heads.main | ||
40 | except AttributeError: | ||
41 | return self.repo.heads.master | ||
42 | |||
33 | def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"): | 43 | def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"): |
34 | if len(to_add) == 0 and len(to_remove) == 0: | 44 | if len(to_add) == 0 and len(to_remove) == 0: |
35 | return | 45 | return |
@@ -67,10 +77,10 @@ class TestBlobParsing(OESelftestTestCase): | |||
67 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} | 77 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} |
68 | 78 | ||
69 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) | 79 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) |
70 | blob1 = self.repo.heads.master.commit.tree.blobs[0] | 80 | blob1 = self.heads_default.commit.tree.blobs[0] |
71 | 81 | ||
72 | self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" }) | 82 | self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" }) |
73 | blob2 = self.repo.heads.master.commit.tree.blobs[0] | 83 | blob2 = self.heads_default.commit.tree.blobs[0] |
74 | 84 | ||
75 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), | 85 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), |
76 | blob1, blob2, False, False) | 86 | blob1, blob2, False, False) |
@@ -86,10 +96,10 @@ class TestBlobParsing(OESelftestTestCase): | |||
86 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} | 96 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} |
87 | 97 | ||
88 | self.commit_vars(to_add = { "foo" : "1" }) | 98 | self.commit_vars(to_add = { "foo" : "1" }) |
89 | blob1 = self.repo.heads.master.commit.tree.blobs[0] | 99 | blob1 = self.heads_default.commit.tree.blobs[0] |
90 | 100 | ||
91 | self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" }) | 101 | self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" }) |
92 | blob2 = self.repo.heads.master.commit.tree.blobs[0] | 102 | blob2 = self.heads_default.commit.tree.blobs[0] |
93 | 103 | ||
94 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), | 104 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), |
95 | blob1, blob2, False, False) | 105 | blob1, blob2, False, False) |