def _report_usage_dev_version(repo_path, stack_frame_depth): """ :param str repo_path: :param int stack_frame_depth: """ common.logger.warn("Access to development working tree: %s", repo_path) from returnn.util.basic import try_get_stack_frame frame = try_get_stack_frame(depth=stack_frame_depth + 1) if frame: from returnn.util.better_exchook import get_source_code, add_indent_lines src = get_source_code(filename=frame.f_code.co_filename, lineno=frame.f_lineno, module_globals=frame.f_globals) common.logger.warn(" Called from: %s:%i, code:\n%s", frame.f_code.co_filename, frame.f_lineno, add_indent_lines(" ", src.rstrip())) else: common.logger.warn( " (Could not get stack frame information from calling code.)") from returnn.util.basic import git_commit_date, git_commit_rev, git_is_dirty rev = git_commit_rev(git_dir=repo_path, length=_DefaultNumHashDigits) commit_date = git_commit_date(git_dir=repo_path) # like "20190202.154527" commit_date = commit_date.replace(".", "") version = "%s-%s" % (commit_date[:8], rev[:_MinNumHashDigits]) import_str = "v%s_%s" % (commit_date, rev) common.logger.warn(" Current version: %s (%s)", version, import_str) if git_is_dirty(git_dir=repo_path): common.logger.warn( " (Warning, code is dirty. Commit your recent changes.)")
def git_head_version(git_dir=_root_dir, long=False): """ :param str git_dir: :param bool long: see :func:`get_version_str` :rtype: str """ from returnn.util.basic import git_commit_date, git_commit_rev, git_is_dirty commit_date = git_commit_date(git_dir=git_dir) # like "20190202.154527" version = "1.%s" % commit_date # distutils.version.StrictVersion compatible if long: # Keep SemVer compatible. rev = git_commit_rev(git_dir=git_dir) version += "+git.%s" % rev if git_is_dirty(git_dir=git_dir): version += ".dirty" return version