Skip to content

git-basetag.py: add a class to help identifying basetags for PRs

Mauro Carvalho Chehab requested to merge mchehab_kernel/media-ci:main into main

Git currently doesn't provide an internal mechanism to identify what baseline should be used when a pull request is received.

This causes patchwork integration to fail, as they may be against different branches/tags than the latest next or fixes branch.

The gitBaseTag class allow getting it quickly using standard git commands. It can be used inside media-ci with:

from git-basetag import gitBaseTag

git_base = gitBaseTag(verbose=0)
tags = git_base.get_all_tags(since=30)
tag = git_base.base_tag(tags, base_commit, final_commit)

Where verbose, since and final_commit being optional arguments.

since can be a number of days ago or a string in iso format, like 2024-08-01.

To make easier to use, the script also contains a main() method, allowing it to be used either standalone or included as a library.

When used standalone, it will give the tag from where the code was applied:

$ git-basetag.py HEAD~3
Base tag: refs/tags/v6.10

$ git-basetag.py maintainers-doc~3 maintainers-doc
Base tag: refs/tags/media/v6.13-1

$ contrib/git-basetag.py HEAD~ --since 2024-08-01
Base tag: refs/remotes/origin/mr_report

$ contrib/git-basetag.py HEAD~ --since 3
Base tag: refs/remotes/origin/mr_report

$ contrib/git-basetag.py HEAD~ --since 1
Can't find a tag that contains all indexes

Please notice that this only works if the files inside the tested branch weren't modified since the last commit at the tag.

Signed-off-by: Mauro Carvalho Chehab mchehab+huawei@kernel.org

Edited by Mauro Carvalho Chehab

Merge request reports

Loading