31 @brief Generate git version file
32 @param s_workpath : workpath
34 s_git_version_file = os.path.join(s_workpath, GIT_VERSION_FILE_NAME)
36 log.info(
"Generating git version file %s", s_git_version_file)
37 if not os.path.exists(s_workpath):
40 log.info(
"Directory %s already exists", s_workpath)
41 repo = git.Repo(search_parent_directories=
True)
42 sha = repo.head.commit.hexsha
43 short_sha = repo.git.rev_parse(sha, short=8)
44 with open(s_git_version_file, mode=
"w", encoding=
"utf-8")
as f:
45 code_content = FILE_HEADER
46 code_content += f
"GIT_SHORT_SHA = '{short_sha}'\n"