From dcfc91ce13b1e4d87de7375cfd63fdfb4ea574e4 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Thu, 2 May 2024 12:00:51 +0300 Subject: [PATCH] tarball: Implement checkout for specific commit We often need not ToT, but specific commit, implement this. Signed-off-by: Denys Fedoryshchenko --- src/tarball.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/tarball.py b/src/tarball.py index b49eb1769..80d84c334 100755 --- a/src/tarball.py +++ b/src/tarball.py @@ -58,6 +58,21 @@ def _find_build_config(self, node): if config.tree.name == tree and config.branch == branch: return config + def _find_build_commit(self, node): + revision = node['data'].get('kernel_revision') + commit = revision.get('commit') + return commit + + def _checkout_commitid(self, commitid): + self.log.info(f"Checking out commit {commitid}") + # i might need something from kernelci.build + # but i prefer to implement it myself + cwd = os.getcwd() + os.chdir(self._service_config.kdir) + kernelci.shell_cmd(f"git checkout {commitid}", self._service_config.kdir) + os.chdir(cwd) + self.log.info("Commit checked out") + def _update_repo(self, config): ''' Return True - if failed to update repo and need to retry @@ -185,6 +200,15 @@ def _run(self, sub_id): 'Failed to init/update git repo') os._exit(1) + commitid = self._find_build_commit(checkout_node) + if commitid is None: + self.log.error("Failed to find commit id") + self._update_failed_checkout_node(checkout_node, + 'git_checkout_failure', + 'Failed to find commit id') + os._exit(1) + self._checkout_commitid(commitid) + describe = kernelci.build.git_describe( build_config.tree.name, self._service_config.kdir )