Skip to content

Commit

Permalink
tarball: Implement checkout for specific commit
Browse files Browse the repository at this point in the history
We often need not ToT, but specific commit, implement this.

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
  • Loading branch information
nuclearcat committed May 2, 2024
1 parent 0fbd272 commit dcfc91c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit dcfc91c

Please sign in to comment.