2 Helper scripts needed to run tools and checks on the validation.
3 Mainly for git checkout and compilation.
5 Author: The Belle II Collaboration
6 Contributors: Nils Braun, Thomas Hauth
9 from subprocess
import check_call, check_output, CalledProcessError
17 print(
"This script requires GitPython, please install it via `pip3 install --user GitPython")
23 Return the folder name of the basf2 repository currently set up
25 git_repository_folder = os.getenv(
"BELLE2_LOCAL_DIR")
26 if not git_repository_folder:
27 raise ValueError(
"You need to setup basf2 first")
29 return git_repository_folder
34 Return a git repo object of the current basf2 repository
36 :param non_dirty_check: Check if the repo is dirty and issue a printed warning if yes.
39 repo = Repo(git_repository)
42 if non_dirty_check
and repo.is_dirty():
43 basf2.B2WARNING(
"Your git repo is dirty! I can not guarantee for valid results...")
50 Checkout the given revision in the basf2 repository.
51 ATTENTION: this does not check for dirty files etc.
53 :param revision: which revision to checkout
54 :param repo: basf2 repo object (None will use the default basf2 repo)
61 repo.git.checkout(revision)
68 Compile basf2 with the given options as list.
70 :param compile_options: List of cmd options given to scons.
72 if compile_options
is None:
76 check_call([
"scons"] + compile_options, cwd=git_repository_folder)
81 Run the basf2 validation.
82 :param validation_options: List of options given to the b2validation call.
85 check_call([
"b2validation"] + validation_options, cwd=git_repository_folder)
90 Fix for ROOT to give the command line options directly to python.
92 from ROOT
import PyConfig
93 PyConfig.IgnoreCommandLineOptions =
True
98 Return list of git hashes between `git_end_hash` and `git_start_hash`
99 (but not including them).
102 git_hashs = check_output([
"git",
"log", str(git_start_hash +
".." + git_end_hash),
103 "--pretty=format:%H"]).decode(
"utf-8").split(
"\n")
105 except CalledProcessError:
106 basf2.B2FATAL(
"Error while receiving the git history.")