archive: Various Fixes
- When
git archiveerrors, do not require an exit code, but just use theExitStatuswe already have. This requires less unwrapping. Also, the previous default of 0 was misleading, since 0 is returned upon successful termination. - Use “refname” instead of “refspec” as these are different concepts. Refer to https://git-scm.com/docs/git-check-ref-format and in particular https://git-scm.com/docs/git-check-ref-format#Documentation/git-check-ref-format.txt---refspec-pattern.
- Only allow appending “.tar.gz” to commit IDs, not to refnames,
because refnames may contain the suffix “.tar.gz”. It might look
weird, but it is not forbidden to do
git branch foo.tar.gz. char::is_asciidoes not help sanitize refnames to file names. In particular we have'/'.is_ascii() == true. Use the full commit ID instead.
- When
git archiveerrors, do not require an exit code, but just use theExitStatuswe already have. This requires less unwrapping. Also, the previous default of 0 was misleading, since 0 is returned upon successful termination. - Use “refname” instead of “refspec” as these are different concepts. Refer to https://git-scm.com/docs/git-check-ref-format and in particular https://git-scm.com/docs/git-check-ref-format#Documentation/git-check-ref-format.txt---refspec-pattern.
- Only allow appending “.tar.gz” to commit IDs, not to refnames,
because refnames may contain the suffix “.tar.gz”. It might look
weird, but it is not forbidden to do
git branch foo.tar.gz. char::is_asciidoes not help sanitize refnames to file names. In particular we have'/'.is_ascii() == true. Use the full commit ID instead.
Bring back refname into filename after review.
Thanks @lorenz, patch looks pretty good to me, I got a few issues from clippy here that you maybe could fix?
> radicle-explorer@1.0.0 check:radicle-httpd
> cd radicle-httpd && cargo clippy --all --tests && cargo fmt --all --check
Compiling radicle-httpd v0.18.1 (/Users/sebastinez/Projects/radicle-explorer/radicle-httpd)
warning: this expression creates a reference which is immediately dereferenced by the compiler
--> src/raw.rs:127:22
|
127 | if Oid::from_str(&sha).is_err() {
| ^^^^ help: change this to: `sha`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
= note: `#[warn(clippy::needless_borrow)]` on by default
warning: calling `push_str()` using a single-character string literal
--> src/raw.rs:209:9
|
209 | build.push_str("-");
| ^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `build.push('-')`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
= note: `#[warn(clippy::single_char_add_str)]` on by default
warning: calling `push_str()` using a single-character string literal
--> src/raw.rs:215:13
|
215 | build.push_str("-");
| ^^^^^^^^^^^^^^^^^^^ help: consider using `push` with a character literal: `build.push('-')`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_char_add_str
Run clippy.