-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix private repos and add filename support #36
base: master
Are you sure you want to change the base?
Conversation
3eab3cd
to
f04de36
Compare
b485e94
to
b2c3ae1
Compare
b2c3ae1
to
1b7af37
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick pass. We need some test coverage and commentary around the new code.
} | ||
Some(url) | ||
}, | ||
}) | ||
} | ||
|
||
fn filename(&self) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests pretty please.
match self { | ||
Repository::GitLab { repo_path, .. } => Some(format!( | ||
"npins-gitlab-{}.tar.gz", | ||
repo_path.split('/').last().unwrap().to_owned() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are our assurances that we can really unwrap here? Do we verify this while unserializing? Do we verify it (only?) during interactive modification of the JSON file?
|
||
Ok(ChannelHash { hash }) | ||
} | ||
} | ||
|
||
impl Pin { | ||
pub fn calc_filename(url: &url::Url) -> Result<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests please.
|
||
impl Pin { | ||
pub fn calc_filename(url: &url::Url) -> Result<String> { | ||
let name_parts = url.path_segments().unwrap().collect::<Vec<&str>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What makes us think it is safe to unwrap here?
I really dislike having to track the name in the pins JSON. Is there no way that we can solve this in Nix on the import side of things with a simple string substitution? |
I can try but I don't see how this will be fast |
Ah yes we have to do this in the Rust code because |
The idea is, would it be possible to generate the derivation name on the fly where required instead of having to store it in the pins file. |
I'm very sorry for this.
So essentially when using a private repos, the
sha1=
parameter was replaced by the private token rather than the private token being appended to the query params.This would have been an easy fix but that actually results in
&
being part of the derivation name which is invalid. This is why I now generate filenames for all the pins that are fetchurl'ed. Yay.