9Helper scripts needed to run tools and checks on the validation.
10Mainly for git checkout and compilation.
13from subprocess
import check_call, check_output, CalledProcessError
22 "This script requires GitPython, please install it via `pip3 install --user GitPython"
27def get_basf2_repo_folder():
29 Return the folder name of the basf2 repository currently set up
31 git_repository_folder = os.getenv("BELLE2_LOCAL_DIR")
32 if not git_repository_folder:
33 raise ValueError(
"You need to setup basf2 first")
35 return git_repository_folder
38def get_basf2_repo(non_dirty_check=False):
40 Return a git repo object of the current basf2 repository
42 :param non_dirty_check: Check if the repo
is dirty
and issue a printed warning
if yes.
44 git_repository = get_basf2_repo_folder()
45 repo = Repo(git_repository)
48 if non_dirty_check
and repo.is_dirty():
50 "Your git repo is dirty! I can not guarantee for valid results..."
56def checkout_git_revision(revision, repo=None, use_stash=False):
58 Checkout the given revision in the basf2 repository.
59 ATTENTION: this does
not check
for dirty files etc.
61 :param revision: which revision to checkout
62 :param repo: basf2 repo object (
None will use the default basf2 repo)
65 repo = get_basf2_repo()
69 repo.git.checkout(revision)
74def compile_basf2(compile_options=None):
76 Compile basf2 with the given options
as list.
78 :param compile_options: List of cmd options given to scons.
80 if compile_options
is None:
83 git_repository_folder = get_basf2_repo_folder()
84 check_call([
"scons"] + compile_options, cwd=git_repository_folder)
87def run_basf2_validation(validation_options=None):
89 Run the basf2 validation.
90 :param validation_options: List of options given to the b2validation call.
92 git_repository_folder = get_basf2_repo_folder()
93 check_call(["b2validation"] + validation_options, cwd=git_repository_folder)
96def fix_root_command_line():
98 Fix for ROOT to give the command line options directly to python.
100 from ROOT
import PyConfig
102 PyConfig.IgnoreCommandLineOptions =
True
105def get_git_hashes_between(git_end_hash, git_start_hash):
107 Return list of git hashes between `git_end_hash` and `git_start_hash`
108 (but
not including them).
116 str(git_start_hash +
".." + git_end_hash),
117 "--pretty=format:%H",
124 except CalledProcessError:
125 basf2.B2FATAL(
"Error while receiving the git history.")