Changes Made
When trying to use the CLI with the foolowing remote url configured (as the only remote): git@codeberg.org:piotr-ginal/forgejo-cli.git
I got the following error:
$ fj --host codeberg.org repo view
Error: relative URL without a base
Location:
src/repo.rs:136:43
The same remote (same repo etc) but with cli compiled on ade375d23c
$ ./target/release/fj --host codeberg.org repo view
keys file not found, creating
piotr-ginal/forgejo-cli
Fork of forgejo-contrib/forgejo-cli
The problem causing this was introduced in 1df2ad5b01 #462
git show 1df2ad5b01f3fec5786b81f51dd7751b3ad768a1 -- src/main.rs
fn ssh_url_parse(s: &str) -> Result<url::Url, url::ParseError> {
- url::Url::parse(s).or_else(|_| {
+ let mut url = url::Url::parse(s)?;
+ if url.cannot_be_a_base() {
let mut new_s = String::new();
new_s.push_str("ssh://");
let auth_end = s.find("@").unwrap_or(0);
new_s.push_str(&s[..auth_end]);
new_s.push_str(&s[auth_end..].replacen(":", "/", 1));
- url::Url::parse(&new_s)
- })
+ url = url::Url::parse(&new_s)?
+ }
The scp-like syntax (user@host:path) fails Url::parse outright with a parse error, so it never reaches the cannot_be_a_base() check.
@tpikonen Am i missing something here?
Also, ive written two simple test cases showing this bug, feel free to check out at the commit adding the test and run cargo test to see for yourself.
As these would be the only tests in this repo, just let me know and ill drop the commit from the PR
Code of Conduct
- I agree to act in accordance with the CoC & AI Agreement.
- This contribution was not generated by an LLM, even in part.