Skip to content

Commit

Permalink
kernelci.build: get data for checkout fields
Browse files Browse the repository at this point in the history
Add methods to get git commit tags, git commit
message, and if the commit is at tip of the branch
for checkout node.

Signed-off-by: Jeny Sadadia <[email protected]>
  • Loading branch information
Jeny Sadadia committed Sep 23, 2024
1 parent 569ad5d commit ceda108
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions kernelci/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,56 @@ def git_describe_verbose(path):
return describe.strip()


def git_commit_tags(path, commit):
"""Get the git tags
*path* is the path to the local git repository
*commit* is the current checked out commit
Returns list of associated git tags if exist otherwise an
empty list.
"""
cmd = r"""
set -e
cd {path}
git tag --points-at {commit}
""".format(path=path, commit=commit)
tags = shell_cmd(cmd)
return tags if tags else []


def git_commit_message(path, commit):
"""Get the git commit message
*path* is the path to the local git repository
*commit* is the current checked out commit
Returns the git commit message consists of subject and body.
"""
cmd = r"""
set -e
cd {path}
git show -s --format=%B {commit}
""".format(path=path, commit=commit)
message = shell_cmd(cmd)
return message.strip()


def git_branch_tip(path, commit):
"""Get the git commit message
*path* is the path to the local git repository
*commit* is the current checked out commit
Returns `True`, when the commit being checked out is at the tip of
the branch at the moment of the checkout, otherwise `False`
"""
hc = head_commit(path)
if hc == commit:
return True
return False


def make_tarball(kdir, tarball_name):
"""Make a kernel source tarball
Expand Down

0 comments on commit ceda108

Please sign in to comment.