Skip to content

feat: pixi add git source dependency #2858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 25 commits into from
Jan 10, 2025
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
49592e5
feat: move cli params separatly
nichmor Jan 8, 2025
ece11c6
misc: remove funcs and add some docstrings
nichmor Jan 8, 2025
7cc3635
misc: remove unused dep
nichmor Jan 8, 2025
e79276f
Merge branch 'main' into feat/pixi-add-git-spec
nichmor Jan 8, 2025
c720898
misc: remove unused dep
nichmor Jan 8, 2025
1d75bb3
misc: add conflicts_with_all for GitRev
nichmor Jan 8, 2025
a66f5a6
misc: remove pixi_utils
nichmor Jan 8, 2025
f97bf3f
misc: update failing tests and snapshots
nichmor Jan 8, 2025
ae8160a
misc: add pypi implementation
nichmor Jan 9, 2025
a6b302d
misc: add cli docs
nichmor Jan 9, 2025
7608031
misc: add unit tests for vcs reqs
nichmor Jan 9, 2025
7933675
misc: fix conflict
nichmor Jan 9, 2025
bba2eea
misc: update snapshot
nichmor Jan 9, 2025
9575001
misc: make tests more stable by using only one platform
nichmor Jan 9, 2025
7afa629
misc: update snapshots
nichmor Jan 9, 2025
b355b86
misc: configure git user
nichmor Jan 10, 2025
e28e476
Merge branch 'main' into feat/pixi-add-git-spec
nichmor Jan 10, 2025
e0d4619
misc: use global configuration
nichmor Jan 10, 2025
735c8a6
Merge branch 'feat/pixi-add-git-spec' of github.com:nichmor/pixi into…
nichmor Jan 10, 2025
13b94fa
misc: add git user configuraiton for tests
nichmor Jan 10, 2025
c90d7d3
misc: comment out cred tests
nichmor Jan 10, 2025
3f6077f
misc: do not update lockfileupdate on lock
nichmor Jan 10, 2025
1d88d5d
misc: enable snapshot back
nichmor Jan 10, 2025
301abc2
Merge branch 'main' into feat/pixi-add-git-spec
nichmor Jan 10, 2025
373a1e9
misc: remove git configuration
nichmor Jan 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
misc: remove funcs and add some docstrings
  • Loading branch information
nichmor committed Jan 8, 2025
commit ece11c6db0cba642570dc796bde4b4b57953fb86
16 changes: 0 additions & 16 deletions crates/pixi_git/src/lib.rs
Original file line number Diff line number Diff line change
@@ -73,22 +73,6 @@ impl GitUrl {
pub fn precise(&self) -> Option<GitSha> {
self.precise
}

/// Determines if the given URL looks like a Git URL.
pub fn is_git_url(url: &Url) -> bool {
// Check if the scheme indicates it's a Git URL.
if url.scheme().starts_with("git+") {
// Check if the path ends with .git or has a Git-specific format.
return true;
} else if let Some(path) = url.path_segments() {
if path.clone().any(|segment| segment.ends_with(".git")) {
return true;
}
};

// If the URL doesn't match Git-specific patterns, return false.
false
}
}

impl TryFrom<Url> for GitUrl {
21 changes: 5 additions & 16 deletions crates/pixi_spec/src/lib.rs
Original file line number Diff line number Diff line change
@@ -20,7 +20,6 @@ pub use detailed::DetailedSpec;
pub use git::{GitSpec, Reference};
use itertools::Either;
pub use path::{PathBinarySpec, PathSourceSpec, PathSpec};
use pixi_git::GitUrl;
use rattler_conda_types::{
ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, ParseChannelError, VersionSpec,
};
@@ -103,21 +102,11 @@ impl PixiSpec {
channel_config: &ChannelConfig,
) -> Self {
if let Some(url) = spec.url {
// check if it is a git url
if GitUrl::is_git_url(&url) {
let git_url = GitUrl::try_from(url.clone()).unwrap();
Self::Git(GitSpec {
git: git_url.repository().clone(),
rev: Some(git_url.reference().clone().into()),
subdirectory: spec.subdir,
})
} else {
Self::Url(UrlSpec {
url,
md5: spec.md5,
sha256: spec.sha256,
})
}
Self::Url(UrlSpec {
url,
md5: spec.md5,
sha256: spec.sha256,
})
} else if spec.build.is_none()
&& spec.build_number.is_none()
&& spec.file_name.is_none()
4 changes: 2 additions & 2 deletions src/cli/add.rs
Original file line number Diff line number Diff line change
@@ -102,8 +102,8 @@ pub async fn execute(args: Args) -> miette::Result<()> {

let (match_specs, source_specs, pypi_deps) = match dependency_config.dependency_type() {
DependencyType::CondaDependency(spec_type) => {
// now if user passed some git configuration
// we will use it to create pixi specs
// if user passed some git configuration
// we will use it to create pixi source specs
let passed_specs: IndexMap<PackageName, (MatchSpec, SpecType)> = dependency_config
.specs()?
.into_iter()
4 changes: 4 additions & 0 deletions src/cli/cli_config.rs
Original file line number Diff line number Diff line change
@@ -148,20 +148,24 @@ pub struct GitRev {
}

impl GitRev {
/// Create a new `GitRev`
pub fn new() -> Self {
Default::default()
}

/// Set the branch
pub fn with_branch(mut self, branch: String) -> GitRev {
self.branch = Some(branch);
self
}

/// Set the revision
pub fn with_rev(mut self, rev: String) -> GitRev {
self.rev = Some(rev);
self
}

/// Set the tag
pub fn with_tag(mut self, tag: String) -> GitRev {
self.tag = Some(tag);
self