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
)
-
command:
ClassVar
[str
] = 'git'¶
- 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
-
outdated_dirs:
list
[str
] |None
¶
-
outdated_files:
list
[str
] |None
¶
-
source_details:
dict
[str
,str
|None
] |None
¶
- 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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- 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].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'source': FieldInfo(annotation=str, required=True, alias='source', alias_priority=1), 'source_branch': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='source-branch', alias_priority=1), 'source_commit': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='source-commit', alias_priority=1), 'source_depth': FieldInfo(annotation=int, required=False, default=0, alias='source-depth', alias_priority=1), 'source_submodules': FieldInfo(annotation=Union[list[str], NoneType], required=False, default=None, alias='source-submodules', alias_priority=1), 'source_tag': FieldInfo(annotation=Union[str, NoneType], required=False, default=None, alias='source-tag', alias_priority=1), 'source_type': FieldInfo(annotation=Literal['git'], required=False, default='git', alias='source-type', alias_priority=1)}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
-
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'
]¶