Skip to content

Commit 9ae74fc

Browse files
committed
chore: forbid branch and tag for git source
1 parent 12a1112 commit 9ae74fc

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

crates/pixi_manifest/src/build_system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ mod tests {
106106
"https://prefix.dev/pixi-build-backends",
107107
"https://prefix.dev/conda-forge",
108108
]
109-
source = { git = "https://github.com/conda-forge/numpy-feedstock" }
109+
source = { git = "https://github.com/conda-forge/numpy-feedstock", rev ="ee87916a49d5e96d4f322f68c3650e8ff6b8866b" }
110110
"#;
111111

112112
let build = PackageBuild::from_toml_str(toml).unwrap();

crates/pixi_manifest/src/toml/build_backend.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ static BOTH_ADDITIONAL_DEPS_WARNING: Once = Once::new();
169169
fn spec_from_spanned_toml_location(
170170
spanned_toml: Spanned<TomlLocationSpec>,
171171
) -> Result<SourceLocationSpec, DeserError> {
172-
spanned_toml
172+
let source_location_spec = spanned_toml
173173
.value
174174
.into_source_location_spec()
175175
.map_err(|err| {
@@ -178,7 +178,24 @@ fn spec_from_spanned_toml_location(
178178
span: spanned_toml.span,
179179
line_info: None,
180180
})
181-
})
181+
})?;
182+
183+
// For build sources, require explicit rev for git sources to
184+
// ensure reproducible builds Should be removed once we will be
185+
// able to store source revision in lockfile.
186+
if let SourceLocationSpec::Git(ref git_spec) = source_location_spec {
187+
if git_spec.rev.is_none() {
188+
return Err(DeserError::from(Error {
189+
kind: toml_span::ErrorKind::Custom(Cow::Borrowed(
190+
"Git sources in build context require an explicit `rev` field for reproducible builds",
191+
)),
192+
span: spanned_toml.span,
193+
line_info: None,
194+
}));
195+
}
196+
}
197+
198+
Ok(source_location_spec)
182199
}
183200

184201
impl<'de> toml_span::Deserialize<'de> for TomlPackageBuild {

docs/reference/pixi_manifest.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -955,8 +955,6 @@ The build system is a table that can contain the following fields:
955955
- `path`: a string representing a relative or absolute path to the source code.
956956
- `git`: a string representing URL to the source repository.
957957
- `rev`: a string representing SHA revision to checkout.
958-
- `tag`: a string representing git tag to use.
959-
- `branch`: a string representing git branch to use.
960958
- `subdirectory`: a string representing path to subdirectory to use.
961959
- `channels`: specifies the channels to get the build backend from.
962960
- `backend`: specifies the build backend to use. This is a table that can contain the following fields:

schema/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,8 +715,8 @@ class SourceLocation(StrictBaseModel):
715715

716716
git: NonEmptyStr | None = Field(None, description="The git URL to the source repo")
717717
rev: NonEmptyStr | None = Field(None, description="A git SHA revision to use")
718-
tag: NonEmptyStr | None = Field(None, description="A git tag to use")
719-
branch: NonEmptyStr | None = Field(None, description="A git branch to use")
718+
# tag: NonEmptyStr | None = Field(None, description="A git tag to use")
719+
# branch: NonEmptyStr | None = Field(None, description="A git branch to use")
720720
subdirectory: NonEmptyStr | None = Field(None, description="A subdirectory to use in the repo")
721721

722722

schema/schema.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,12 +1707,6 @@
17071707
"type": "object",
17081708
"additionalProperties": false,
17091709
"properties": {
1710-
"branch": {
1711-
"title": "Branch",
1712-
"description": "A git branch to use",
1713-
"type": "string",
1714-
"minLength": 1
1715-
},
17161710
"git": {
17171711
"title": "Git",
17181712
"description": "The git URL to the source repo",
@@ -1736,12 +1730,6 @@
17361730
"description": "A subdirectory to use in the repo",
17371731
"type": "string",
17381732
"minLength": 1
1739-
},
1740-
"tag": {
1741-
"title": "Tag",
1742-
"description": "A git tag to use",
1743-
"type": "string",
1744-
"minLength": 1
17451733
}
17461734
}
17471735
},

0 commit comments

Comments
 (0)