craft_parts.sources.git_source module¶
Implement the git source handler.
- class craft_parts.sources.git_source.GitSource(source, part_src_dir, **kwargs)[source]¶
Bases:
SourceHandler
The git source handler.
Retrieve part sources from a git repository. Branch, depth, commit and tag can be specified using part properties
source-branch
,source-depth
, source-commit`,source-tag
, andsource-submodules
.- Parameters:
source (
str
)part_src_dir (
Path
)kwargs (
Any
)
- classmethod generate_version(*, part_src_dir=None)[source]¶
Return the latest git tag from PWD or defined part_src_dir.
The output depends on the use of annotated tags and will return something like: ‘2.28+git.10.abcdef’ where ‘2.28 is the tag, ‘+git’ indicates there are commits ahead of the tag, in this case it is ‘10’ and the latest commit hash begins with ‘abcdef’. If there are no tags or the revision cannot be determined, this will return 0 as the tag and only the commit hash of the latest commit.
- Parameters:
part_src_dir (
Optional
[Path
])- Return type:
str
- source_model¶
alias of
GitSourceModel
- class craft_parts.sources.git_source.GitSourceModel(**data)[source]¶
Bases:
BaseSourceModel
Pydantic model for a git-based source.
- Parameters:
data (
Any
)
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function get_model_config.<locals>.<lambda>>, 'extra': 'forbid', 'frozen': True, 'json_schema_extra': {'if': {'not': {'required': ['source-type']}}, 'then': {'properties': {'source': {'pattern': '(^git[+@:]|\\.git$)'}}}}}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- pattern: ClassVar[str | None] = '(^git(\\+.+:|[@:])|\\.git$)'¶
A regular expression for inferring this source type.
If pattern is None (the default), the source type cannot be inferred and must always be explicitly written in the source-type field of a part.
-
source:
str
¶
-
source_branch:
str
|None
¶
-
source_commit:
str
|None
¶
-
source_depth:
int
¶
-
source_submodules:
list
[str
] |None
¶
-
source_tag:
str
|None
¶
-
source_type:
Literal
['git'
]¶ The name of this source type.
Sources must define this with a type hint of a Literal type of its name and a value of its name.