mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-22 10:26:30 +00:00
Merge branch 'feature/add-gitlab' into feature/add-bitbucket
This commit is contained in:
commit
60b2e2096e
2 changed files with 6 additions and 5 deletions
|
@ -11,7 +11,7 @@ use ::models::repo::{Repository, RepoPath};
|
||||||
const GITHUB_API_BASE_URI: &'static str = "https://api.github.com";
|
const GITHUB_API_BASE_URI: &'static str = "https://api.github.com";
|
||||||
const GITHUB_USER_CONTENT_BASE_URI: &'static str = "https://raw.githubusercontent.com";
|
const GITHUB_USER_CONTENT_BASE_URI: &'static str = "https://raw.githubusercontent.com";
|
||||||
|
|
||||||
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, ::hyper::error::UriError> {
|
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, Error> {
|
||||||
let path_str: &str = path.as_ref();
|
let path_str: &str = path.as_ref();
|
||||||
Ok(format!("{}/{}/{}/HEAD/{}",
|
Ok(format!("{}/{}/{}/HEAD/{}",
|
||||||
GITHUB_USER_CONTENT_BASE_URI,
|
GITHUB_USER_CONTENT_BASE_URI,
|
||||||
|
|
|
@ -1,23 +1,24 @@
|
||||||
use hyper::Uri;
|
use hyper::Uri;
|
||||||
use relative_path::RelativePathBuf;
|
use relative_path::RelativePathBuf;
|
||||||
|
use failure::Error;
|
||||||
|
|
||||||
use ::models::repo::RepoPath;
|
use ::models::repo::RepoPath;
|
||||||
|
|
||||||
const GITLAB_USER_CONTENT_BASE_URI: &'static str = "https://gitlab.com";
|
const GITLAB_USER_CONTENT_BASE_URI: &'static str = "https://gitlab.com";
|
||||||
|
|
||||||
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, ::hyper::error::UriError> {
|
pub fn get_manifest_uri(repo_path: &RepoPath, path: &RelativePathBuf) -> Result<Uri, Error> {
|
||||||
let path_str: &str = path.as_ref();
|
let path_str: &str = path.as_ref();
|
||||||
// gitlab will return a 308 if the Uri ends with, say, `.../raw/master//Cargo.toml`, so make
|
// gitlab will return a 308 if the Uri ends with, say, `.../raw/HEAD//Cargo.toml`, so make
|
||||||
// sure that last slash isn't doubled
|
// sure that last slash isn't doubled
|
||||||
let slash_path = if path_str.starts_with("/") {
|
let slash_path = if path_str.starts_with("/") {
|
||||||
&path_str[1..]
|
&path_str[1..]
|
||||||
} else {
|
} else {
|
||||||
path_str
|
path_str
|
||||||
};
|
};
|
||||||
format!("{}/{}/{}/raw/master/{}",
|
Ok(format!("{}/{}/{}/raw/HEAD/{}",
|
||||||
GITLAB_USER_CONTENT_BASE_URI,
|
GITLAB_USER_CONTENT_BASE_URI,
|
||||||
repo_path.qual.as_ref(),
|
repo_path.qual.as_ref(),
|
||||||
repo_path.name.as_ref(),
|
repo_path.name.as_ref(),
|
||||||
slash_path
|
slash_path
|
||||||
).parse::<Uri>()
|
).parse::<Uri>()?)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue