diff --git a/CHANGELOG.md b/CHANGELOG.md index 44aea70..2b3c040 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ # Changelog +## [0.7.3] - 2026-06-13 "Оптимизация Зависимостей и VCS / Dependency Optimization & VCS" + +### RU + +**Добавлено:** + +- **Параметр `--vcs` для команд `new` и `init`** — добавлена возможность явно указывать систему контроля версий через `--vcs `. +- **Интеграция Git-информации в `--version`** — утилита теперь выводит текущий короткий хэш коммита и суффикс `-dirty`, если в репозитории DCR есть незакоммиченные изменения. +- **Автоматическая генерация `.gitignore`** — при инициализации Git-репозитория автоматически создается файл `.gitignore` с исключением директории `/target`. +- **Защита от вложенных репозиториев** — автоматическая инициализация Git теперь пропускается, если `dcr new` или `dcr init` запускаются внутри уже существующего Git-репозитория. +- **Тесты для верификации VCS** — добавлены интеграционные тесты `new_vcs_options_work` и `init_vcs_options_work` для проверки логики инициализации репозиториев. + +**Изменено:** + +- **Полный отказ от библиотеки `git2`** — работа с Git (клонирование зависимостей, инициализация VCS, проверка статуса) переведена на вызовы системного `git` через `Command`. Это облегчает сборку проекта и убирает необходимость в фичах `vendored` и `openssl`. +- **Миграция с `reqwest` на `ureq`** — в модуле обновления (`flag_update.rs`) тяжелый `reqwest` заменен на легковесный синхронный клиент `ureq 2.10`, что уменьшило оверхед и размер итогового бинарника. + +### EN + +**Added:** + +- **`--vcs` option for `new` and `init` commands** — introduced explicit version control system selection via `--vcs `. +- **Git metadata integration in `--version`** — the CLI now appends the current short commit hash and a `-dirty` suffix if there are uncommitted changes in the DCR repository. +- **Automatic `.gitignore` generation** — Git repository initialization now automatically writes a `.gitignore` file excluding the `/target` directory. +- **Nested repository prevention** — automatic Git initialization is now skipped if `dcr new` or `dcr init` is executed inside an already existing Git repository. +- **VCS verification tests** — added `new_vcs_options_work` and `init_vcs_options_work` integration tests to ensure reliable repository behavior. + +**Changed:** + +- **Complete removal of `git2` dependency** — all Git actions (dependency fetching, VCS setup, status checks) are now delegated to the system `git` executable via `Command`. This simplifies compilation and drops the need for `vendored` and `openssl` features. +- **Migrated from `reqwest` to `ureq`** — replaced the heavy `reqwest` crate in `flag_update.rs` with the lightweight synchronous `ureq 2.10` client, reducing overhead and the final binary size. + ## [0.7.2] - 2026-06-07 "Исправление Таргетов и Линковки / Target & Linker Fixes" ### RU diff --git a/Cargo.lock b/Cargo.lock index 4429d44..5a5eecf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,12 +8,6 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" -[[package]] -name = "atomic-waker" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" - [[package]] name = "base64" version = "0.22.1" @@ -44,30 +38,6 @@ dependencies = [ "objc2", ] -[[package]] -name = "bumpalo" -version = "3.20.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" - -[[package]] -name = "bytes" -version = "1.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" - -[[package]] -name = "cc" -version = "1.2.63" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556e016178bb5662a08681bbe0f00f8e17631781a4dfc8c45e466e4b185ec27f" -dependencies = [ - "find-msvc-tools", - "jobserver", - "libc", - "shlex", -] - [[package]] name = "cfg-if" version = "1.0.4" @@ -80,6 +50,22 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -112,18 +98,16 @@ dependencies = [ [[package]] name = "dcr" -version = "0.7.2" +version = "0.7.3" dependencies = [ "ctrlc", - "git2", "glob", - "openssl", - "reqwest", "self-replace", "serde", "serde_json", "sha2", "toml", + "ureq", ] [[package]] @@ -181,33 +165,12 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" -[[package]] -name = "find-msvc-tools" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" - [[package]] name = "foldhash" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.2.2" @@ -217,55 +180,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "futures-channel" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" - -[[package]] -name = "futures-io" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" - -[[package]] -name = "futures-sink" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" - -[[package]] -name = "futures-task" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" - -[[package]] -name = "futures-util" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" -dependencies = [ - "futures-core", - "futures-io", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "slab", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -276,33 +190,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "wasi", - "wasm-bindgen", -] - -[[package]] -name = "getrandom" -version = "0.3.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" -dependencies = [ - "cfg-if", - "js-sys", - "libc", - "r-efi 5.3.0", - "wasip2", - "wasm-bindgen", -] - [[package]] name = "getrandom" version = "0.4.2" @@ -311,26 +198,11 @@ checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" dependencies = [ "cfg-if", "libc", - "r-efi 6.0.0", + "r-efi", "wasip2", "wasip3", ] -[[package]] -name = "git2" -version = "0.20.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b88256088d75a56f8ecfa070513a775dd9107f6530ef14919dac831af9cfe2b" -dependencies = [ - "bitflags", - "libc", - "libgit2-sys", - "log", - "openssl-probe", - "openssl-sys", - "url", -] - [[package]] name = "glob" version = "0.3.3" @@ -358,104 +230,6 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" -[[package]] -name = "http" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8be7462df143984c4598a256ef469b251d7d7f9e271135073e78fc535414f3d0" -dependencies = [ - "bytes", - "itoa", -] - -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" -dependencies = [ - "bytes", - "futures-core", - "http", - "http-body", - "pin-project-lite", -] - -[[package]] -name = "httparse" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" - -[[package]] -name = "hyper" -version = "1.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" -dependencies = [ - "atomic-waker", - "bytes", - "futures-channel", - "futures-core", - "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ca68d021ef39cf6463ab54c1d0f5daf03377b70561305bb89a8f83aab66e0f" -dependencies = [ - "http", - "hyper", - "hyper-util", - "rustls", - "tokio", - "tokio-rustls", - "tower-service", - "webpki-roots", -] - -[[package]] -name = "hyper-util" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" -dependencies = [ - "base64", - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "hyper", - "ipnet", - "libc", - "percent-encoding", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", -] - [[package]] name = "icu_collections" version = "2.2.0" @@ -577,40 +351,12 @@ dependencies = [ "serde_core", ] -[[package]] -name = "ipnet" -version = "2.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98f6fed1fde3f8c21bc40a1abb88dd75e67924f9cffc3ef95607bad8017f8e2" - [[package]] name = "itoa" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" -[[package]] -name = "jobserver" -version = "0.1.34" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afb3de4395d6b3e67a780b6de64b51c978ecf11cb9a462c66be7d4ca9039d33" -dependencies = [ - "getrandom 0.3.4", - "libc", -] - -[[package]] -name = "js-sys" -version = "0.3.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "142bc4740e452c1e57ade0cbc129f139c9093e354346f0872ef985f4f5cf5f11" -dependencies = [ - "cfg-if", - "futures-util", - "once_cell", - "wasm-bindgen", -] - [[package]] name = "leb128fmt" version = "0.1.0" @@ -623,46 +369,6 @@ version = "0.2.186" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" -[[package]] -name = "libgit2-sys" -version = "0.18.5+1.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "005d6ae6eac1912906073e069f7db60b1fa98e052a68227824afe3e3a1c59ca2" -dependencies = [ - "cc", - "libc", - "libssh2-sys", - "libz-sys", - "openssl-sys", - "pkg-config", -] - -[[package]] -name = "libssh2-sys" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "220e4f05ad4a218192533b300327f5150e809b54c4ec83b5a1d91833601811b9" -dependencies = [ - "cc", - "libc", - "libz-sys", - "openssl-sys", - "pkg-config", - "vcpkg", -] - -[[package]] -name = "libz-sys" -version = "1.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85bc9657773828b90eeb625adff10eeac83cc21bbfd8e23a03eaa8a33c9e28d9" -dependencies = [ - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -681,29 +387,12 @@ version = "0.4.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "616ec5685824bcc94416c6d4a7a446eea774a31efd7062c8480ba6fd06d7a6e5" -[[package]] -name = "lru-slab" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "112b39cec0b298b6c1999fee3e31427f74f676e4cb9879ed1a121b43661a4154" - [[package]] name = "memchr" version = "2.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b947ae49db0d222b1dbc6b113ce7248a3fc3a6ca21b696717bfc000ba4484d8" -[[package]] -name = "mio" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" -dependencies = [ - "libc", - "wasi", - "windows-sys 0.61.2", -] - [[package]] name = "nix" version = "0.31.3" @@ -737,77 +426,18 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" -[[package]] -name = "openssl" -version = "0.10.80" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a45fa2aa886c42762255da344f0a0d313e254066c46aad76f300c3d3da62d967" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "openssl-macros", - "openssl-sys", -] - -[[package]] -name = "openssl-macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "openssl-probe" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" -[[package]] -name = "openssl-src" -version = "300.6.0+3.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8e8cbfd3a4a8c8f089147fd7aaa33cf8c7450c4d09f8f80698a0cf093abeff4" -dependencies = [ - "cc", -] - -[[package]] -name = "openssl-sys" -version = "0.9.116" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f28a22dc7140cda5f096e5e7724a6962ca81a7f8bfd2979f9b18c11af56318c4" -dependencies = [ - "cc", - "libc", - "openssl-src", - "pkg-config", - "vcpkg", -] - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "pin-project-lite" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" - -[[package]] -name = "pkg-config" -version = "0.3.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" - [[package]] name = "potential_utf" version = "0.1.5" @@ -817,15 +447,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "ppv-lite86" -version = "0.2.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" -dependencies = [ - "zerocopy", -] - [[package]] name = "prettyplease" version = "0.2.37" @@ -845,61 +466,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quinn" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" -dependencies = [ - "bytes", - "cfg_aliases", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls", - "socket2", - "thiserror", - "tokio", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-proto" -version = "0.11.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" -dependencies = [ - "bytes", - "getrandom 0.3.4", - "lru-slab", - "rand", - "ring", - "rustc-hash", - "rustls", - "rustls-pki-types", - "slab", - "thiserror", - "tinyvec", - "tracing", - "web-time", -] - -[[package]] -name = "quinn-udp" -version = "0.5.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "addec6a0dcad8a8d96a771f815f0eaf55f9d1805756410b39f5fa81332574cbd" -dependencies = [ - "cfg_aliases", - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.60.2", -] - [[package]] name = "quote" version = "1.0.45" @@ -909,107 +475,12 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "r-efi" -version = "5.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" - [[package]] name = "r-efi" version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" -[[package]] -name = "rand" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44c5af06bb1b7d3216d91932aed5265164bf384dc89cd6ba05cf59a35f5f76ea" -dependencies = [ - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" -dependencies = [ - "getrandom 0.3.4", -] - -[[package]] -name = "reqwest" -version = "0.12.28" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" -dependencies = [ - "base64", - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "js-sys", - "log", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "tokio", - "tokio-rustls", - "tower", - "tower-http", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", -] - -[[package]] -name = "ring" -version = "0.17.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" -dependencies = [ - "cc", - "cfg-if", - "getrandom 0.2.17", - "libc", - "untrusted", - "windows-sys 0.52.0", -] - -[[package]] -name = "rustc-hash" -version = "2.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94300abf3f1ae2e2b8ffb7b58043de3d399c73fa6f4b73826402a5c457614dbe" - [[package]] name = "rustix" version = "1.1.4" @@ -1024,17 +495,25 @@ dependencies = [ ] [[package]] -name = "rustls" -version = "0.23.40" +name = "rustls-native-certs" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "e5bfb394eeed242e909609f56089eecfe5fda225042e8b171791b9c95f5931e5" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "rustls-pki-types", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "once_cell", - "ring", "rustls-pki-types", - "rustls-webpki", - "subtle", - "zeroize", ] [[package]] @@ -1043,32 +522,40 @@ version = "1.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30a7197ae7eb376e574fe940d068c30fe0462554a3ddbe4eca7838e049c937a9" dependencies = [ - "web-time", "zeroize", ] [[package]] -name = "rustls-webpki" -version = "0.103.13" +name = "schannel" +version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c429a8649f110dddef65e2a5ad240f747e85f7758a6bccc7e5777bd33f756e" +checksum = "91c1b7e4904c873ef0710c1f407dde2e6287de2bebc1bbbf7d430bb7cbffd939" dependencies = [ - "ring", - "rustls-pki-types", - "untrusted", + "windows-sys 0.61.2", ] [[package]] -name = "rustversion" -version = "1.0.22" +name = "security-framework" +version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] [[package]] -name = "ryu" -version = "1.0.23" +name = "security-framework-sys" +version = "2.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" +checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3" +dependencies = [ + "core-foundation-sys", + "libc", +] [[package]] name = "self-replace" @@ -1139,18 +626,6 @@ dependencies = [ "serde_core", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha2" version = "0.10.9" @@ -1162,46 +637,18 @@ dependencies = [ "digest", ] -[[package]] -name = "shlex" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" - -[[package]] -name = "slab" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" - [[package]] name = "smallvec" version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" -[[package]] -name = "socket2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" -dependencies = [ - "libc", - "windows-sys 0.61.2", -] - [[package]] name = "stable_deref_trait" version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "subtle" -version = "2.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" - [[package]] name = "syn" version = "2.0.117" @@ -1213,15 +660,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" -dependencies = [ - "futures-core", -] - [[package]] name = "synstructure" version = "0.13.2" @@ -1240,32 +678,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom", "once_cell", "rustix", "windows-sys 0.61.2", ] -[[package]] -name = "thiserror" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "tinystr" version = "0.8.3" @@ -1276,45 +694,6 @@ dependencies = [ "zerovec", ] -[[package]] -name = "tinyvec" -version = "1.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e61e67053d25a4e82c844e8424039d9745781b3fc4f32b8d55ed50f5f667ef3" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - -[[package]] -name = "tokio" -version = "1.52.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc7f01b389ac15039e4dc9531aa973a135d7a4135281b12d7c1bc79fd57fffe" -dependencies = [ - "bytes", - "libc", - "mio", - "pin-project-lite", - "socket2", - "windows-sys 0.61.2", -] - -[[package]] -name = "tokio-rustls" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1729aa945f29d91ba541258c8df89027d5792d85a8841fb65e8bf0f4ede4ef61" -dependencies = [ - "rustls", - "tokio", -] - [[package]] name = "toml" version = "1.1.2+spec-1.1.0" @@ -1354,76 +733,6 @@ version = "1.1.1+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" -[[package]] -name = "tower" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4" -dependencies = [ - "futures-core", - "futures-util", - "pin-project-lite", - "sync_wrapper", - "tokio", - "tower-layer", - "tower-service", -] - -[[package]] -name = "tower-http" -version = "0.6.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" -dependencies = [ - "bitflags", - "bytes", - "futures-util", - "http", - "http-body", - "pin-project-lite", - "tower", - "tower-layer", - "tower-service", - "url", -] - -[[package]] -name = "tower-layer" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" - -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" -dependencies = [ - "once_cell", -] - -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "typenum" version = "1.20.1" @@ -1443,10 +752,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] -name = "untrusted" -version = "0.9.0" +name = "ureq" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" +checksum = "02d1a66277ed75f640d608235660df48c8e3c19f3b4edb6a263315626cc3c01d" +dependencies = [ + "base64", + "log", + "once_cell", + "rustls-native-certs", + "serde", + "serde_json", + "url", +] [[package]] name = "url" @@ -1466,33 +784,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - -[[package]] -name = "wasi" -version = "0.11.1+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" - [[package]] name = "wasip2" version = "1.0.3+wasi-0.2.9" @@ -1511,61 +808,6 @@ dependencies = [ "wit-bindgen 0.51.0", ] -[[package]] -name = "wasm-bindgen" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ed04576f974d2b2fba0f38c51dbc5518011e38c36bf1143164be765528fd409" -dependencies = [ - "cfg-if", - "once_cell", - "rustversion", - "wasm-bindgen-macro", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.72" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9473dbd2991ae90b6291c3c32c30c6187ac49aa32f9905d1cce280ec1e110b0f" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "916151b09da36bd82f6615cbf3a419e2f0ba23a03c6160e8e92eb6bd4aa1dec6" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "299047362ccbfce148b67ab7e73349f77748e00c8296f9542adfad2ad82c5c5e" -dependencies = [ - "bumpalo", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.122" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a929b2c61f11ba3e9bc35b50c1f25cb38e0e892c0c231ae2b8cf78d5dad4437" -dependencies = [ - "unicode-ident", -] - [[package]] name = "wasm-encoder" version = "0.244.0" @@ -1600,35 +842,6 @@ dependencies = [ "semver", ] -[[package]] -name = "web-sys" -version = "0.3.99" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d621441cfc37b84979402712047321980c178f299193a3589d05b99e8763436" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "web-time" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - -[[package]] -name = "webpki-roots" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" -dependencies = [ - "rustls-pki-types", -] - [[package]] name = "windows-link" version = "0.2.1" @@ -1641,16 +854,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-sys" -version = "0.60.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" -dependencies = [ - "windows-targets 0.53.5", + "windows-targets", ] [[package]] @@ -1668,31 +872,14 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm 0.52.6", - "windows_aarch64_msvc 0.52.6", - "windows_i686_gnu 0.52.6", - "windows_i686_gnullvm 0.52.6", - "windows_i686_msvc 0.52.6", - "windows_x86_64_gnu 0.52.6", - "windows_x86_64_gnullvm 0.52.6", - "windows_x86_64_msvc 0.52.6", -] - -[[package]] -name = "windows-targets" -version = "0.53.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" -dependencies = [ - "windows-link", - "windows_aarch64_gnullvm 0.53.1", - "windows_aarch64_msvc 0.53.1", - "windows_i686_gnu 0.53.1", - "windows_i686_gnullvm 0.53.1", - "windows_i686_msvc 0.53.1", - "windows_x86_64_gnu 0.53.1", - "windows_x86_64_gnullvm 0.53.1", - "windows_x86_64_msvc 0.53.1", + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", ] [[package]] @@ -1701,96 +888,48 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" - [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_aarch64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" - [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" -[[package]] -name = "windows_i686_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" - [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" - [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_i686_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" - [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnu" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" - [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" - [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "windows_x86_64_msvc" -version = "0.53.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" - [[package]] name = "winnow" version = "1.0.3" @@ -1920,26 +1059,6 @@ dependencies = [ "synstructure", ] -[[package]] -name = "zerocopy" -version = "0.8.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b065d4f0e55f82fae73202e189638116a87c55ab6b8e6c2721e13dd9d854ad1" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.8.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b631b19d36a892ab55420c92dbc83ccd79274f25be714855d3074aa71cab639" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "zerofrom" version = "0.1.8" diff --git a/Cargo.toml b/Cargo.toml index 85c448e..c599bce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dcr" -version = "0.7.2" +version = "0.7.3" edition = "2024" build = "build.rs" description = "DCR is a utility for managing C/C++ projects in a Cargo-like style." @@ -61,7 +61,7 @@ assets = [ [dependencies] glob = "0.3" -reqwest = { version = "0.12", default-features = false, features = ["blocking", "json", "rustls-tls"] } +ureq = { version = "2.10", default-features = false, features = ["json", "native-certs"] } serde = { version = "1", features = ["derive"] } self-replace = "1" sha2 = "0.10" @@ -69,21 +69,6 @@ toml = "1.0.3" serde_json = "1" ctrlc = "3" -[features] -default = ["vendored"] -vendored = [ - "git2/vendored-libgit2", - "git2/vendored-openssl", - "openssl/vendored", -] - -[target.'cfg(not(windows))'.dependencies] -git2 = "0.20.4" -openssl = "0.10" - -[target.'cfg(windows)'.dependencies] -git2 = "0.20.4" - [profile.release] opt-level = "z" lto = "thin" diff --git a/README.md b/README.md index 08ab808..dd18355 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Linux (Dexoron Packages) -See https://dcr.dexoron.su for settings youre packages manager +See https://pkg.dexoron.su for settings youre packages manager **Arch Linux:** diff --git a/build.rs b/build.rs index 3e0ba11..b18c764 100644 --- a/build.rs +++ b/build.rs @@ -18,4 +18,37 @@ fn main() { let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown-target".to_string()); println!("cargo:rustc-env=DCR_TARGET={target}"); + + // Let's try to retrieve the commit hash for the version + let commit = std::process::Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .output() + .ok() + .and_then(|o| { + if o.status.success() { + String::from_utf8(o.stdout) + .ok() + .map(|s| s.trim().to_string()) + } else { + None + } + }); + + // Check if there are any uncommitted changes in the repository + let is_dirty = std::process::Command::new("git") + .args(["status", "--porcelain"]) + .output() + .ok() + .map(|o| o.status.success() && !o.stdout.is_empty()) + .unwrap_or(false); + + if let Some(commit_hash) = commit { + let dirty_suffix = if is_dirty { "-dirty" } else { "" }; + println!( + "cargo:rustc-env=DCR_GIT_INFO= (git {}{})", + commit_hash, dirty_suffix + ); + } else { + println!("cargo:rustc-env=DCR_GIT_INFO="); + } } diff --git a/docs/getting-started/installation.mdx b/docs/getting-started/installation.mdx index 956bf44..cdc55fd 100644 --- a/docs/getting-started/installation.mdx +++ b/docs/getting-started/installation.mdx @@ -6,7 +6,7 @@ sidebar_label: Installation ## Linux (Dexoron Packages) -Configure your package manager at https://dcr.dexoron.su and install: +Configure your package manager at https://pkg.dexoron.su and install: **Arch Linux** ```sh diff --git a/src/cli/flag_update.rs b/src/cli/flag_update.rs index 5d54dc9..5b4c5b4 100644 --- a/src/cli/flag_update.rs +++ b/src/cli/flag_update.rs @@ -17,9 +17,9 @@ use crate::utils::log::{error, warn}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, printc}; -use reqwest::blocking::Client; use serde::Deserialize; use std::fs; +use std::io::Read; use std::path::{Path, PathBuf}; #[cfg(target_os = "linux")] use std::process::Command; @@ -72,15 +72,8 @@ pub fn flag_update(args: &[String]) -> i32 { let current_version = env!("CARGO_PKG_VERSION"); let target = env!("DCR_TARGET"); - let client = match Client::builder().user_agent("dcr-updater").build() { - Ok(client) => client, - Err(_) => { - error("Failed to initialize HTTP client"); - return 1; - } - }; - let release = match fetch_latest_release(&client) { + let release = match fetch_latest_release() { Ok(release) => release, Err(err) => { error(&format!("Failed to check for updates: {err}")); @@ -104,7 +97,7 @@ pub fn flag_update(args: &[String]) -> i32 { return 1; }; - let bytes = match download_asset(&client, &asset.browser_download_url) { + let bytes = match download_asset(&asset.browser_download_url) { Ok(bytes) => bytes, Err(err) => { error(&format!("Failed to download update: {err}")); @@ -131,35 +124,35 @@ pub fn flag_update(args: &[String]) -> i32 { 0 } -fn fetch_latest_release(client: &Client) -> Result { - let response = client - .get(LATEST_RELEASE_URL) - .send() - .map_err(|_| "GitHub API request failed".to_string())?; - - if !response.status().is_success() { - return Err(format!("GitHub API returned status {}", response.status())); - } +fn fetch_latest_release() -> Result { + let response = ureq::get(LATEST_RELEASE_URL) + .set("User-Agent", "dcr-updater") + .call() + .map_err(|e| match e { + ureq::Error::Status(code, _) => format!("GitHub API returned status {code}"), + ureq::Error::Transport(e) => format!("GitHub API request failed: {e}"), + })?; response - .json::() + .into_json::() .map_err(|_| "GitHub API response has an unexpected format".to_string()) } -fn download_asset(client: &Client, url: &str) -> Result, String> { - let response = client - .get(url) - .send() - .map_err(|_| "Download request failed".to_string())?; +fn download_asset(url: &str) -> Result, String> { + let response = ureq::get(url) + .set("User-Agent", "dcr-updater") + .call() + .map_err(|e| match e { + ureq::Error::Status(code, _) => format!("Download returned status {code}"), + ureq::Error::Transport(e) => format!("Download request failed: {e}"), + })?; - if !response.status().is_success() { - return Err(format!("Download returned status {}", response.status())); - } - - response - .bytes() - .map(|bytes| bytes.to_vec()) - .map_err(|_| "Failed to read downloaded data".to_string()) + let mut reader = response.into_reader(); + let mut data = Vec::new(); + reader + .read_to_end(&mut data) + .map_err(|_| "Failed to read downloaded data".to_string())?; + Ok(data) } fn asset_candidates(target: &str) -> Vec { diff --git a/src/cli/init.rs b/src/cli/init.rs index 28fa7d3..2183131 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -17,6 +17,7 @@ use crate::config::FILE_MAIN_C; use crate::core::config::{Config, validate_package_name}; +use crate::core::vcs::VcsKind; use crate::utils::fs::check_dir; use crate::utils::log::{error, warn}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; @@ -27,7 +28,7 @@ use toml::Value; pub fn init(args: &[String]) -> i32 { if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr init", BOLD_CYAN); + printc(" dcr init [--vcs ]", BOLD_CYAN); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Initializes the current directory as a DCR project."); @@ -35,7 +36,25 @@ pub fn init(args: &[String]) -> i32 { return 0; } - if !args.is_empty() { + let mut vcs_str = None; + let mut clean_args = Vec::new(); + let mut iter = args.iter(); + while let Some(arg) = iter.next() { + if arg == "--vcs" { + if let Some(val) = iter.next() { + vcs_str = Some(val.clone()); + } else { + error("--vcs requires a value"); + return 1; + } + } else if let Some(stripped) = arg.strip_prefix("--vcs=") { + vcs_str = Some(stripped.to_string()); + } else { + clean_args.push(arg.clone()); + } + } + + if !clean_args.is_empty() { warn("Command does not support additional arguments"); return 1; } @@ -106,6 +125,40 @@ pub fn init(args: &[String]) -> i32 { colored("src/main.c", BOLD_CYAN) ); + // settings VCS + let mut vcs_kind = VcsKind::Git; + if let Some(ref vcs_val) = vcs_str { + match VcsKind::parse(vcs_val) { + Ok(kind) => vcs_kind = kind, + Err(e) => { + error(&e); + return 1; + } + } + } else if let Ok(cwd_path) = std::env::current_dir() + && crate::core::vcs::find_existing_vcs(&cwd_path).is_some() + { + vcs_kind = VcsKind::None; + } + + if vcs_kind == VcsKind::Git { + if crate::utils::git::is_git_available() { + let project_path = std::path::Path::new("."); + if let Err(e) = crate::core::vcs::init_vcs(vcs_kind, project_path) { + warn(&format!("Failed to initialize git repository: {}", e)); + } else { + println!( + " {} Initialized git repository", + colored("✔", BOLD_GREEN) + ); + } + } else { + warn( + "Git is not installed or not found in PATH. Skipping Git repository initialization.", + ); + } + } + println!( "Project `{}` successfully created\n", colored(project_name.as_str(), BOLD_GREEN) diff --git a/src/cli/new.rs b/src/cli/new.rs index 661c610..599af78 100644 --- a/src/cli/new.rs +++ b/src/cli/new.rs @@ -17,6 +17,7 @@ use crate::config::FILE_MAIN_C; use crate::core::config::{Config, validate_package_name}; +use crate::core::vcs::VcsKind; use crate::utils::fs::check_dir; use crate::utils::log::{error, warn}; use crate::utils::text::{BOLD_CYAN, BOLD_GREEN, colored, printc}; @@ -27,7 +28,7 @@ use toml::Value; pub fn new(args: &[String]) -> i32 { if args.first().is_some_and(|a| a == "--help") { printc("USAGE:", BOLD_GREEN); - printc(" dcr new ", BOLD_CYAN); + printc(" dcr new [--vcs ]", BOLD_CYAN); println!(); printc("DESCRIPTION:", BOLD_GREEN); println!(" Creates a new C/C++ project with the given name."); @@ -37,16 +38,34 @@ pub fn new(args: &[String]) -> i32 { let items = check_dir(None).unwrap_or_default(); - if args.is_empty() { + let mut vcs_str = None; + let mut clean_args = Vec::new(); + let mut iter = args.iter(); + while let Some(arg) = iter.next() { + if arg == "--vcs" { + if let Some(val) = iter.next() { + vcs_str = Some(val.clone()); + } else { + error("--vcs requires a value"); + return 1; + } + } else if let Some(stripped) = arg.strip_prefix("--vcs=") { + vcs_str = Some(stripped.to_string()); + } else { + clean_args.push(arg.clone()); + } + } + + if clean_args.is_empty() { error("Project name not specified"); return 1; } - if args.len() > 1 { + if clean_args.len() > 1 { warn("Command does not support additional arguments"); return 1; } - let project_name = &args[0]; + let project_name = &clean_args[0]; println!( "Creating a Project `{}`...", colored(project_name, BOLD_CYAN) @@ -127,6 +146,40 @@ pub fn new(args: &[String]) -> i32 { colored("src/main.c", BOLD_CYAN) ); + // settings VCS + let mut vcs_kind = VcsKind::Git; + if let Some(ref vcs_val) = vcs_str { + match VcsKind::parse(vcs_val) { + Ok(kind) => vcs_kind = kind, + Err(e) => { + error(&e); + return 1; + } + } + } else if let Ok(cwd) = std::env::current_dir() + && crate::core::vcs::find_existing_vcs(&cwd).is_some() + { + vcs_kind = VcsKind::None; + } + + if vcs_kind == VcsKind::Git { + if crate::utils::git::is_git_available() { + let project_path = std::path::Path::new(project_name); + if let Err(e) = crate::core::vcs::init_vcs(vcs_kind, project_path) { + warn(&format!("Failed to initialize git repository: {}", e)); + } else { + println!( + " {} Initialized git repository", + colored("✔", BOLD_GREEN) + ); + } + } else { + warn( + "Git is not installed or not found in PATH. Skipping Git repository initialization.", + ); + } + } + println!( "Project `{}` successfully created\n", colored(project_name, BOLD_GREEN) diff --git a/src/core/deps/git.rs b/src/core/deps/git.rs index 710ceea..2ca84e8 100644 --- a/src/core/deps/git.rs +++ b/src/core/deps/git.rs @@ -29,43 +29,5 @@ pub fn fetch_git_dep( return Ok(()); } - let mut builder = git2::build::RepoBuilder::new(); - if let Some(b) = branch { - builder.branch(b); - } - - let repo = builder - .clone(url, target_dir) - .map_err(|e| format!("failed to clone {}: {}", url, e))?; - - if let Some(t) = tag { - checkout_ref(&repo, &format!("refs/tags/{}", t))?; - } else if let Some(r) = rev { - checkout_ref(&repo, r)?; - } - - Ok(()) -} - -#[allow(dead_code)] -fn checkout_ref(repo: &git2::Repository, reference_str: &str) -> Result<(), String> { - let (object, reference) = repo - .revparse_ext(reference_str) - .map_err(|e| format!("failed to find ref {}: {}", reference_str, e))?; - - repo.checkout_tree(&object, None).map_err(|e| { - let ref_name = reference.as_ref().and_then(|r| r.name()).unwrap_or("HEAD"); - format!("failed to checkout {}: {}", ref_name, e) - })?; - - match reference { - Some(gref) => { - let ref_name = gref.name().unwrap_or("HEAD"); - repo.set_head(ref_name) - } - None => repo.set_head_detached(object.id()), - } - .map_err(|e| format!("failed to set HEAD: {}", e))?; - - Ok(()) + crate::utils::git::git_clone_and_checkout(url, target_dir, branch, tag, rev) } diff --git a/src/core/mod.rs b/src/core/mod.rs index 43eec38..ed33f0d 100644 --- a/src/core/mod.rs +++ b/src/core/mod.rs @@ -20,4 +20,5 @@ pub mod config; pub mod deps; pub mod registry; pub mod runner; +pub mod vcs; pub mod workspace; diff --git a/src/core/vcs/git.rs b/src/core/vcs/git.rs new file mode 100644 index 0000000..83696f1 --- /dev/null +++ b/src/core/vcs/git.rs @@ -0,0 +1,32 @@ +// DCR — Cargo-like C/C++ project manager. +// +// Copyright (C) 2026 Dexoron (Bezotechestvo Vladimir) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use std::fs; +use std::path::Path; + +// creating git init and .gitignore +pub fn init(path: &Path) -> Result<(), String> { + crate::utils::git::git_init(path)?; + + let gitignore_path = path.join(".gitignore"); + if !gitignore_path.exists() { + fs::write(&gitignore_path, "/target\n") + .map_err(|e| format!("failed to create .gitignore: {}", e))?; + } + + Ok(()) +} diff --git a/src/core/vcs/mod.rs b/src/core/vcs/mod.rs new file mode 100644 index 0000000..8d2e593 --- /dev/null +++ b/src/core/vcs/mod.rs @@ -0,0 +1,61 @@ +// DCR — Cargo-like C/C++ project manager. +// +// Copyright (C) 2026 Dexoron (Bezotechestvo Vladimir) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pub mod git; + +use std::path::Path; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum VcsKind { + Git, + None, +} + +impl VcsKind { + pub fn parse(s: &str) -> Result { + match s.to_lowercase().as_str() { + "git" => Ok(Self::Git), + "none" => Ok(Self::None), + _ => Err(format!("Unknown VCS: {}", s)), + } + } +} + +pub fn init_vcs(kind: VcsKind, path: &Path) -> Result<(), String> { + match kind { + VcsKind::Git => git::init(path), + VcsKind::None => Ok(()), + } +} + +// look for git repo in parents to avoid nested repos +pub fn find_existing_vcs(path: &Path) -> Option { + let mut current = if path.is_file() { + path.parent() + } else { + Some(path) + }; + + while let Some(dir) = current { + if dir.join(".git").exists() { + return Some(VcsKind::Git); + } + current = dir.parent(); + } + + None +} diff --git a/src/main.rs b/src/main.rs index fcb0ae7..361029e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,7 +44,12 @@ fn main() { "clean" => cli::clean::clean(rest), "gen" => cli::r#gen::r#gen(rest), "--version" => { - println!("dcr {} ({})", env!("CARGO_PKG_VERSION"), env!("DCR_TARGET")); + println!( + "dcr {}{} ({})", + env!("CARGO_PKG_VERSION"), + env!("DCR_GIT_INFO"), + env!("DCR_TARGET") + ); 0 } "--help" => cli::help::help(), diff --git a/src/utils/git.rs b/src/utils/git.rs new file mode 100644 index 0000000..ed83dc1 --- /dev/null +++ b/src/utils/git.rs @@ -0,0 +1,112 @@ +// DCR — Cargo-like C/C++ project manager. +// +// Copyright (C) 2026 Dexoron (Bezotechestvo Vladimir) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +use std::path::Path; +use std::process::Command; + +// checking installed git on system +pub fn is_git_available() -> bool { + Command::new("git") + .arg("--version") + .output() + .map(|o| o.status.success()) + .unwrap_or(false) +} + +// warning of git not in system +#[allow(dead_code)] +pub fn warn_if_git_missing() { + if !is_git_available() { + crate::utils::log::warn( + "Git is not installed or not found in PATH. Some features (like dependency cloning and VCS initialization) may fail.", + ); + } +} + +// init repo in folder +pub fn git_init(path: &Path) -> Result<(), String> { + if !is_git_available() { + return Err("git executable not found in PATH".to_string()); + } + + let status = Command::new("git") + .arg("init") + .current_dir(path) + .status() + .map_err(|e| format!("failed to execute git init: {}", e))?; + + if !status.success() { + return Err("git init failed".to_string()); + } + + Ok(()) +} + +// Clone the dependency and switch to the branch/tag/commit +#[allow(dead_code)] +pub fn git_clone_and_checkout( + url: &str, + target_dir: &Path, + branch: Option<&str>, + tag: Option<&str>, + rev: Option<&str>, +) -> Result<(), String> { + if !is_git_available() { + return Err("git executable not found in PATH".to_string()); + } + + let mut args = vec!["clone"]; + + if let Some(b) = branch { + args.push("--branch"); + args.push(b); + args.push("--single-branch"); + } else if let Some(t) = tag { + args.push("--branch"); + args.push(t); + args.push("--single-branch"); + } + + args.push(url); + + let target_dir_str = target_dir.to_string_lossy().to_string(); + args.push(&target_dir_str); + + let status = Command::new("git") + .args(&args) + .status() + .map_err(|e| format!("failed to execute git clone: {}", e))?; + + if !status.success() { + return Err(format!("git clone of {} failed", url)); + } + + if let Some(r) = rev { + let checkout_status = Command::new("git") + .arg("checkout") + .arg(r) + .current_dir(target_dir) + .status() + .map_err(|e| format!("failed to execute git checkout: {}", e))?; + + if !checkout_status.success() { + return Err(format!("git checkout to revision {} failed", r)); + } + } + + Ok(()) +} diff --git a/src/utils/mod.rs b/src/utils/mod.rs index c4cdcdd..1a955c3 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -17,5 +17,6 @@ pub mod build; pub mod fs; +pub mod git; pub mod log; pub mod text; diff --git a/tests/cli_basic.rs b/tests/cli_basic.rs index fd55ce9..9fc3704 100644 --- a/tests/cli_basic.rs +++ b/tests/cli_basic.rs @@ -99,6 +99,60 @@ fn new_creates_project_layout() { ); } +fn is_git_in_path() -> bool { + std::process::Command::new("git") + .arg("--version") + .output() + .map(|o| o.status.success()) + .unwrap_or(false) +} + +#[test] +fn new_vcs_options_work() { + // 1. Test --vcs none + let dir = unique_sandbox_dir("new_vcs_none"); + let out = run_dcr(&["new", "hello_none", "--vcs", "none"], &dir); + assert!(out.status.success(), "dcr new --vcs none should succeed"); + let project_dir = dir.join("hello_none"); + assert!(project_dir.is_dir()); + assert!(!project_dir.join(".git").exists()); + assert!(!project_dir.join(".gitignore").exists()); + + // 2. Test --vcs git + if is_git_in_path() { + let dir = unique_sandbox_dir("new_vcs_git"); + let out = run_dcr(&["new", "hello_git", "--vcs", "git"], &dir); + assert!(out.status.success(), "dcr new --vcs git should succeed"); + let project_dir = dir.join("hello_git"); + assert!(project_dir.is_dir()); + assert!(project_dir.join(".git").is_dir()); + assert!(project_dir.join(".gitignore").is_file()); + let gitignore = std::fs::read_to_string(project_dir.join(".gitignore")).unwrap(); + assert!(gitignore.contains("/target")); + } +} + +#[test] +fn init_vcs_options_work() { + // 1. Test --vcs none + let dir = unique_sandbox_dir("init_vcs_none"); + let out = run_dcr(&["init", "--vcs", "none"], &dir); + assert!(out.status.success(), "dcr init --vcs none should succeed"); + assert!(!dir.join(".git").exists()); + assert!(!dir.join(".gitignore").exists()); + + // 2. Test --vcs git + if is_git_in_path() { + let dir = unique_sandbox_dir("init_vcs_git"); + let out = run_dcr(&["init", "--vcs", "git"], &dir); + assert!(out.status.success(), "dcr init --vcs git should succeed"); + assert!(dir.join(".git").is_dir()); + assert!(dir.join(".gitignore").is_file()); + let gitignore = std::fs::read_to_string(dir.join(".gitignore")).unwrap(); + assert!(gitignore.contains("/target")); + } +} + #[test] fn init_and_clean_remove_target() { let dir = unique_sandbox_dir("init");