Merge pull request 'update to new version of forgejo-api' (#37) from update-api into main

Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/37
This commit is contained in:
Cyborus 2024-04-01 20:18:20 +00:00
commit a014a4e87a
5 changed files with 539 additions and 302 deletions

318
Cargo.lock generated
View file

@ -19,9 +19,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "anstream"
version = "0.6.5"
version = "0.6.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6"
checksum = "d96bd03f33fe50a863e394ee9718a706f988b9079b20c3784fb726e7678b62fb"
dependencies = [
"anstyle",
"anstyle-parse",
@ -33,9 +33,9 @@ dependencies = [
[[package]]
name = "anstyle"
version = "1.0.4"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87"
checksum = "8901269c6307e8d93993578286ac0edf7f195079ffff5ebdeea6a59ffb7e36bc"
[[package]]
name = "anstyle-parse"
@ -67,9 +67,9 @@ dependencies = [
[[package]]
name = "auth-git2"
version = "0.5.3"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41e7771d4ab6635cbd685ce8db215b29c78a468098126de77c57f3b2e6eb3757"
checksum = "e51bd0e4592409df8631ca807716dc1e5caafae5d01ce0157c966c71c7e49c3c"
dependencies = [
"dirs",
"git2",
@ -99,9 +99,9 @@ dependencies = [
[[package]]
name = "base64"
version = "0.21.5"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64ct"
@ -117,15 +117,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.1"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
[[package]]
name = "bumpalo"
version = "3.14.0"
version = "3.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa"
[[package]]
name = "bytes"
@ -135,9 +135,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
[[package]]
name = "cc"
version = "1.0.83"
version = "1.0.90"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
dependencies = [
"jobserver",
"libc",
@ -151,9 +151,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.4.12"
version = "4.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d"
checksum = "949626d00e063efc93b6dca932419ceb5432f99769911c0b995f7e884c778813"
dependencies = [
"clap_builder",
"clap_derive",
@ -161,9 +161,9 @@ dependencies = [
[[package]]
name = "clap_builder"
version = "4.4.12"
version = "4.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9"
checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4"
dependencies = [
"anstream",
"anstyle",
@ -173,9 +173,9 @@ dependencies = [
[[package]]
name = "clap_derive"
version = "4.4.7"
version = "4.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442"
checksum = "90239a040c80f5e14809ca132ddc4176ab33d5e17e49691793296e3fcb34d72f"
dependencies = [
"heck",
"proc-macro2",
@ -185,9 +185,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1"
checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce"
[[package]]
name = "colorchoice"
@ -278,9 +278,9 @@ dependencies = [
[[package]]
name = "eyre"
version = "0.6.11"
version = "0.6.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6267a1fa6f59179ea4afc8e50fd8612a3cc60bc858f786ff877a4a8cb042799"
checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec"
dependencies = [
"indenter",
"once_cell",
@ -337,7 +337,7 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "forgejo-api"
version = "0.1.0"
source = "git+https://codeberg.org/Cyborus/forgejo-api.git?rev=2435d0fa40#2435d0fa405464786f5c1691452445e8ec2f1395"
source = "git+https://codeberg.org/Cyborus/forgejo-api.git?rev=96b92daf23#96b92daf235985c17f19af0f0f19c20055d78f09"
dependencies = [
"base64ct",
"bytes",
@ -452,9 +452,9 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe9006bed769170c11f845cf00c7c1e9092aeb3f268e007c3e760ac68008070f"
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
dependencies = [
"cfg-if",
"libc",
@ -484,9 +484,9 @@ dependencies = [
[[package]]
name = "h2"
version = "0.3.22"
version = "0.3.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d6250322ef6e60f93f9a2162799302cd6f68f79f6e5d85c8c16f14d1d958178"
checksum = "4fbd2820c5e49886948654ab546d0688ff24530286bdcf8fca3cefb16d4618eb"
dependencies = [
"bytes",
"fnv",
@ -509,21 +509,21 @@ checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "heck"
version = "0.4.1"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.3.3"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "http"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8947b1a6fad4393052c7ba1f4cd97bed3e953a95c79c92ad9b051a04611d9fbb"
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
dependencies = [
"bytes",
"fnv",
@ -608,9 +608,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683"
[[package]]
name = "indexmap"
version = "2.1.0"
version = "2.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4"
dependencies = [
"equivalent",
"hashbrown",
@ -649,18 +649,18 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "jobserver"
version = "0.1.27"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d"
checksum = "ab46a6e9526ddef3ae7f787c06f0f2600639ba80ea3eade3d8e670a2230f51d6"
dependencies = [
"libc",
]
[[package]]
name = "js-sys"
version = "0.3.66"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cee9c64da59eae3b50095c18d3e74f8b73c0b86d2792824ff01bbce68ba229ca"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
dependencies = [
"wasm-bindgen",
]
@ -673,9 +673,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.151"
version = "0.2.153"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
[[package]]
name = "libgit2-sys"
@ -697,7 +697,7 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85c833ca1e66078851dba29046874e38f08b2c883700aa29a03ddd3b23814ee8"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.5.0",
"libc",
"redox_syscall",
]
@ -718,9 +718,9 @@ dependencies = [
[[package]]
name = "libz-sys"
version = "1.1.12"
version = "1.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97137b25e321a73eef1418d1d5d2eda4d77e12813f8e6dead84bc52c5870a7b"
checksum = "037731f5d3aaa87a5675e895b63ddff1a87624bc29f77004ea829809654e48f6"
dependencies = [
"cc",
"libc",
@ -730,9 +730,9 @@ dependencies = [
[[package]]
name = "linux-raw-sys"
version = "0.4.12"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4cd1a83af159aa67994778be9070f0ae1bd732942279cabb14f86f986a21456"
checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
[[package]]
name = "lock_api"
@ -746,9 +746,9 @@ dependencies = [
[[package]]
name = "log"
version = "0.4.20"
version = "0.4.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
[[package]]
name = "memchr"
@ -774,18 +774,18 @@ dependencies = [
[[package]]
name = "miniz_oxide"
version = "0.7.1"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7"
dependencies = [
"adler",
]
[[package]]
name = "mio"
version = "0.8.10"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
dependencies = [
"libc",
"wasi",
@ -810,6 +810,12 @@ dependencies = [
"tempfile",
]
[[package]]
name = "num-conv"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num_cpus"
version = "1.16.0"
@ -837,9 +843,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]]
name = "open"
version = "5.0.1"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90878fb664448b54c4e592455ad02831e23a3f7e157374a8b95654731aac7349"
checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32"
dependencies = [
"is-wsl",
"libc",
@ -848,11 +854,11 @@ dependencies = [
[[package]]
name = "openssl"
version = "0.10.62"
version = "0.10.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cde4d2d9200ad5909f8dac647e29482e07c3a35de8a13fce7c9c7747ad9f671"
checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.5.0",
"cfg-if",
"foreign-types",
"libc",
@ -880,9 +886,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.98"
version = "0.9.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1665caf8ab2dc9aef43d1c0023bd904633a6a05cb30b0ad59bec2ae986e57a7"
checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff"
dependencies = [
"cc",
"libc",
@ -945,9 +951,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.28"
version = "0.3.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69d3587f8a9e599cc7ec2c00e331f71c4e69a5f9a4b8a6efd5b07466b9736f9a"
checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec"
[[package]]
name = "powerfmt"
@ -957,18 +963,18 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
[[package]]
name = "proc-macro2"
version = "1.0.73"
version = "1.0.79"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dd5e8a1f1029c43224ad5898e50140c2aebb1705f19e67c918ebf5b9e797fe1"
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.34"
version = "1.0.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a37c9326af5ed140c86a46655b5278de879853be5573c01df185b6f49a580a"
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
dependencies = [
"proc-macro2",
]
@ -995,9 +1001,9 @@ dependencies = [
[[package]]
name = "reqwest"
version = "0.11.23"
version = "0.11.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37b1ae8d9ac08420c66222fb9096fc5de435c3c48542bc5336c51892cffafb41"
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
dependencies = [
"base64",
"bytes",
@ -1018,9 +1024,11 @@ dependencies = [
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls-pemfile",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
@ -1040,11 +1048,11 @@ checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "rustix"
version = "0.38.28"
version = "0.38.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72e572a5e8ca657d7366229cdde4bd14c4eb5499a9573d4d366fe1b599daa316"
checksum = "65e04861e65f21776e67888bfbea442b3642beaa0138fdb1dd7a84a52dffdb89"
dependencies = [
"bitflags 2.4.1",
"bitflags 2.5.0",
"errno",
"libc",
"linux-raw-sys",
@ -1052,10 +1060,19 @@ dependencies = [
]
[[package]]
name = "ryu"
version = "1.0.16"
name = "rustls-pemfile"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
dependencies = [
"base64",
]
[[package]]
name = "ryu"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
[[package]]
name = "schannel"
@ -1097,18 +1114,18 @@ dependencies = [
[[package]]
name = "serde"
version = "1.0.193"
version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.193"
version = "1.0.197"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [
"proc-macro2",
"quote",
@ -1117,9 +1134,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.109"
version = "1.0.114"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
dependencies = [
"itoa",
"ryu",
@ -1158,18 +1175,18 @@ dependencies = [
[[package]]
name = "smallvec"
version = "1.11.2"
version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "socket2"
version = "0.5.5"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9"
checksum = "05ffd9c0a93b7543e062e759284fcf5f5e3b098501104bfbdde4d404db792871"
dependencies = [
"libc",
"windows-sys 0.48.0",
"windows-sys 0.52.0",
]
[[package]]
@ -1180,21 +1197,27 @@ checksum = "b5097ec7ea7218135541ad96348f1441d0c616537dd4ed9c47205920c35d7d97"
[[package]]
name = "strsim"
version = "0.10.0"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01"
[[package]]
name = "syn"
version = "2.0.45"
version = "2.0.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eae3c679c56dc214320b67a1bc04ef3dfbd6411f6443974b5e4893231298e66"
checksum = "7383cd0e49fff4b6b90ca5670bfd3e9d6a733b3f90c686605aa7eec8c4996032"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "sync_wrapper"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "system-configuration"
version = "0.5.1"
@ -1218,13 +1241,12 @@ dependencies = [
[[package]]
name = "tempfile"
version = "3.9.0"
version = "3.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01ce4141aa927a6d1bd34a041795abd0db1cccba5d5f24b009f694bdf3a1f3fa"
checksum = "85b77fafb263dd9d05cbeac119526425676db3784113aa9295c88498cbf8bff1"
dependencies = [
"cfg-if",
"fastrand",
"redox_syscall",
"rustix",
"windows-sys 0.52.0",
]
@ -1241,18 +1263,18 @@ dependencies = [
[[package]]
name = "thiserror"
version = "1.0.53"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2cd5904763bad08ad5513ddbb12cf2ae273ca53fa9f68e843e236ec6dfccc09"
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.53"
version = "1.0.58"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3dcf4a824cce0aeacd6f38ae6f24234c8e80d68632338ebaa1443b5df9e29e19"
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
dependencies = [
"proc-macro2",
"quote",
@ -1261,12 +1283,13 @@ dependencies = [
[[package]]
name = "time"
version = "0.3.31"
version = "0.3.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f657ba42c3f86e7680e53c8cd3af8abbe56b5491790b46e22e19c0d57463583e"
checksum = "c8248b6521bb14bc45b4067159b9b6ad792e2d6d754d6c41fb50e29fefe38749"
dependencies = [
"deranged",
"itoa",
"num-conv",
"powerfmt",
"serde",
"time-core",
@ -1281,10 +1304,11 @@ checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
[[package]]
name = "time-macros"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26197e33420244aeb70c3e8c78376ca46571bc4e701e4791c2cd9f57dcb3a43f"
checksum = "7ba3a3ef41e6672a2f0f001392bb5dcd3ff0a9992d618ca761a11c3121547774"
dependencies = [
"num-conv",
"time-core",
]
@ -1305,9 +1329,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.35.1"
version = "1.36.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89b4efa943be685f629b149f53829423f8f5531ea21249408e8e2f8671ec104"
checksum = "61285f6515fa018fb2d1e46eb21223fff441ee8db5d0f1435e8ab4f5cdb80931"
dependencies = [
"backtrace",
"bytes",
@ -1399,9 +1423,9 @@ dependencies = [
[[package]]
name = "unicode-bidi"
version = "0.3.14"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6f2528f27a9eb2b21e69c95319b30bd0efd85d09c379741b0f78ea1d86be2416"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-ident"
@ -1411,9 +1435,9 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
version = "0.1.22"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
dependencies = [
"tinyvec",
]
@ -1438,9 +1462,9 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
[[package]]
name = "uuid"
version = "1.6.1"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e395fcf16a7a3d8127ec99782007af141946b4795001f876d54fb0d55978560"
checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0"
dependencies = [
"getrandom",
]
@ -1474,9 +1498,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.89"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ed0d4f68a3015cc185aff4db9506a015f4b96f95303897bfa23f846db54064e"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
dependencies = [
"cfg-if",
"wasm-bindgen-macro",
@ -1484,9 +1508,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.89"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b56f625e64f3a1084ded111c4d5f477df9f8c92df113852fa5a374dbda78826"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
dependencies = [
"bumpalo",
"log",
@ -1499,9 +1523,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.39"
version = "0.4.42"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac36a15a220124ac510204aec1c3e5db8a22ab06fd6706d881dc6149f8ed9a12"
checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0"
dependencies = [
"cfg-if",
"js-sys",
@ -1511,9 +1535,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.89"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0162dbf37223cd2afce98f3d0785506dcb8d266223983e4b5b525859e6e182b2"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -1521,9 +1545,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.89"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0eb82fcb7930ae6219a7ecfd55b217f5f0893484b7a13022ebb2b2bf20b5283"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
dependencies = [
"proc-macro2",
"quote",
@ -1534,15 +1558,15 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.89"
version = "0.2.92"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ab9b36309365056cd639da3134bf87fa8f3d86008abf99e612384a6eecd459f"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
[[package]]
name = "web-sys"
version = "0.3.66"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50c24a44ec86bb68fbecd1b3efed7e85ea5621b39b35ef2766b66cd984f8010f"
checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef"
dependencies = [
"js-sys",
"wasm-bindgen",
@ -1585,7 +1609,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.0",
"windows-targets 0.52.4",
]
[[package]]
@ -1605,17 +1629,17 @@ dependencies = [
[[package]]
name = "windows-targets"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd"
checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
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",
"windows_aarch64_gnullvm 0.52.4",
"windows_aarch64_msvc 0.52.4",
"windows_i686_gnu 0.52.4",
"windows_i686_msvc 0.52.4",
"windows_x86_64_gnu 0.52.4",
"windows_x86_64_gnullvm 0.52.4",
"windows_x86_64_msvc 0.52.4",
]
[[package]]
@ -1626,9 +1650,9 @@ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea"
checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
[[package]]
name = "windows_aarch64_msvc"
@ -1638,9 +1662,9 @@ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef"
checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
[[package]]
name = "windows_i686_gnu"
@ -1650,9 +1674,9 @@ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313"
checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3"
[[package]]
name = "windows_i686_msvc"
@ -1662,9 +1686,9 @@ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a"
checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
[[package]]
name = "windows_x86_64_gnu"
@ -1674,9 +1698,9 @@ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd"
checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
[[package]]
name = "windows_x86_64_gnullvm"
@ -1686,9 +1710,9 @@ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e"
checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
[[package]]
name = "windows_x86_64_msvc"
@ -1698,9 +1722,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.0"
version = "0.52.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
[[package]]
name = "winreg"

View file

@ -10,7 +10,7 @@ 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 = "2435d0fa40" }
forgejo-api = { git = "https://codeberg.org/Cyborus/forgejo-api.git", rev = "96b92daf23" }
futures = "0.3.28"
git2 = "0.17.2"
open = "5.0.0"

View file

@ -1,6 +1,9 @@
use clap::Subcommand;
use eyre::eyre;
use forgejo_api::{Comment, CreateIssueCommentOption, EditIssueOption, Forgejo, IssueCommentQuery};
use forgejo_api::structs::{
Comment, CreateIssueCommentOption, CreateIssueOption, EditIssueOption, IssueGetCommentsQuery,
};
use forgejo_api::Forgejo;
use crate::repo::RepoInfo;
@ -52,11 +55,11 @@ pub enum State {
Closed,
}
impl From<State> for forgejo_api::State {
impl From<State> for forgejo_api::structs::IssueListIssuesQueryState {
fn from(value: State) -> Self {
match value {
State::Open => forgejo_api::State::Open,
State::Closed => forgejo_api::State::Closed,
State::Open => forgejo_api::structs::IssueListIssuesQueryState::Open,
State::Closed => forgejo_api::structs::IssueListIssuesQueryState::Closed,
}
}
}
@ -133,30 +136,52 @@ async fn create_issue(
}
};
let issue = api
.create_issue(
.issue_create_issue(
repo.owner(),
repo.name(),
forgejo_api::CreateIssueOption {
CreateIssueOption {
body: Some(body),
title,
..Default::default()
assignee: None,
assignees: None,
closed: None,
due_date: None,
labels: None,
milestone: None,
r#ref: None,
},
)
.await?;
eprintln!("created issue #{}: {}", issue.number, issue.title);
let number = issue
.number
.ok_or_else(|| eyre::eyre!("issue does not have number"))?;
let title = issue
.title
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have title"))?;
eprintln!("created issue #{}: {}", number, title);
Ok(())
}
async fn view_issue(repo: &RepoInfo, api: &Forgejo, id: u64) -> eyre::Result<()> {
let issue = api
.get_issue(repo.owner(), repo.name(), id)
.await?
.ok_or_else(|| eyre!("issue {id} does not exist"))?;
println!("#{}: {}", id, issue.title);
println!("By {}", issue.user.login);
if !issue.body.is_empty() {
let issue = api.issue_get_issue(repo.owner(), repo.name(), id).await?;
let title = issue
.title
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have title"))?;
let user = issue
.user
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have creator"))?;
let username = user
.login
.as_ref()
.ok_or_else(|| eyre::eyre!("user does not have login"))?;
println!("#{}: {}", id, title);
println!("By {}", username);
if let Some(body) = &issue.body {
println!();
println!("{}", issue.body);
println!("{}", body);
}
Ok(())
}
@ -172,16 +197,22 @@ async fn view_issues(
let labels = labels
.map(|s| s.split(',').map(|s| s.to_string()).collect::<Vec<_>>())
.unwrap_or_default();
let query = forgejo_api::IssueQuery {
query: query_str,
labels,
let query = forgejo_api::structs::IssueListIssuesQuery {
q: query_str,
labels: Some(labels.join(",")),
created_by: creator,
assigned_by: assignee,
state: state.map(|s| s.into()),
..Default::default()
r#type: None,
milestones: None,
since: None,
before: None,
mentioned_by: None,
page: None,
limit: None,
};
let issues = api
.get_repo_issues(repo.owner(), repo.name(), query)
.issue_list_issues(repo.owner(), repo.name(), query)
.await?;
if issues.len() == 1 {
println!("1 issue");
@ -189,58 +220,97 @@ async fn view_issues(
println!("{} issues", issues.len());
}
for issue in issues {
println!(
"#{}: {} (by {})",
issue.number, issue.title, issue.user.login
);
let number = issue
.number
.ok_or_else(|| eyre::eyre!("issue does not have number"))?;
let title = issue
.title
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have title"))?;
let user = issue
.user
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have creator"))?;
let username = user
.login
.as_ref()
.ok_or_else(|| eyre::eyre!("user does not have login"))?;
println!("#{}: {} (by {})", number, title, username);
}
Ok(())
}
async fn view_comment(repo: &RepoInfo, api: &Forgejo, id: u64, idx: usize) -> eyre::Result<()> {
let query = IssueGetCommentsQuery {
since: None,
before: None,
};
let comments = api
.get_issue_comments(repo.owner(), repo.name(), id, IssueCommentQuery::default())
.issue_get_comments(repo.owner(), repo.name(), id, query)
.await?;
let comment = comments
.get(idx)
.ok_or_else(|| eyre!("comment {idx} doesn't exist"))?;
print_comment(&comment);
print_comment(&comment)?;
Ok(())
}
async fn view_comments(repo: &RepoInfo, api: &Forgejo, id: u64) -> eyre::Result<()> {
let query = IssueGetCommentsQuery {
since: None,
before: None,
};
let comments = api
.get_issue_comments(repo.owner(), repo.name(), id, IssueCommentQuery::default())
.issue_get_comments(repo.owner(), repo.name(), id, query)
.await?;
for comment in comments {
print_comment(&comment);
print_comment(&comment)?;
}
Ok(())
}
fn print_comment(comment: &Comment) {
println!("{} said:", comment.user.login);
println!("{}", comment.body);
if !comment.assets.is_empty() {
println!("({} attachments)", comment.assets.len());
fn print_comment(comment: &Comment) -> eyre::Result<()> {
let body = comment
.body
.as_ref()
.ok_or_else(|| eyre::eyre!("comment does not have body"))?;
let user = comment
.user
.as_ref()
.ok_or_else(|| eyre::eyre!("comment does not have user"))?;
let username = user
.login
.as_ref()
.ok_or_else(|| eyre::eyre!("user does not have login"))?;
println!("{} said:", username);
println!("{}", body);
let assets = comment
.assets
.as_ref()
.ok_or_else(|| eyre::eyre!("comment does not have assets"))?;
if !assets.is_empty() {
println!("({} attachments)", assets.len());
}
Ok(())
}
async fn browse_issue(repo: &RepoInfo, api: &Forgejo, id: Option<u64>) -> eyre::Result<()> {
match id {
Some(id) => {
let issue = api
.get_issue(repo.owner(), repo.name(), id)
.await?
.ok_or_else(|| eyre!("issue {id} does not exist"))?;
open::that(issue.html_url.as_str())?;
let issue = api.issue_get_issue(repo.owner(), repo.name(), id).await?;
let html_url = issue
.html_url
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have html_url"))?;
open::that(html_url.as_str())?;
}
None => {
let repo = api
.get_repo(repo.owner(), repo.name())
.await?
.ok_or_else(|| eyre!("repo {}/{} does not exist", repo.owner(), repo.name()))?;
open::that(format!("{}/issues", repo.html_url))?;
let repo = api.repo_get(repo.owner(), repo.name()).await?;
let html_url = repo
.html_url
.as_ref()
.ok_or_else(|| eyre::eyre!("issue does not have html_url"))?;
open::that(format!("{}/issues", html_url))?;
}
}
Ok(())
@ -260,13 +330,13 @@ async fn add_comment(
body
}
};
api.create_comment(
api.issue_create_comment(
repo.owner(),
repo.name(),
issue,
forgejo_api::CreateIssueCommentOption {
forgejo_api::structs::CreateIssueCommentOption {
body,
..Default::default()
updated_at: None,
},
)
.await?;
@ -282,12 +352,14 @@ async fn edit_title(
let new_title = match new_title {
Some(s) => s,
None => {
let mut issue_info = api
.get_issue(repo.owner(), repo.name(), issue)
.await?
.ok_or_else(|| eyre!("issue {issue} does not exist"))?;
crate::editor(&mut issue_info.title, Some("md")).await?;
issue_info.title
let issue_info = api
.issue_get_issue(repo.owner(), repo.name(), issue)
.await?;
let mut title = issue_info
.title
.ok_or_else(|| eyre::eyre!("issue does not have title"))?;
crate::editor(&mut title, Some("md")).await?;
title
}
};
if new_title.is_empty() {
@ -296,13 +368,21 @@ async fn edit_title(
if new_title.contains('\n') {
eyre::bail!("title cannot contain newlines");
}
api.edit_issue(
api.issue_edit_issue(
repo.owner(),
repo.name(),
issue,
forgejo_api::EditIssueOption {
forgejo_api::structs::EditIssueOption {
title: Some(new_title.trim().to_owned()),
..Default::default()
assignee: None,
assignees: None,
body: None,
due_date: None,
milestone: None,
r#ref: None,
state: None,
unset_due_date: None,
updated_at: None,
},
)
.await?;
@ -318,21 +398,31 @@ async fn edit_body(
let new_body = match new_body {
Some(s) => s,
None => {
let mut issue_info = api
.get_issue(repo.owner(), repo.name(), issue)
.await?
.ok_or_else(|| eyre!("issue {issue} does not exist"))?;
crate::editor(&mut issue_info.body, Some("md")).await?;
issue_info.body
let issue_info = api
.issue_get_issue(repo.owner(), repo.name(), issue)
.await?;
let mut body = issue_info
.body
.ok_or_else(|| eyre::eyre!("issue does not have body"))?;
crate::editor(&mut body, Some("md")).await?;
body
}
};
api.edit_issue(
api.issue_edit_issue(
repo.owner(),
repo.name(),
issue,
forgejo_api::EditIssueOption {
forgejo_api::structs::EditIssueOption {
body: Some(new_body),
..Default::default()
assignee: None,
assignees: None,
due_date: None,
milestone: None,
r#ref: None,
state: None,
title: None,
unset_due_date: None,
updated_at: None,
},
)
.await?;
@ -347,11 +437,14 @@ async fn edit_comment(
new_body: Option<String>,
) -> eyre::Result<()> {
let comments = api
.get_issue_comments(
.issue_get_comments(
repo.owner(),
repo.name(),
issue,
forgejo_api::IssueCommentQuery::default(),
IssueGetCommentsQuery {
since: None,
before: None,
},
)
.await?;
let comment = comments
@ -360,18 +453,24 @@ async fn edit_comment(
let new_body = match new_body {
Some(s) => s,
None => {
let mut body = comment.body.clone();
let mut body = comment
.body
.clone()
.ok_or_else(|| eyre::eyre!("issue does not have body"))?;
crate::editor(&mut body, Some("md")).await?;
body
}
};
api.edit_comment(
let id = comment
.id
.ok_or_else(|| eyre::eyre!("comment does not have id"))?;
api.issue_edit_comment(
repo.owner(),
repo.name(),
comment.id,
forgejo_api::EditIssueCommentOption {
id,
forgejo_api::structs::EditIssueCommentOption {
body: new_body,
..Default::default()
updated_at: None,
},
)
.await?;
@ -394,16 +493,27 @@ async fn close_issue(
}
};
let opt = CreateIssueCommentOption { body };
api.create_comment(repo.owner(), repo.name(), issue, opt)
let opt = CreateIssueCommentOption {
body,
updated_at: None,
};
api.issue_create_comment(repo.owner(), repo.name(), issue, opt)
.await?;
}
let edit = EditIssueOption {
state: Some(forgejo_api::State::Closed),
..Default::default()
state: Some("closed".into()),
assignee: None,
assignees: None,
body: None,
due_date: None,
milestone: None,
r#ref: None,
title: None,
unset_due_date: None,
updated_at: None,
};
api.edit_issue(repo.owner(), repo.name(), issue, edit)
api.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
.await?;
Ok(())

View file

@ -1,6 +1,9 @@
use clap::Subcommand;
use eyre::{bail, eyre};
use forgejo_api::Forgejo;
use forgejo_api::{
structs::{RepoCreateReleaseAttachmentQuery, RepoListReleasesQuery},
Forgejo,
};
use tokio::io::AsyncWriteExt;
use crate::{keys::KeyInfo, repo::RepoInfo};
@ -170,12 +173,12 @@ async fn create_release(
(Some(tag), None) => tag,
(None, Some(tag)) => {
let tag = tag.unwrap_or_else(|| name.clone());
let opt = forgejo_api::CreateTagOption {
let opt = forgejo_api::structs::CreateTagOption {
message: None,
tag_name: tag.clone(),
target: branch,
};
api.create_tag(repo.owner(), repo.name(), opt).await?;
api.repo_create_tag(repo.owner(), repo.name(), opt).await?;
tag
}
(Some(_), Some(_)) => {
@ -184,25 +187,25 @@ async fn create_release(
};
let body = match body {
Some(Some(body)) => body,
Some(Some(body)) => Some(body),
Some(None) => {
let mut s = String::new();
crate::editor(&mut s, Some("md")).await?;
s
Some(s)
}
None => String::new(),
None => None,
};
let release_opt = forgejo_api::CreateReleaseOption {
let release_opt = forgejo_api::structs::CreateReleaseOption {
body,
draft,
name,
prerelease,
draft: Some(draft),
name: Some(name),
prerelease: Some(prerelease),
tag_name,
target_commitish: None,
};
let release = api
.create_release(repo.owner(), repo.name(), release_opt)
.repo_create_release(repo.owner(), repo.name(), release_opt)
.await?;
for attachment in attachments {
@ -218,12 +221,18 @@ async fn create_release(
(file, asset)
}
};
api.create_release_attachment(
let query = RepoCreateReleaseAttachmentQuery {
name: Some(asset.into()),
};
let id = release
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
api.repo_create_release_attachment(
repo.owner(),
repo.name(),
release.id,
asset,
id,
tokio::fs::read(file).await?,
query,
)
.await?;
}
@ -245,13 +254,16 @@ async fn edit_release(
let body = match body {
Some(Some(body)) => Some(body),
Some(None) => {
let mut s = release.body.clone();
let mut s = release
.body
.clone()
.ok_or_else(|| eyre::eyre!("release does not have body"))?;
crate::editor(&mut s, Some("md")).await?;
Some(s)
}
None => None,
};
let release_edit = forgejo_api::EditReleaseOption {
let release_edit = forgejo_api::structs::EditReleaseOption {
name: rename,
tag_name: tag,
body,
@ -259,7 +271,10 @@ async fn edit_release(
prerelease,
target_commitish: None,
};
api.edit_release(repo.owner(), repo.name(), release.id, release_edit)
let id = release
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
api.repo_edit_release(repo.owner(), repo.name(), id, release_edit)
.await?;
Ok(())
}
@ -270,15 +285,31 @@ async fn list_releases(
prerelease: bool,
draft: bool,
) -> eyre::Result<()> {
let query = forgejo_api::ReleaseQuery {
prerelease: Some(prerelease),
let query = forgejo_api::structs::RepoListReleasesQuery {
pre_release: Some(prerelease),
draft: Some(draft),
..Default::default()
per_page: None,
page: None,
limit: None,
};
let releases = api.get_releases(repo.owner(), repo.name(), query).await?;
let releases = api
.repo_list_releases(repo.owner(), repo.name(), query)
.await?;
for release in releases {
print!("{}", release.name);
match (release.draft, release.prerelease) {
let name = release
.name
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have name"))?;
let draft = release
.draft
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have draft"))?;
let prerelease = release
.prerelease
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have prerelease"))?;
print!("{}", name);
match (draft, prerelease) {
(false, false) => (),
(true, false) => print!(" (draft)"),
(false, true) => print!(" (prerelease)"),
@ -296,30 +327,56 @@ async fn view_release(
by_tag: bool,
) -> eyre::Result<()> {
let release = if by_tag {
api.get_release_by_tag(repo.owner(), repo.name(), &name)
api.repo_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(
let name = release
.name
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have name"))?;
let author = release
.author
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have author"))?;
let login = author
.login
.as_ref()
.ok_or_else(|| eyre::eyre!("autho does not have login"))?;
let created_at = release
.created_at
.ok_or_else(|| eyre::eyre!("release does not have created_at"))?;
println!("{}", name);
print!("By {} on ", login);
created_at.format_into(
&mut std::io::stdout(),
&time::format_description::well_known::Rfc2822,
)?;
println!();
if !release.body.is_empty() {
let body = release
.body
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have body"))?;
if !body.is_empty() {
println!();
for line in release.body.lines() {
for line in body.lines() {
println!("> {line}");
}
println!();
}
if !release.assets.is_empty() {
println!("{} assets", release.assets.len() + 2);
for asset in release.assets {
println!("- {}", asset.name);
let assets = release
.assets
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
if !assets.is_empty() {
println!("{} assets", assets.len() + 2);
for asset in assets {
let name = asset
.name
.as_ref()
.ok_or_else(|| eyre::eyre!("asset does not have name"))?;
println!("- {}", name);
}
println!("- source.zip");
println!("- source.tar.gz");
@ -331,7 +388,11 @@ async fn browse_release(repo: &RepoInfo, api: &Forgejo, name: Option<String>) ->
match name {
Some(name) => {
let release = find_release(repo, api, &name).await?;
open::that(release.html_url.as_str())?;
let html_url = release
.html_url
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have html_url"))?;
open::that(html_url.as_str())?;
}
None => {
let mut url = repo.url().clone();
@ -360,13 +421,19 @@ async fn create_asset(
(&*file, asset)
}
};
let id = find_release(repo, api, &release).await?.id;
api.create_release_attachment(
let id = find_release(repo, api, &release)
.await?
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
let query = RepoCreateReleaseAttachmentQuery {
name: Some(asset.to_owned()),
};
api.repo_create_release_attachment(
repo.owner(),
repo.name(),
id,
asset,
tokio::fs::read(file).await?,
query,
)
.await?;
@ -380,12 +447,21 @@ async fn delete_asset(
asset: String,
) -> eyre::Result<()> {
let release = find_release(repo, api, &release).await?;
let asset = release
let assets = release
.assets
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
let asset = assets
.iter()
.find(|a| a.name == asset)
.find(|a| a.name.as_ref() == Some(&asset))
.ok_or_else(|| eyre!("asset not found"))?;
api.delete_release_attachment(repo.owner(), repo.name(), release.id, asset.id)
let release_id = release
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
let asset_id = asset
.id
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
api.repo_delete_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
.await?;
Ok(())
}
@ -400,24 +476,41 @@ async fn download_asset(
let release = find_release(repo, api, &release).await?;
let file = match &*asset {
"source.zip" => {
api.download_zip_archive(repo.owner(), repo.name(), &release.tag_name)
let tag_name = release
.tag_name
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have tag_name"))?;
api.repo_get_archive(repo.owner(), repo.name(), &format!("{}.zip", tag_name))
.await?
}
"source.tar.gz" => {
api.download_tarball_archive(repo.owner(), repo.name(), &release.tag_name)
let tag_name = release
.tag_name
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have tag_name"))?;
api.repo_get_archive(repo.owner(), repo.name(), &format!("{}.tar.gz", tag_name))
.await?
}
name => {
let asset = release
let assets = release
.assets
.as_ref()
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
let asset = assets
.iter()
.find(|a| a.name == name)
.find(|a| a.name.as_deref() == Some(name))
.ok_or_else(|| eyre!("asset not found"))?;
api.download_release_attachment(repo.owner(), repo.name(), release.id, asset.id)
let release_id = release
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
let asset_id = asset
.id
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
api.download_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
.await?
.to_vec()
}
};
let file = file.ok_or_else(|| eyre!("asset not found"))?;
let output = output
.as_deref()
.unwrap_or_else(|| std::path::Path::new(&asset));
@ -436,17 +529,20 @@ async fn find_release(
repo: &RepoInfo,
api: &Forgejo,
name: &str,
) -> eyre::Result<forgejo_api::Release> {
) -> eyre::Result<forgejo_api::structs::Release> {
let query = RepoListReleasesQuery {
draft: None,
pre_release: None,
per_page: None,
page: None,
limit: None,
};
let mut releases = api
.get_releases(
repo.owner(),
repo.name(),
forgejo_api::ReleaseQuery::default(),
)
.repo_list_releases(repo.owner(), repo.name(), query)
.await?;
let idx = releases
.iter()
.position(|r| r.name == name)
.position(|r| r.name.as_deref() == Some(name))
.ok_or_else(|| eyre!("release not found"))?;
Ok(releases.swap_remove(idx))
}
@ -458,11 +554,15 @@ async fn delete_release(
by_tag: bool,
) -> eyre::Result<()> {
if by_tag {
api.delete_release_by_tag(repo.owner(), repo.name(), &name)
api.repo_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?;
let id = find_release(repo, api, &name)
.await?
.id
.ok_or_else(|| eyre::eyre!("release does not have id"))?;
api.repo_delete_release(repo.owner(), repo.name(), id)
.await?;
}
Ok(())
}

View file

@ -1,6 +1,6 @@
use clap::Subcommand;
use eyre::eyre;
use forgejo_api::CreateRepoOption;
use forgejo_api::structs::CreateRepoOption;
use url::Url;
pub struct RepoInfo {
@ -110,26 +110,34 @@ impl RepoCommand {
let host = Url::parse(&host)?;
let api = keys.get_api(&host)?;
let repo_spec = CreateRepoOption {
auto_init: false,
default_branch: "main".into(),
auto_init: Some(false),
default_branch: Some("main".into()),
description,
gitignores: String::new(),
issue_labels: String::new(),
license: String::new(),
gitignores: None,
issue_labels: None,
license: None,
name: repo.clone(),
private,
readme: String::new(),
template: false,
trust_model: forgejo_api::TrustModel::Default,
private: Some(private),
readme: Some(String::new()),
template: Some(false),
trust_model: Some(forgejo_api::structs::CreateRepoOptionTrustModel::Default),
};
let new_repo = api.create_repo(repo_spec).await?;
eprintln!("created new repo at {}", host.join(&new_repo.full_name)?);
let new_repo = api.create_current_user_repo(repo_spec).await?;
let full_name = new_repo
.full_name
.as_ref()
.ok_or_else(|| eyre::eyre!("new_repo does not have full_name"))?;
eprintln!("created new repo at {}", host.join(&full_name)?);
if set_upstream.is_some() || push {
let repo = git2::Repository::open(".")?;
let upstream = set_upstream.as_deref().unwrap_or("origin");
let mut remote = repo.remote(upstream, new_repo.clone_url.as_str())?;
let clone_url = new_repo
.clone_url
.as_ref()
.ok_or_else(|| eyre::eyre!("new_repo does not have clone_url"))?;
let mut remote = repo.remote(upstream, clone_url.as_str())?;
if push {
let head = repo.head()?;
@ -153,14 +161,9 @@ impl RepoCommand {
RepoCommand::Info => {
let repo = RepoInfo::get_current(remote_name)?;
let api = keys.get_api(&repo.host_url())?;
let repo = api.get_repo(repo.owner(), repo.name()).await?;
match repo {
Some(repo) => {
let repo = api.repo_get(repo.owner(), repo.name()).await?;
dbg!(repo);
}
None => eprintln!("repo not found"),
}
}
RepoCommand::Browse => {
let repo = RepoInfo::get_current(remote_name)?;
let mut url = repo.host_url().clone();