gitversioned.versioning.entrypoints¶
Primary entry points for dynamic version resolution.
Provides high-level functions to resolve PEP 440 versions from Git repository state, format the version string based on configured templates, and write the output to target files or system streams.
resolve_version(settings, repository=None, environment=None)
¶
Resolve the dynamic version from configured sources and apply formatting.
Queries the repository sources to obtain a base version, determines the build type (e.g., release or dev), applies auto-increment increments if configured, and formats the final PEP 440 version.
Example
from gitversioned.settings import Settings version, v_type, ref = resolve_version(Settings())
:param settings: Configuration settings governing version resolution. :param repository: Optional Git repository instance to query. :param environment: Optional build environment parameters. :return: A tuple containing the final normalized Version, the version type, and the GitReference used for resolution.
Source code in src/gitversioned/versioning/entrypoints.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
resolve_version_output(settings, repository=None, environment=None)
¶
Resolve the version and format the target output content.
Runs version resolution and then applies the configured output strategies to format the final string (e.g., for writing to a version file).
Example
from gitversioned.settings import Settings content, version, v_type, ref = resolve_version_output(Settings())
:param settings: Configuration settings governing output generation. :param repository: Optional Git repository instance to query. :param environment: Optional build environment parameters. :return: A tuple containing the formatted output content string, the resolved Version, the version type, and the GitReference.
Source code in src/gitversioned/versioning/entrypoints.py
resolve_version_output_to_stream(settings, repository=None, environment=None)
¶
Resolve the version and write formatted content to the configured output file path.
Resolves the dynamic version, formats it using the configured strategy, and writes the formatted content to the specified output file path. Creates parent directories for files if needed.
Example
from gitversioned.settings import Settings settings = Settings() res = resolve_version_output_to_stream(settings)
:param settings: Configuration settings governing output path and formatting. :param repository: Optional Git repository instance to query. :param environment: Optional build environment parameters. :return: A tuple containing the resolved output Path (or None if disabled), the formatted content, the Version, the version type, and the GitReference. :raises ValueError: If the configured output target cannot be written to.