mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-26 03:56:30 +00:00
Add bitbucket module for generating url to Cargo.toml
This commit is contained in:
parent
cc537251fe
commit
3ca1c7b238
2 changed files with 21 additions and 0 deletions
17
src/interactors/bitbucket.rs
Normal file
17
src/interactors/bitbucket.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
use hyper::Uri;
|
||||||
|
use relative_path::RelativePathBuf;
|
||||||
|
|
||||||
|
use ::models::repo::RepoPath;
|
||||||
|
|
||||||
|
const BITBUCKET_USER_CONTENT_BASE_URI: &'static str = "https://bitbucket.org";
|
||||||
|
|
||||||
|
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, ::hyper::error::UriError> {
|
||||||
|
let path_str: &str = path.as_ref();
|
||||||
|
format!("{}/{}/{}/raw/master/{}",
|
||||||
|
BITBUCKET_USER_CONTENT_BASE_URI,
|
||||||
|
repo_path.qual.as_ref(),
|
||||||
|
repo_path.name.as_ref(),
|
||||||
|
path_str
|
||||||
|
).parse::<Uri>()
|
||||||
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use tokio_service::Service;
|
||||||
|
|
||||||
use ::models::repo::{RepoSite, RepoPath};
|
use ::models::repo::{RepoSite, RepoPath};
|
||||||
|
|
||||||
|
pub mod bitbucket;
|
||||||
pub mod crates;
|
pub mod crates;
|
||||||
pub mod github;
|
pub mod github;
|
||||||
pub mod gitlab;
|
pub mod gitlab;
|
||||||
|
@ -34,6 +35,9 @@ impl<S> Service for RetrieveFileAtPath<S>
|
||||||
&RepoSite::Gitlab => {
|
&RepoSite::Gitlab => {
|
||||||
gitlab::get_manifest_uri(&repo_path, &path)
|
gitlab::get_manifest_uri(&repo_path, &path)
|
||||||
},
|
},
|
||||||
|
&RepoSite::Bitbucket => {
|
||||||
|
bitbucket::get_manifest_uri(&repo_path, &path)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let uri_future = uri.into_future().from_err();
|
let uri_future = uri.into_future().from_err();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue