diff options
| author | Adrian Freihofer <adrian.freihofer@gmail.com> | 2024-02-21 20:37:01 +0100 |
|---|---|---|
| committer | Steve Sakoman <steve@sakoman.com> | 2024-03-01 05:19:54 -1000 |
| commit | 4f6135b3501514e187ca4877ed33004b5e3df5ed (patch) | |
| tree | b0c63e0efe1d541a64e79fbadf3acecac11819f5 | |
| parent | 054ac1ee853874a736c2187da7251f17a467dde2 (diff) | |
| download | poky-4f6135b3501514e187ca4877ed33004b5e3df5ed.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: 095598eb7c9aa64797c8a41255fa28b695398054)
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Cherry-picked from master: 7df99843d8f31d8e0c2872ff625f4a5abf28f740
Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
| -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 33bd6df2f3..ae12aa0865 100644 --- a/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py +++ b/meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | |||
| @@ -28,6 +28,16 @@ class TestBlobParsing(OESelftestTestCase): | |||
| 28 | import shutil | 28 | import shutil |
| 29 | shutil.rmtree(self.repo_path) | 29 | shutil.rmtree(self.repo_path) |
| 30 | 30 | ||
| 31 | @property | ||
| 32 | def heads_default(self): | ||
| 33 | """ | ||
| 34 | Support repos defaulting to master or to main branch | ||
| 35 | """ | ||
| 36 | try: | ||
| 37 | return self.repo.heads.main | ||
| 38 | except AttributeError: | ||
| 39 | return self.repo.heads.master | ||
| 40 | |||
| 31 | def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"): | 41 | def commit_vars(self, to_add={}, to_remove = [], msg="A commit message"): |
| 32 | if len(to_add) == 0 and len(to_remove) == 0: | 42 | if len(to_add) == 0 and len(to_remove) == 0: |
| 33 | return | 43 | return |
| @@ -65,10 +75,10 @@ class TestBlobParsing(OESelftestTestCase): | |||
| 65 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} | 75 | changesmap = { "foo-2" : ("2", "8"), "bar" : ("","4"), "bar-2" : ("","5")} |
| 66 | 76 | ||
| 67 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) | 77 | self.commit_vars(to_add = { "foo" : "1", "foo-2" : "2", "foo-3" : "3" }) |
| 68 | blob1 = self.repo.heads.master.commit.tree.blobs[0] | 78 | blob1 = self.heads_default.commit.tree.blobs[0] |
| 69 | 79 | ||
| 70 | self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" }) | 80 | self.commit_vars(to_add = { "foo-2" : "8", "bar" : "4", "bar-2" : "5" }) |
| 71 | blob2 = self.repo.heads.master.commit.tree.blobs[0] | 81 | blob2 = self.heads_default.commit.tree.blobs[0] |
| 72 | 82 | ||
| 73 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), | 83 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), |
| 74 | blob1, blob2, False, False) | 84 | blob1, blob2, False, False) |
| @@ -84,10 +94,10 @@ class TestBlobParsing(OESelftestTestCase): | |||
| 84 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} | 94 | defaultmap = { x : ("default", "1") for x in ["PKG", "PKGE", "PKGV", "PKGR"]} |
| 85 | 95 | ||
| 86 | self.commit_vars(to_add = { "foo" : "1" }) | 96 | self.commit_vars(to_add = { "foo" : "1" }) |
| 87 | blob1 = self.repo.heads.master.commit.tree.blobs[0] | 97 | blob1 = self.heads_default.commit.tree.blobs[0] |
| 88 | 98 | ||
| 89 | self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" }) | 99 | self.commit_vars(to_add = { "PKG" : "1", "PKGE" : "1", "PKGV" : "1", "PKGR" : "1" }) |
| 90 | blob2 = self.repo.heads.master.commit.tree.blobs[0] | 100 | blob2 = self.heads_default.commit.tree.blobs[0] |
| 91 | 101 | ||
| 92 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), | 102 | change_records = compare_dict_blobs(os.path.join(self.repo_path, self.test_file), |
| 93 | blob1, blob2, False, False) | 103 | blob1, blob2, False, False) |
