-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): remove hardcoded git domains (#244)
- Loading branch information
Showing
7 changed files
with
88 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ select from. Dependencies specified with a custom URL do not use the version req | |
#### ZIP file | ||
|
||
```bash | ||
[forge] soldeer install <NAME>~<VERSION> <ZIP_URL> | ||
[forge] soldeer install <NAME>~<VERSION> --url <ZIP_URL> | ||
``` | ||
|
||
If the URL to a ZIP file is provided, the registry is not used and the file is downloaded from the URL directly. Note | ||
|
@@ -72,32 +72,31 @@ that a version must still be provided, but it can be freely chosen. | |
#### Git Repository | ||
|
||
```bash | ||
[forge] soldeer install <NAME>~<VERSION> <GIT_URL> | ||
[forge] soldeer install <NAME>~<VERSION> --git <GIT_URL> | ||
``` | ||
|
||
If the URL to a git repository is provided (at the moment, only `github.com` and `gitlab.com` are supported, and the URL | ||
must end with `.git`), then the repository will be cloned into the `dependencies` folder with the `git` CLI available | ||
on the system. HTTPS and SSH-style URLs are supported (see examples below). | ||
If the URL to a git repository is provided, then the repository will be cloned into the `dependencies` folder with the | ||
`git` CLI available on the system. HTTPS and SSH-style URLs are supported (see examples below). | ||
|
||
Cloning a specific identifier can be done with the `--rev <COMMIT>`, `--branch <BRANCH>` or `--tag <TAG>` arguments. If | ||
omitted, then the default branch is checked out. | ||
|
||
Some examples: | ||
|
||
```bash | ||
[forge] soldeer install test-project~v1 [email protected]:test/test.git | ||
[forge] soldeer install test-project~v1 [email protected]:test/test.git | ||
[forge] soldeer install test-project~v1 --git [email protected]:test/test.git | ||
[forge] soldeer install test-project~v1 --git [email protected]:test/test.git | ||
``` | ||
|
||
```bash | ||
[forge] soldeer install test-project~v1 https://github.com/test/test.git | ||
[forge] soldeer install test-project~v1 https://gitlab.com/test/test.git | ||
[forge] soldeer install test-project~v1 --git https://github.com/test/test.git | ||
[forge] soldeer install test-project~v1 --git https://gitlab.com/test/test.git | ||
``` | ||
|
||
```bash | ||
[forge] soldeer install test-project~v1 [email protected]:test/test.git --rev 345e611cd84bfb4e62c583fa1886c1928bc1a464 | ||
[forge] soldeer install test-project~v1 [email protected]:test/test.git --branch dev | ||
[forge] soldeer install test-project~v1 [email protected]:test/test.git --tag v1 | ||
[forge] soldeer install test-project~v1 --git [email protected]:test/test.git --rev 345e611cd84bfb4e62c583fa1886c1928bc1a464 | ||
[forge] soldeer install test-project~v1 --git [email protected]:test/test.git --branch dev | ||
[forge] soldeer install test-project~v1 --git [email protected]:test/test.git --tag v1 | ||
``` | ||
|
||
Note that a version must still be provided, but it can be freely chosen. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ use cliclack::{ | |
use soldeer_core::{ | ||
config::{ | ||
add_to_config, read_config_deps, read_soldeer_config, Dependency, GitIdentifier, Paths, | ||
UrlType, | ||
}, | ||
errors::{InstallError, LockError}, | ||
install::{ensure_dependencies_dir, install_dependencies, install_dependency, Progress}, | ||
|
@@ -28,11 +29,11 @@ If used with arguments, a dependency will be added to the configuration. When us | |
Examples: | ||
- Install all: soldeer install | ||
- Add from registry: soldeer install lib_name~2.3.0 | ||
- Add with custom URL: soldeer install lib_name~2.3.0 https://foo.bar/lib.zip | ||
- Add with git: soldeer install lib_name~2.3.0 [email protected]:foo/bar.git | ||
- Add with git (commit): soldeer install lib_name~2.3.0 [email protected]:foo/bar.git --rev 05f218fb6617932e56bf5388c3b389c3028a7b73 | ||
- Add with git (tag): soldeer install lib_name~2.3.0 [email protected]:foo/bar.git --tag v2.3.0 | ||
- Add with git (branch): soldeer install lib_name~2.3.0 [email protected]:foo/bar.git --branch feature/baz", | ||
- Add with custom URL: soldeer install lib_name~2.3.0 --url https://foo.bar/lib.zip | ||
- Add with git: soldeer install lib_name~2.3.0 --git [email protected]:foo/bar.git | ||
- Add with git (commit): soldeer install lib_name~2.3.0 --git [email protected]:foo/bar.git --rev 05f218fb6617932e56bf5388c3b389c3028a7b73 | ||
- Add with git (tag): soldeer install lib_name~2.3.0 --git [email protected]:foo/bar.git --tag v2.3.0 | ||
- Add with git (branch): soldeer install lib_name~2.3.0 --git [email protected]:foo/bar.git --branch feature/baz", | ||
after_help = "For more information, read the README.md" | ||
)] | ||
#[non_exhaustive] | ||
|
@@ -45,22 +46,26 @@ pub struct Install { | |
|
||
/// The URL to the dependency zip file. | ||
/// | ||
/// If not present, the package will be installed from the Soldeer repository. | ||
/// | ||
/// Example: https://my-domain/dep.zip | ||
#[arg(value_name = "URL", requires = "dependency")] | ||
pub remote_url: Option<String>, | ||
#[arg(long = "url", requires = "dependency", conflicts_with = "git_url")] | ||
pub zip_url: Option<String>, | ||
|
||
/// The URL to the dependency repository. | ||
/// | ||
/// Example: [email protected]:foo/bar.git | ||
#[arg(long = "git", requires = "dependency", conflicts_with = "zip_url")] | ||
pub git_url: Option<String>, | ||
|
||
/// A Git commit hash | ||
#[arg(long, group = "identifier", requires = "remote_url")] | ||
#[arg(long, group = "identifier", requires = "git_url")] | ||
pub rev: Option<String>, | ||
|
||
/// A Git tag | ||
#[arg(long, group = "identifier", requires = "remote_url")] | ||
#[arg(long, group = "identifier", requires = "git_url")] | ||
pub tag: Option<String>, | ||
|
||
/// A Git branch | ||
#[arg(long, group = "identifier", requires = "remote_url")] | ||
#[arg(long, group = "identifier", requires = "git_url")] | ||
pub branch: Option<String>, | ||
|
||
/// If set, this command will delete the existing remappings and re-create them | ||
|
@@ -140,7 +145,8 @@ pub(crate) async fn install_command(paths: &Paths, cmd: Install) -> Result<()> { | |
(None, None, None) => None, | ||
_ => unreachable!("clap should prevent this"), | ||
}; | ||
let mut dep = Dependency::from_name_version(&dependency, cmd.remote_url, identifier)?; | ||
let url = cmd.zip_url.map(UrlType::http).or(cmd.git_url.map(UrlType::git)); | ||
let mut dep = Dependency::from_name_version(&dependency, url, identifier)?; | ||
if dependencies | ||
.iter() | ||
.any(|d| d.name() == dep.name() && d.version_req() == dep.version_req()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.