mirror of
https://github.com/nix-community/nurl.git
synced 2024-10-26 20:19:56 +03:00
support fetchsvn
This commit is contained in:
parent
87f7c3c7bf
commit
2f0e9a71ed
@ -84,4 +84,5 @@ pub enum FetcherFunction {
|
||||
FetchFromSourcehut,
|
||||
Fetchgit,
|
||||
Fetchhg,
|
||||
Fetchsvn,
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ mod gitlab;
|
||||
mod hg;
|
||||
mod repo_or_cz;
|
||||
mod sourcehut;
|
||||
mod svn;
|
||||
|
||||
pub use bitbucket::FetchFromBitbucket;
|
||||
pub use git::Fetchgit;
|
||||
@ -17,6 +18,7 @@ pub use gitlab::FetchFromGitLab;
|
||||
pub use hg::Fetchhg;
|
||||
pub use repo_or_cz::FetchFromRepoOrCz;
|
||||
pub use sourcehut::FetchFromSourcehut;
|
||||
pub use svn::Fetchsvn;
|
||||
|
||||
use anyhow::Result;
|
||||
use enum_dispatch::enum_dispatch;
|
||||
@ -61,6 +63,7 @@ pub enum FetcherDispatch<'a> {
|
||||
FetchFromSourcehut(FetchFromSourcehut<'a>),
|
||||
Fetchgit(Fetchgit),
|
||||
Fetchhg(Fetchhg),
|
||||
Fetchsvn(Fetchsvn),
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
|
21
src/fetcher/svn.rs
Normal file
21
src/fetcher/svn.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use url::Url;
|
||||
|
||||
use crate::{
|
||||
impl_fetcher,
|
||||
simple::{SimpleFetcher, SimpleFodFetcher},
|
||||
};
|
||||
|
||||
pub struct Fetchsvn;
|
||||
impl_fetcher!(Fetchsvn);
|
||||
|
||||
impl<'a> SimpleFetcher<'a, 1> for Fetchsvn {
|
||||
const HASH_KEY: &'static str = "sha256";
|
||||
const KEYS: [&'static str; 1] = ["url"];
|
||||
const NAME: &'static str = "fetchsvn";
|
||||
|
||||
fn get_values(&self, url: &'a Url) -> Option<[&'a str; 1]> {
|
||||
Some([url.as_ref()])
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SimpleFodFetcher<'a, 1> for Fetchsvn {}
|
10
src/main.rs
10
src/main.rs
@ -15,6 +15,7 @@ use crate::{
|
||||
fetcher::{
|
||||
FetchFromBitbucket, FetchFromGitHub, FetchFromGitLab, FetchFromGitea, FetchFromGitiles,
|
||||
FetchFromRepoOrCz, FetchFromSourcehut, Fetcher, FetcherDispatch, Fetchgit, Fetchhg,
|
||||
Fetchsvn,
|
||||
},
|
||||
};
|
||||
|
||||
@ -26,7 +27,12 @@ fn main() -> Result<()> {
|
||||
if opts.list_fetchers || opts.list_possible_fetchers {
|
||||
let mut out = stdout().lock();
|
||||
for fetcher in FetcherFunction::value_variants() {
|
||||
if matches!(fetcher, FetcherFunction::Fetchhg) && opts.list_possible_fetchers {
|
||||
if opts.list_possible_fetchers
|
||||
&& matches!(
|
||||
fetcher,
|
||||
FetcherFunction::Fetchhg | FetcherFunction::Fetchsvn
|
||||
)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if let Some(fetcher) = fetcher.to_possible_value() {
|
||||
@ -100,6 +106,8 @@ fn main() -> Result<()> {
|
||||
(None | Some(FetcherFunction::Fetchgit), _) => Fetchgit.into(),
|
||||
|
||||
(Some(FetcherFunction::Fetchhg), _) => Fetchhg.into(),
|
||||
|
||||
(Some(FetcherFunction::Fetchsvn), _) => Fetchsvn.into(),
|
||||
};
|
||||
|
||||
let out = &mut stdout().lock();
|
||||
|
@ -10,6 +10,7 @@ use crate::prefetch::{flake_prefetch, fod_prefetch, url_prefetch};
|
||||
|
||||
pub trait SimpleFetcher<'a, const N: usize> {
|
||||
const HOST_KEY: &'static str = "domain";
|
||||
const HASH_KEY: &'static str = "hash";
|
||||
const KEYS: [&'static str; N];
|
||||
const NAME: &'static str;
|
||||
|
||||
@ -61,7 +62,8 @@ pub trait SimpleFetcher<'a, const N: usize> {
|
||||
|
||||
write!(
|
||||
expr,
|
||||
r#"rev="{rev}";hash="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";"#
|
||||
r#"rev="{rev}";{}="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";"#,
|
||||
Self::HASH_KEY,
|
||||
)?;
|
||||
|
||||
for (key, value) in args {
|
||||
@ -118,10 +120,10 @@ pub trait SimpleFetcher<'a, const N: usize> {
|
||||
} else {
|
||||
writeln!(out, r#"{indent} rev = "{rev}";"#)?;
|
||||
}
|
||||
if let Some(hash) = overwrites.remove("hash") {
|
||||
writeln!(out, "{indent} hash = {hash};")?;
|
||||
if let Some(hash) = overwrites.remove(Self::HASH_KEY) {
|
||||
writeln!(out, "{indent} {} = {hash};", Self::HASH_KEY)?;
|
||||
} else {
|
||||
writeln!(out, r#"{indent} hash = "{hash}";"#)?;
|
||||
writeln!(out, r#"{indent} {} = "{hash}";"#, Self::HASH_KEY)?;
|
||||
}
|
||||
|
||||
for (key, value) in args {
|
||||
@ -158,7 +160,7 @@ pub trait SimpleFetcher<'a, const N: usize> {
|
||||
) -> Result<()> {
|
||||
let mut fetcher_args = json!({
|
||||
"rev": rev,
|
||||
"hash": hash,
|
||||
Self::HASH_KEY: hash,
|
||||
});
|
||||
|
||||
if let Some(host) = self.host() {
|
||||
|
Loading…
Reference in New Issue
Block a user