diff --git a/Cargo.lock b/Cargo.lock index 69797c7..4336b2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "anstream" -version = "0.6.4" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab91ebe16eb252986481c5b62f6098f3b698a45e34b5b98200cf20dd2484a44" +checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" dependencies = [ "anstyle", "anstyle-parse", @@ -39,30 +39,30 @@ checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317b9a89c1868f5ea6ff1d9539a69f45dffc21ce321ac1fd1160dfa48c8e2140" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0699d10d2f4d628a98ee7b57b289abbc98ff3bad977cb3152709d4bf2330628" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -145,9 +145,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2275f18819641850fa26c89acc84d465c1bf91ce57bc2748b28c420473352f64" +checksum = "bfaff671f6b22ca62406885ece523383b9b64022e341e53e009a62ebc47a45f2" dependencies = [ "clap_builder", "clap_derive", @@ -155,9 +155,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.8" +version = "4.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07cdf1b148b25c1e1f7a42225e30a0d99a615cd4637eae7365548dd4529b95bc" +checksum = "a216b506622bb1d316cd51328dce24e07bdff4a6128a47c7e7fad11878d5adbb" dependencies = [ "anstream", "anstyle", @@ -191,9 +191,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -201,15 +201,15 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "deranged" -version = "0.3.9" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3" +checksum = "8eb30d70a07a3b04884d2677f06bec33509dc67ca60d92949e5535352d3191dc" dependencies = [ "powerfmt", "serde", @@ -242,7 +242,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -262,19 +262,19 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f258a7194e7f7c2a7837a8913aeab7fd8c383457034fa20ce4dd3dcb813e8eb8" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "eyre" -version = "0.6.9" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80f656be11ddf91bd709454d15d5bd896fbaf4cc3314e69349e4d1569f5b46cd" +checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799" dependencies = [ "indenter", "once_cell", @@ -298,9 +298,11 @@ dependencies = [ "futures", "git2", "open", + "reqwest", "serde", "serde_json", "soft_assert", + "time", "tokio", "url", "uuid", @@ -330,10 +332,12 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "forgejo-api" version = "0.1.0" -source = "git+https://codeberg.org/Cyborus/forgejo-api.git?rev=cdb15605f6#cdb15605f60d22d161c5c79d834ee7b4113dc654" +source = "git+https://codeberg.org/Cyborus/forgejo-api.git?rev=86a4acc1ad#86a4acc1ad63a37f84d778fac8a3f610b85b0e9a" dependencies = [ + "bytes", "reqwest", "serde", + "serde_json", "soft_assert", "thiserror", "time", @@ -343,9 +347,9 @@ dependencies = [ [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -452,9 +456,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.28.0" +version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" [[package]] name = "git2" @@ -492,9 +496,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.14.2" +version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93e7192158dbcda357bdec5fb5788eebf8bbac027f3f33e719d29135ae84156" +checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" @@ -521,9 +525,9 @@ dependencies = [ [[package]] name = "http-body" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", "http", @@ -581,9 +585,9 @@ dependencies = [ [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -632,9 +636,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" +checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "jobserver" @@ -647,9 +651,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54c0c35952f67de54bb584e9fd912b3023117cbafc0a77d8f3dee1fb5f572fe8" +checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca" dependencies = [ "wasm-bindgen", ] @@ -662,9 +666,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.150" +version = "0.2.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" +checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4" [[package]] name = "libgit2-sys" @@ -719,9 +723,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.11" +version = "0.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "969488b55f8ac402214f3f5fd243ebb7206cf82de60d3172994707a4bcc2b829" +checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456" [[package]] name = "lock_api" @@ -751,6 +755,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4192263c238a5f0d0c6bfd21f336a313a4ce1c450542449ca191bb657b4642ef" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.7.1" @@ -762,13 +776,13 @@ dependencies = [ [[package]] name = "mio" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dce281c5e46beae905d4de1870d8b1509a9142b62eedf18b443b011ca8343d0" +checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09" dependencies = [ "libc", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -810,15 +824,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "open" -version = "5.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfabf1927dce4d6fdf563d63328a0a506101ced3ec780ca2135747336c98cef8" +checksum = "90878fb664448b54c4e592455ad02831e23a3f7e157374a8b95654731aac7349" dependencies = [ "is-wsl", "libc", @@ -827,9 +841,9 @@ dependencies = [ [[package]] name = "openssl" -version = "0.10.59" +version = "0.10.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a257ad03cd8fb16ad4172fedf8094451e1af1c4b70097636ef2eac9a5f0cc33" +checksum = "6b8419dc8cc6d866deb801274bba2e6f8f6108c1bb7fcc10ee5ab864931dbb45" dependencies = [ "bitflags 2.4.1", "cfg-if", @@ -859,9 +873,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.95" +version = "0.9.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40a4130519a360279579c2053038317e40eff64d13fd3f004f9e1b72b8a6aaf9" +checksum = "c3eaad34cdd97d81de97964fc7f29e2d104f483840d906ef56daa1912338460b" dependencies = [ "cc", "libc", @@ -895,7 +909,7 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -906,9 +920,9 @@ checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" @@ -936,9 +950,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -992,6 +1006,7 @@ dependencies = [ "js-sys", "log", "mime", + "mime_guess", "native-tls", "once_cell", "percent-encoding", @@ -1018,22 +1033,22 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" [[package]] name = "rustix" -version = "0.38.25" +version = "0.38.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc99bc2d4f1fed22595588a013687477aedf3cdcfb26558c559edb67b4d9b22e" +checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316" dependencies = [ "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] name = "ryu" -version = "1.0.15" +version = "1.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" +checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c" [[package]] name = "schannel" @@ -1041,7 +1056,7 @@ version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c3733bf4cf7ea0880754e19cb5a462007c4a8c1914bff372ccc95b464f1df88" dependencies = [ - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1075,18 +1090,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -1157,7 +1172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" dependencies = [ "libc", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1174,9 +1189,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269" dependencies = [ "proc-macro2", "quote", @@ -1214,7 +1229,7 @@ dependencies = [ "fastrand", "redox_syscall", "rustix", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1293,9 +1308,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.34.0" +version = "1.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" +checksum = "841d45b238a16291a4e1584e61820b8ae57d696cc5015c459c229ccc6990cc1c" dependencies = [ "backtrace", "bytes", @@ -1307,7 +1322,7 @@ dependencies = [ "signal-hook-registry", "socket2 0.5.5", "tokio-macros", - "windows-sys", + "windows-sys 0.48.0", ] [[package]] @@ -1372,15 +1387,24 @@ dependencies = [ [[package]] name = "try-lock" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] [[package]] name = "unicode-bidi" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" +checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416" [[package]] name = "unicode-ident" @@ -1399,9 +1423,9 @@ dependencies = [ [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", @@ -1417,9 +1441,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "uuid" -version = "1.5.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" +checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560" dependencies = [ "getrandom", ] @@ -1430,6 +1454,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "want" version = "0.3.1" @@ -1447,9 +1477,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7daec296f25a1bae309c0cd5c29c4b260e510e6d813c286b19eaadf409d40fce" +checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1457,9 +1487,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e397f4664c0e4e428e8313a469aaa58310d302159845980fd23b0f22a847f217" +checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826" dependencies = [ "bumpalo", "log", @@ -1472,9 +1502,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.38" +version = "0.4.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" +checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12" dependencies = [ "cfg-if", "js-sys", @@ -1484,9 +1514,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5961017b3b08ad5f3fe39f1e79877f8ee7c23c5e5fd5eb80de95abc41f1f16b2" +checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1494,9 +1524,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5353b8dab669f5e10f5bd76df26a9360c748f054f862ff5f3f8aae0c7fb3907" +checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283" dependencies = [ "proc-macro2", "quote", @@ -1507,15 +1537,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.88" +version = "0.2.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d046c5d029ba91a1ed14da14dca44b68bf2f124cfbaf741c54151fdb3e0750b" +checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f" [[package]] name = "web-sys" -version = "0.3.65" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" +checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f" dependencies = [ "js-sys", "wasm-bindgen", @@ -1549,7 +1579,16 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", ] [[package]] @@ -1558,13 +1597,28 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", ] [[package]] @@ -1573,42 +1627,84 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" + [[package]] name = "winreg" version = "0.50.0" @@ -1616,5 +1712,5 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1" dependencies = [ "cfg-if", - "windows-sys", + "windows-sys 0.48.0", ] diff --git a/Cargo.toml b/Cargo.toml index a6113ec..b2d2ea6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,13 +10,15 @@ auth-git2 = "0.5.3" clap = { version = "4.3.11", features = ["derive"] } directories = "5.0.1" eyre = "0.6.8" -forgejo-api = { git = "https://codeberg.org/Cyborus/forgejo-api.git", rev = "cdb15605f6" } +forgejo-api = { git = "https://codeberg.org/Cyborus/forgejo-api.git", rev = "86a4acc1ad" } futures = "0.3.28" git2 = "0.17.2" open = "5.0.0" +reqwest = "0.11.22" serde = { version = "1.0.170", features = ["derive"] } serde_json = "1.0.100" soft_assert = "0.1.1" +time = { version = "0.3.30", features = ["formatting"] } tokio = { version = "1.29.1", features = ["full"] } url = "2.4.0" uuid = { version = "1.5.0", features = ["v4"] } diff --git a/src/main.rs b/src/main.rs index ca6b624..db4fe20 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use keys::*; mod auth; mod issues; +mod release; mod repo; #[derive(Parser, Debug)] @@ -30,6 +31,8 @@ pub enum Command { }, #[clap(subcommand)] Auth(auth::AuthCommand), + #[clap(subcommand)] + Release(release::ReleaseCommand), } #[tokio::main] @@ -37,21 +40,21 @@ async fn main() -> eyre::Result<()> { let args = App::parse(); let mut keys = KeyInfo::load().await?; + let remote_name = args.remote.as_deref(); match args.command { - Command::Repo(subcommand) => subcommand.run(&keys, args.remote.as_deref()).await?, - Command::Issue(subcommand) => subcommand.run(&keys, args.remote.as_deref()).await?, + Command::Repo(subcommand) => subcommand.run(&keys, remote_name).await?, + Command::Issue(subcommand) => subcommand.run(&keys, remote_name).await?, Command::User { host } => { let host = host.map(|host| Url::parse(&host)).transpose()?; let url = match host { Some(url) => url, - None => repo::RepoInfo::get_current(args.remote.as_deref())? - .url() - .clone(), + None => repo::RepoInfo::get_current(remote_name)?.url().clone(), }; let name = keys.get_login(&url)?.username(); eprintln!("currently signed in to {name}@{url}"); } Command::Auth(subcommand) => subcommand.run(&mut keys).await?, + Command::Release(subcommand) => subcommand.run(&mut keys, remote_name).await?, } keys.save().await?; diff --git a/src/release.rs b/src/release.rs new file mode 100644 index 0000000..f2ed7f2 --- /dev/null +++ b/src/release.rs @@ -0,0 +1,461 @@ +use clap::Subcommand; +use eyre::{bail, eyre}; +use forgejo_api::Forgejo; +use tokio::io::AsyncWriteExt; + +use crate::{keys::KeyInfo, repo::RepoInfo}; + +#[derive(Subcommand, Clone, Debug)] +pub enum ReleaseCommand { + Create { + name: String, + #[clap(long, short = 'T')] + /// Create a new cooresponding tag for this release. Defaults to release's name. + create_tag: Option>, + #[clap(long, short = 't')] + /// Pre-existing tag to use + /// + /// If you need to create a new tag for this release, use `--create-tag` + tag: Option, + #[clap( + long, + short, + help = "Include a file as an attachment", + long_help = "Include a file as an attachment + +`--attach=` will set the attachment's name to the file name +`--attach=:` will use the provided name for the attachment" + )] + attach: Vec, + #[clap(long, short)] + /// Text of the release body. + /// + /// Using this flag without an argument will open your editor. + body: Option>, + #[clap(long, short = 'B')] + branch: Option, + #[clap(long, short)] + draft: bool, + #[clap(long, short)] + prerelease: bool, + }, + Edit { + name: String, + #[clap(long, short = 'n')] + rename: Option, + #[clap(long, short = 't')] + /// Corresponding tag for this release. + tag: Option, + #[clap(long, short)] + /// Text of the release body. + /// + /// Using this flag without an argument will open your editor. + body: Option>, + #[clap(long, short)] + draft: Option, + #[clap(long, short)] + prerelease: Option, + }, + Delete { + name: String, + #[clap(long, short = 't')] + by_tag: bool, + }, + List { + #[clap(long, short = 'p')] + include_prerelease: bool, + #[clap(long, short = 'd')] + include_draft: bool, + }, + View { + name: String, + #[clap(long, short = 't')] + by_tag: bool, + }, + Browse { + name: Option, + }, + #[clap(subcommand)] + Asset(AssetCommand), +} + +#[derive(Subcommand, Clone, Debug)] +pub enum AssetCommand { + Create { + release: String, + path: std::path::PathBuf, + name: Option, + }, + Delete { + release: String, + asset: String, + }, + Download { + release: String, + asset: String, + #[clap(long, short)] + output: Option, + }, +} + +impl ReleaseCommand { + pub async fn run(self, keys: &KeyInfo, remote_name: Option<&str>) -> eyre::Result<()> { + let repo = RepoInfo::get_current(remote_name)?; + let api = keys.get_api(&repo.host_url())?; + match self { + Self::Create { + name, + create_tag, + tag, + attach, + body, + branch, + draft, + prerelease, + } => { + create_release( + &repo, &api, name, create_tag, tag, attach, body, branch, draft, prerelease, + ) + .await? + } + Self::Edit { + name, + rename, + tag, + body, + draft, + prerelease, + } => edit_release(&repo, &api, name, rename, tag, body, draft, prerelease).await?, + Self::Delete { name, by_tag } => delete_release(&repo, &api, name, by_tag).await?, + Self::List { + include_prerelease, + include_draft, + } => list_releases(&repo, &api, include_prerelease, include_draft).await?, + Self::View { name, by_tag } => view_release(&repo, &api, name, by_tag).await?, + Self::Browse { name } => browse_release(&repo, &api, name).await?, + Self::Asset(subcommand) => match subcommand { + AssetCommand::Create { + release, + path, + name, + } => create_asset(&repo, &api, release, path, name).await?, + AssetCommand::Delete { release, asset } => { + delete_asset(&repo, &api, release, asset ).await? + } + AssetCommand::Download { + release, + asset, + output, + } => download_asset(&repo, &api, release, asset, output).await?, + }, + } + Ok(()) + } +} + +async fn create_release( + repo: &RepoInfo, + api: &Forgejo, + name: String, + create_tag: Option>, + tag: Option, + attachments: Vec, + body: Option>, + branch: Option, + draft: bool, + prerelease: bool, +) -> eyre::Result<()> { + let tag_name = match (tag, create_tag) { + (None, None) => bail!("must select tag with `--tag` or `--create-tag`"), + (Some(tag), None) => tag, + (None, Some(tag)) => { + let tag = tag.unwrap_or_else(|| name.clone()); + let opt = forgejo_api::CreateTagOption { + message: None, + tag_name: tag.clone(), + target: branch, + }; + api.create_tag(repo.owner(), repo.name(), opt).await?; + tag + } + (Some(_), Some(_)) => { + bail!("`--tag` and `--create-tag` are mutually exclusive; please pick just one") + } + }; + + let body = match body { + Some(Some(body)) => body, + Some(None) => { + let mut s = String::new(); + crate::editor(&mut s, Some("md")).await?; + s + } + None => String::new(), + }; + + let release_opt = forgejo_api::CreateReleaseOption { + body, + draft, + name, + prerelease, + tag_name, + target_commitish: None, + }; + let release = api + .create_release(repo.owner(), repo.name(), release_opt) + .await?; + + for attachment in attachments { + let (file, asset) = match attachment.split_once(':') { + Some((file, asset)) => (std::path::Path::new(file), asset), + None => { + let file = std::path::Path::new(&attachment); + let asset = file + .file_name() + .ok_or_else(|| eyre!("{attachment} does not have a file name"))? + .to_str() + .unwrap(); + (file, asset) + } + }; + api.create_release_attachment( + repo.owner(), + repo.name(), + release.id, + asset, + tokio::fs::read(file).await?, + ) + .await?; + } + + Ok(()) +} + +async fn edit_release( + repo: &RepoInfo, + api: &Forgejo, + name: String, + rename: Option, + tag: Option, + body: Option>, + draft: Option, + prerelease: Option, +) -> eyre::Result<()> { + let release = find_release(repo, api, &name).await?; + let body = match body { + Some(Some(body)) => Some(body), + Some(None) => { + let mut s = release.body.clone(); + crate::editor(&mut s, Some("md")).await?; + Some(s) + } + None => None, + }; + let release_edit = forgejo_api::EditReleaseOption { + name: rename, + tag_name: tag, + body, + draft, + prerelease, + target_commitish: None, + }; + api.edit_release(repo.owner(), repo.name(), release.id, release_edit) + .await?; + Ok(()) +} + +async fn list_releases( + repo: &RepoInfo, + api: &Forgejo, + prerelease: bool, + draft: bool, +) -> eyre::Result<()> { + let query = forgejo_api::ReleaseQuery { + prerelease: Some(prerelease), + draft: Some(draft), + ..Default::default() + }; + let releases = api.get_releases(repo.owner(), repo.name(), query).await?; + for release in releases { + print!("{}", release.name); + match (release.draft, release.prerelease) { + (false, false) => (), + (true, false) => print!(" (draft)"), + (false, true) => print!(" (prerelease)"), + (true, true) => print!(" (draft, prerelease)"), + } + println!(); + } + Ok(()) +} + +async fn view_release( + repo: &RepoInfo, + api: &Forgejo, + name: String, + by_tag: bool, +) -> eyre::Result<()> { + let release = if by_tag { + api.get_release_by_tag(repo.owner(), repo.name(), &name) + .await? + .ok_or_else(|| eyre!("release not found"))? + } else { + find_release(repo, api, &name).await? + }; + println!("{}", release.name); + print!("By {} on ", release.author.login); + release.created_at.format_into( + &mut std::io::stdout(), + &time::format_description::well_known::Rfc2822, + )?; + println!(); + if !release.body.is_empty() { + println!(); + for line in release.body.lines() { + println!("> {line}"); + } + println!(); + } + if !release.assets.is_empty() { + println!("{} assets", release.assets.len() + 2); + for asset in release.assets { + println!("- {}", asset.name); + } + println!("- source.zip"); + println!("- source.tar.gz"); + } + Ok(()) +} + +async fn browse_release(repo: &RepoInfo, api: &Forgejo, name: Option) -> eyre::Result<()> { + match name { + Some(name) => { + let release = find_release(repo, api, &name).await?; + open::that(release.html_url.as_str())?; + } + None => { + let mut url = repo.url().clone(); + url.path_segments_mut().unwrap().push("releases"); + open::that(url.as_str())?; + } + } + Ok(()) +} + +async fn create_asset( + repo: &RepoInfo, + api: &Forgejo, + release: String, + file: std::path::PathBuf, + asset: Option, +) -> eyre::Result<()> { + let (file, asset) = match asset { + Some(ref asset) => (&*file, &**asset), + None => { + let asset = file + .file_name() + .ok_or_else(|| eyre!("{} does not have a file name", file.display()))? + .to_str() + .unwrap(); + (&*file, asset) + } + }; + let id = find_release(repo, api, &release).await?.id; + api.create_release_attachment( + repo.owner(), + repo.name(), + id, + asset, + tokio::fs::read(file).await?, + ) + .await?; + + Ok(()) +} + +async fn delete_asset( + repo: &RepoInfo, + api: &Forgejo, + release: String, + asset: String, +) -> eyre::Result<()> { + let release = find_release(repo, api, &release).await?; + let asset = release + .assets + .iter() + .find(|a| a.name == asset) + .ok_or_else(|| eyre!("asset not found"))?; + api.delete_release_attachment(repo.owner(), repo.name(), release.id, asset.id) + .await?; + Ok(()) +} + +async fn download_asset( + repo: &RepoInfo, + api: &Forgejo, + release: String, + asset: String, + output: Option, +) -> eyre::Result<()> { + let release = find_release(repo, api, &release).await?; + let file = match &*asset { + "source.zip" => api.download_release_zip(repo.owner(), repo.name(), release.id).await?, + "source.tar.gz" => api.download_release_tarball(repo.owner(), repo.name(), release.id).await?, + name => { + let asset = release + .assets + .iter() + .find(|a| a.name == name) + .ok_or_else(|| eyre!("asset not found"))?; + api.download_release_attachment(repo.owner(), repo.name(), release.id, asset.id).await? + } + }; + let file = file.ok_or_else(|| eyre!("asset not found"))?; + let output = output + .as_deref() + .unwrap_or_else(|| std::path::Path::new(&asset)); + tokio::fs::OpenOptions::new() + .create_new(true) + .write(true) + .open(output) + .await? + .write_all(file.as_ref()) + .await?; + + Ok(()) +} + +async fn find_release( + repo: &RepoInfo, + api: &Forgejo, + name: &str, +) -> eyre::Result { + let mut releases = api + .get_releases( + repo.owner(), + repo.name(), + forgejo_api::ReleaseQuery::default(), + ) + .await?; + let idx = releases + .iter() + .position(|r| r.name == name) + .ok_or_else(|| eyre!("release not found"))?; + Ok(releases.swap_remove(idx)) +} + +async fn delete_release( + repo: &RepoInfo, + api: &Forgejo, + name: String, + by_tag: bool, +) -> eyre::Result<()> { + if by_tag { + api.delete_release_by_tag(repo.owner(), repo.name(), &name) + .await?; + } else { + let id = find_release(repo, api, &name).await?.id; + api.delete_release(repo.owner(), repo.name(), id).await?; + } + Ok(()) +}