git-basetag.py: add a class to help identifying basetags for PRs
Git currently doesn't provide an internal mechanism to identify what baseline should be used when a pull request is received.
This causes the 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()
tag = git_base.base_tag(tags, base_commit, final_commit)
Where verbose and final_commit being optional arguments.
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
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