From f07eba84ee389512c527e642fdaf38265516450b Mon Sep 17 00:00:00 2001 From: Brandon LeBlanc Date: Tue, 2 Jul 2024 19:24:26 -0700 Subject: [PATCH] Initial commit --- .cargo/config.toml | 18 + .github/workflows/ci.yml | 75 + .gitignore | 17 + .rustfmt.toml | 9 + Cargo.lock | 1830 +++++++++++++++++ Cargo.toml | 32 + LICENSE-APACHE | 176 ++ LICENSE-MIT | 23 + README.md | 60 + crates/git-remote-codecommit/Cargo.toml | 27 + crates/git-remote-codecommit/LICENSE-APACHE | 1 + crates/git-remote-codecommit/LICENSE-MIT | 1 + .../src/canonical_request.rs | 31 + .../src/credential_scope.rs | 18 + crates/git-remote-codecommit/src/datetime.rs | 40 + crates/git-remote-codecommit/src/hex.rs | 21 + crates/git-remote-codecommit/src/hostname.rs | 21 + crates/git-remote-codecommit/src/logging.rs | 23 + crates/git-remote-codecommit/src/main.rs | 179 ++ .../git-remote-codecommit/src/sdk_context.rs | 90 + .../src/string_to_sign.rs | 28 + crates/git-remote-codecommit/src/uri/error.rs | 36 + crates/git-remote-codecommit/src/uri/mod.rs | 150 ++ crates/git-remote-codecommit/src/urlsafe.rs | 28 + crates/git-remote-codecommit/src/username.rs | 15 + 25 files changed, 2949 insertions(+) create mode 100644 .cargo/config.toml create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .rustfmt.toml create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT create mode 100644 README.md create mode 100644 crates/git-remote-codecommit/Cargo.toml create mode 120000 crates/git-remote-codecommit/LICENSE-APACHE create mode 120000 crates/git-remote-codecommit/LICENSE-MIT create mode 100644 crates/git-remote-codecommit/src/canonical_request.rs create mode 100644 crates/git-remote-codecommit/src/credential_scope.rs create mode 100644 crates/git-remote-codecommit/src/datetime.rs create mode 100644 crates/git-remote-codecommit/src/hex.rs create mode 100644 crates/git-remote-codecommit/src/hostname.rs create mode 100644 crates/git-remote-codecommit/src/logging.rs create mode 100644 crates/git-remote-codecommit/src/main.rs create mode 100644 crates/git-remote-codecommit/src/sdk_context.rs create mode 100644 crates/git-remote-codecommit/src/string_to_sign.rs create mode 100644 crates/git-remote-codecommit/src/uri/error.rs create mode 100644 crates/git-remote-codecommit/src/uri/mod.rs create mode 100644 crates/git-remote-codecommit/src/urlsafe.rs create mode 100644 crates/git-remote-codecommit/src/username.rs diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000..78f4bbe --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,18 @@ +[alias] +__vendored = [ + "--config", + "source.crates-io.replace-with = \"vendored-sources\"", + "--frozen", + "--offline", +] + +v-check = "__vendored check" +v-clippy = "__vendored clippy" +v-build = "__vendored build" +v-run = "__vendored run" +v-test = "__vendored test" + +v = "vendor --verbose --versioned-dirs" + +[source.vendored-sources] +directory = "vendor" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2a61aed --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: ci +on: + pull_request: + push: + branches: + - main + +env: + RUST_BACKTRACE: "1" + +jobs: + style: + name: Check Style + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust (nightly) + uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly + components: rustfmt + + - run: cargo fmt --all --check + + check-and-test: + name: Run Clippy Checks and Tests + needs: [style] + strategy: + matrix: + os: + - ubuntu-latest + # - macos-latest + # - windows-latest + rust: + # - stable + # - beta + - nightly + runs-on: ${{ matrix.os }} + env: + RUSTFLAGS: "-D warnings" + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust (${{ matrix.rust }}) + uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + components: clippy + + - name: Setup Cache + uses: Swatinem/rust-cache@v2 + with: + prefix-key: v0-rust + shared-key: ${{ matrix.os }}-${{ matrix.rust }} + + - name: Run Clippy (no default features) + run: cargo clippy --workspace --tests --no-default-features + + - name: Run Clippy (default features) + run: cargo clippy --workspace --tests + + - name: Run Clippy (all features) + run: cargo clippy --workspace --tests --all-features + + - name: Run Tests (no default features) + run: cargo test --workspace --no-default-features + + - name: Run Tests (default features) + run: cargo test --workspace + + - name: Run Tests (all features) + run: cargo test --workspace --all-features \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f414bfa --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +# Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +# Do not ignore anything inside of `vendor` +!vendor/** diff --git a/.rustfmt.toml b/.rustfmt.toml new file mode 100644 index 0000000..990f399 --- /dev/null +++ b/.rustfmt.toml @@ -0,0 +1,9 @@ +format_macro_matchers = true +group_imports = "StdExternalCrate" +imports_granularity = "Item" +normalize_comments = true +normalize_doc_attributes = true +overflow_delimited_expr = true +use_field_init_shorthand = true +use_try_shorthand = true +wrap_comments = true \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..587470f --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1830 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anstream" +version = "0.6.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" + +[[package]] +name = "anstyle-parse" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad186efb764318d35165f1758e7dcef3b10628e26d41a44bc5550652e6804391" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" +dependencies = [ + "anstyle", + "windows-sys 0.52.0", +] + +[[package]] +name = "anyhow" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "aws-config" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2368fb843e9eec932f7789d64d0e05850f4a79067188c657e572f1f5a7589df0" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-sdk-sso", + "aws-sdk-ssooidc", + "aws-sdk-sts", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "hex", + "http 0.2.12", + "hyper", + "ring", + "time", + "tokio", + "tracing", + "url", + "zeroize", +] + +[[package]] +name = "aws-credential-types" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9" +dependencies = [ + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "zeroize", +] + +[[package]] +name = "aws-runtime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a4a5e448145999d7de17bf44a886900ecb834953408dae8aaf90465ce91c1dd" +dependencies = [ + "aws-credential-types", + "aws-sigv4", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "fastrand", + "http 0.2.12", + "http-body 0.4.6", + "percent-encoding", + "pin-project-lite", + "tracing", + "uuid", +] + +[[package]] +name = "aws-sdk-sso" +version = "1.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8aee358b755b2738b3ffb8a5b54ee991b28c8a07483a0ff7d49a58305cc2609" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-ssooidc" +version = "1.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d5ce026f0ae73e06b20be5932150dd0e9b063417fd7c3acf5ca97018b9cbd64" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-types", + "bytes", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sdk-sts" +version = "1.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c820248cb02e4ea83630ad2e43d0721cdbccedba5ac902cd0b6fb84d7271f205" +dependencies = [ + "aws-credential-types", + "aws-runtime", + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-json", + "aws-smithy-query", + "aws-smithy-runtime", + "aws-smithy-runtime-api", + "aws-smithy-types", + "aws-smithy-xml", + "aws-types", + "http 0.2.12", + "once_cell", + "regex-lite", + "tracing", +] + +[[package]] +name = "aws-sigv4" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce" +dependencies = [ + "aws-credential-types", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "form_urlencoded", + "hex", + "hmac", + "http 0.2.12", + "http 1.1.0", + "once_cell", + "percent-encoding", + "sha2", + "time", + "tracing", +] + +[[package]] +name = "aws-smithy-async" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62220bc6e97f946ddd51b5f1361f78996e704677afc518a4ff66b7a72ea1378c" +dependencies = [ + "futures-util", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "aws-smithy-http" +version = "0.60.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08" +dependencies = [ + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "bytes-utils", + "futures-core", + "http 0.2.12", + "http-body 0.4.6", + "once_cell", + "percent-encoding", + "pin-project-lite", + "pin-utils", + "tracing", +] + +[[package]] +name = "aws-smithy-json" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4683df9469ef09468dad3473d129960119a0d3593617542b7d52086c8486f2d6" +dependencies = [ + "aws-smithy-types", +] + +[[package]] +name = "aws-smithy-query" +version = "0.60.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb" +dependencies = [ + "aws-smithy-types", + "urlencoding", +] + +[[package]] +name = "aws-smithy-runtime" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db83b08939838d18e33b5dbaf1a0f048f28c10bd28071ab7ce6f245451855414" +dependencies = [ + "aws-smithy-async", + "aws-smithy-http", + "aws-smithy-runtime-api", + "aws-smithy-types", + "bytes", + "fastrand", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "http-body 1.0.0", + "httparse", + "hyper", + "hyper-rustls", + "once_cell", + "pin-project-lite", + "pin-utils", + "rustls", + "tokio", + "tracing", +] + +[[package]] +name = "aws-smithy-runtime-api" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b570ea39eb95bd32543f6e4032bce172cb6209b9bc8c83c770d08169e875afc" +dependencies = [ + "aws-smithy-async", + "aws-smithy-types", + "bytes", + "http 0.2.12", + "http 1.1.0", + "pin-project-lite", + "tokio", + "tracing", + "zeroize", +] + +[[package]] +name = "aws-smithy-types" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfe321a6b21f5d8eabd0ade9c55d3d0335f3c3157fc2b3e87f05f34b539e4df5" +dependencies = [ + "base64-simd", + "bytes", + "bytes-utils", + "http 0.2.12", + "http 1.1.0", + "http-body 0.4.6", + "http-body 1.0.0", + "http-body-util", + "itoa", + "num-integer", + "pin-project-lite", + "pin-utils", + "ryu", + "serde", + "time", +] + +[[package]] +name = "aws-smithy-xml" +version = "0.60.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d123fbc2a4adc3c301652ba8e149bf4bc1d1725affb9784eb20c953ace06bf55" +dependencies = [ + "xmlparser", +] + +[[package]] +name = "aws-types" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2009a9733865d0ebf428a314440bbe357cc10d0c16d86a8e15d32e9b47c1e80e" +dependencies = [ + "aws-credential-types", + "aws-smithy-async", + "aws-smithy-runtime-api", + "aws-smithy-types", + "rustc_version", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + +[[package]] +name = "base64" +version = "0.21.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" + +[[package]] +name = "base64-simd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339abbe78e73178762e23bea9dfd08e697eb3f3301cd4be981c0f78ba5859195" +dependencies = [ + "outref", + "vsimd", +] + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block-buffer" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" +dependencies = [ + "generic-array", +] + +[[package]] +name = "bytes" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" + +[[package]] +name = "bytes-utils" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dafe3a8757b027e2be6e4e5601ed563c55989fcf1546e933c66c8eb3a058d35" +dependencies = [ + "bytes", + "either", +] + +[[package]] +name = "cc" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" +dependencies = [ + "num-traits", +] + +[[package]] +name = "clap" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", + "terminal_size", +] + +[[package]] +name = "clap_derive" +version = "4.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b82cf0babdbd58558212896d1a4272303a57bdb245c2bf1147185fb45640e70" + +[[package]] +name = "colorchoice" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" + +[[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.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "cpufeatures" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53fe5e26ff1b7aef8bca9c6080520cfb8d9333c7568e1829cef191a9723e5504" +dependencies = [ + "libc", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "digest" +version = "0.10.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" +dependencies = [ + "block-buffer", + "crypto-common", + "subtle", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "exec" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886b70328cba8871bfc025858e1de4be16b1d5088f2ba50b57816f4210672615" +dependencies = [ + "errno 0.2.8", + "libc", +] + +[[package]] +name = "fastrand" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fc0510504f03c51ada170672ac806f1f105a88aa97a5281117e1ddc3368e51a" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" + +[[package]] +name = "futures-sink" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" + +[[package]] +name = "futures-task" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" + +[[package]] +name = "futures-util" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gimli" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" + +[[package]] +name = "git-remote-codecommit" +version = "0.1.0" +dependencies = [ + "anyhow", + "aws-config", + "aws-credential-types", + "aws-sigv4", + "chrono", + "clap", + "exec", + "hmac", + "sha2", + "tokio", + "tracing", + "tracing-subscriber", + "uriparse", +] + +[[package]] +name = "h2" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" +dependencies = [ + "digest", +] + +[[package]] +name = "http" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" +dependencies = [ + "bytes", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.0", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "0.14.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f361cde2f109281a220d4307746cdfd5ee3f410da58a70377762396775634b33" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http 0.2.12", + "http-body 0.4.6", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590" +dependencies = [ + "futures-util", + "http 0.2.12", + "hyper", + "log", + "rustls", + "rustls-native-certs", + "tokio", + "tokio-rustls", +] + +[[package]] +name = "idna" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "miniz_oxide" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" +dependencies = [ + "adler", +] + +[[package]] +name = "mio" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" +dependencies = [ + "libc", + "wasi", + "windows-sys 0.48.0", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "081b846d1d56ddfc18fdf1a922e4f6e07a11768ea1b92dec44e42b72712ccfce" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "outref" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4030760ffd992bef45b0ae3f10ce1aba99e33464c90d14dd7c039884963ddc7a" + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.7", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.4", +] + +[[package]] +name = "regex-lite" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a" + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags", + "errno 0.3.9", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustls" +version = "0.21.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e" +dependencies = [ + "log", + "ring", + "rustls-webpki", + "sct", +] + +[[package]] +name = "rustls-native-certs" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00" +dependencies = [ + "openssl-probe", + "rustls-pemfile", + "schannel", + "security-framework", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +dependencies = [ + "base64", +] + +[[package]] +name = "rustls-webpki" +version = "0.101.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b6275d1ee7a1cd780b64aca7726599a1dbc893b1e64144529e55c3c2f745765" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "schannel" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "sct" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da046153aa2352493d6cb7da4b6e5c0c057d8a1d0a9aa8560baffdd945acd414" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "security-framework" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317936bbbd05227752583946b9e66d7ce3b489f84e11a94a510b4437fef407d7" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.203" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "socket2" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce305eb0b4296696835b71df73eb912e0f1ffd2556a501fcede6e0c50349191c" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[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.68" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "terminal_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21bebf2b7c9e0a515f6e0f8c51dc0f8e4696391e6f1ff30379559f8365fb0df7" +dependencies = [ + "rustix", + "windows-sys 0.48.0", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c55115c6fbe2d2bef26eb09ad74bde02d8255476fc0c7b515ef09fbb35742d82" +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.38.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "windows-sys 0.48.0", +] + +[[package]] +name = "tokio-rustls" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28327cf380ac148141087fbfb9de9d7bd4e84ab5d2c28fbc911d753de8a7081" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[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.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" + +[[package]] +name = "unicode-bidi" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unicode-normalization" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "uriparse" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0200d0fc04d809396c2ad43f3c95da3582a2556eba8d453c1087f4120ee352ff" +dependencies = [ + "fnv", + "lazy_static", +] + +[[package]] +name = "url" +version = "2.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "uuid" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "vsimd" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c3082ca00d5a5ef149bb8b555a72ae84c9c59f7250f013ac822ac2e49b19c64" + +[[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.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" +dependencies = [ + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" + +[[package]] +name = "xmlparser" +version = "0.13.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8a12c0f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,32 @@ +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[workspace] +members = ["crates/*"] +resolver = "2" + +[workspace.package] +version = "0.1.0" +authors = ["Brandon LeBlanc "] +repository = "https://github.com/demosdemon/git-remote-codecommit" +homepage = "https://github.com/demosdemon/git-remote-codecommit" +edition = "2021" +license = "MIT or Apache-2.0" +publish = false + +[workspace.lints.rust] +let_underscore_drop = "warn" +# unused_crate_dependencies = "warn" +non_ascii_idents = "deny" + +[workspace.lints.clippy] +uninlined_format_args = "warn" +cargo_common_metadata = "warn" +# multiple_crate_versions = "warn" +negative_feature_names = "warn" +redundant_feature_names = "warn" +wildcard_dependencies = "deny" +unwrap_used = "warn" + +[profile.release-lto] +inherits = "release" +lto = "fat" diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..1b5ec8b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..30da30f --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# git-remote-codecommit + +This is an implementation of [git-remote-codecommit](https://github.com/aws/git-remote-codecommit) +written in Rust so that statically linked binaries can be generated instead of depending +on Python. + +## Install + +```shell +$ cargo install --locked --profile=release-lto --git='https://github.com/demosdemon/git-remote-codecommit.git' +$ git-remote-codecommit --help +A Git remote helper for AWS CodeCommit. + +This is normally invoked by git any time it needs to interact with a remote with the `codecommit://` scheme. + +https://git-scm.com/docs/gitremote-helpers + +Git invokes the helper with one or two arguments; however, this helper requires both arguments to be present. See the url above for more details; but briefly: + +- The first argument is the name of the remote. In most cases, this is the name of the remote configured in the git repo. However, this can also be the URL to the remote if URL was encountered on the +command line. + +- The second argument is the url of the remote. Git will not provide this if the remote is configured in the config as `remote..vcs = codecommit` and `remote..url` is not set. This is not +supported. + +## URL format + +This helper accepts the following URLs: + +- `codecommit://[@]`: Use the default AWS region. Use the specified profile otherwise use the default. + +- `codecommit::://[@]`: Override the AWS region. + +- Note: Git strips the `codecommit::` prefix when invoking the helper and the remote uses the region form. + +Usage: git-remote-codecommit [OPTIONS] + +Arguments: + + The first argument to the git-remote helper + + + The second argument to the git-remote helper + +Options: + --code-commit-endpoint + Override the default AWS endpoint for CodeCommit. + + If not provided, the default is `git-codecommit.${region}.${aws-partition}`. + + Where `${region}` is taken from the environment or profile and `${aws-partition}` is `amazonaws.com` for AWS regions and `amazonaws.cn` for AWS China regions. + + [env: CODE_COMMIT_ENDPOINT=] + + -h, --help + Print help (see a summary with '-h') + + -V, --version + Print version +``` diff --git a/crates/git-remote-codecommit/Cargo.toml b/crates/git-remote-codecommit/Cargo.toml new file mode 100644 index 0000000..aba4b20 --- /dev/null +++ b/crates/git-remote-codecommit/Cargo.toml @@ -0,0 +1,27 @@ +[package] +name = "git-remote-codecommit" +version.workspace = true +authors.workspace = true +repository.workspace = true +homepage.workspace = true +edition.workspace = true +license.workspace = true +publish.workspace = true + +[dependencies] +anyhow = "1.0.86" +aws-config = "1.5.3" +aws-credential-types = "1.2.0" +aws-sigv4 = { version = "1.2.2", default-features = false } +chrono = { version = "0.4.38", default-features = false, features = ["std"] } +clap = { version = "4.5.8", features = ["deprecated", "derive", "cargo", "env", "wrap_help"] } +exec = "0.3.1" +hmac = "0.12.1" +sha2 = "0.10.8" +tokio = { version = "1.38.0", features = ["mio", "rt"] } +tracing = "0.1.40" +tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } +uriparse = "0.6.4" + +[lints] +workspace = true diff --git a/crates/git-remote-codecommit/LICENSE-APACHE b/crates/git-remote-codecommit/LICENSE-APACHE new file mode 120000 index 0000000..1cd601d --- /dev/null +++ b/crates/git-remote-codecommit/LICENSE-APACHE @@ -0,0 +1 @@ +../../LICENSE-APACHE \ No newline at end of file diff --git a/crates/git-remote-codecommit/LICENSE-MIT b/crates/git-remote-codecommit/LICENSE-MIT new file mode 120000 index 0000000..b2cfbdc --- /dev/null +++ b/crates/git-remote-codecommit/LICENSE-MIT @@ -0,0 +1 @@ +../../LICENSE-MIT \ No newline at end of file diff --git a/crates/git-remote-codecommit/src/canonical_request.rs b/crates/git-remote-codecommit/src/canonical_request.rs new file mode 100644 index 0000000..55fac60 --- /dev/null +++ b/crates/git-remote-codecommit/src/canonical_request.rs @@ -0,0 +1,31 @@ +use std::io::Write; + +use hmac::digest::FixedOutput; +use sha2::Digest; + +use crate::HexDisplayExt; +use crate::URL_PATH_PREFIX; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct CanonicalRequest<'a> { + pub repo: &'a str, + pub hostname: &'a str, +} + +impl CanonicalRequest<'_> { + pub fn sha256(&self) -> impl core::fmt::Display { + let mut hasher = sha2::Sha256::new(); + write!(hasher, "{self}").expect("writing to hasher cannot fail"); + hasher.finalize_fixed().hex_display() + } +} + +impl core::fmt::Display for CanonicalRequest<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let Self { repo, hostname } = self; + write!( + f, + "GIT\n/{URL_PATH_PREFIX}/{repo}\n\nhost:{hostname}\n\nhost\n" + ) + } +} diff --git a/crates/git-remote-codecommit/src/credential_scope.rs b/crates/git-remote-codecommit/src/credential_scope.rs new file mode 100644 index 0000000..6a98bc9 --- /dev/null +++ b/crates/git-remote-codecommit/src/credential_scope.rs @@ -0,0 +1,18 @@ +use std::time::SystemTime; + +use crate::TimestampExt; +use crate::SERVICE; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct CredentialScope<'a> { + pub timestamp: SystemTime, + pub region: &'a str, +} + +impl core::fmt::Display for CredentialScope<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let Self { timestamp, region } = self; + let date = timestamp.sigv4_date(); + write!(f, "{date}/{region}/{SERVICE}/aws4_request") + } +} diff --git a/crates/git-remote-codecommit/src/datetime.rs b/crates/git-remote-codecommit/src/datetime.rs new file mode 100644 index 0000000..8648da8 --- /dev/null +++ b/crates/git-remote-codecommit/src/datetime.rs @@ -0,0 +1,40 @@ +use std::time::SystemTime; + +const SIGV4_DATE: &str = "%Y%m%d"; +const SIGV4_TIMESTAMP: &str = "%Y%m%dT%H%M%S"; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct TimeWithFormat<'a> { + time: SystemTime, + format: &'a str, +} + +impl core::fmt::Display for TimeWithFormat<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + chrono::DateTime::::from(self.time) + .format(self.format) + .fmt(f) + } +} + +pub trait TimestampExt { + fn sigv4_date(self) -> TimeWithFormat<'static>; + + fn sigv4_timestamp(self) -> TimeWithFormat<'static>; +} + +impl TimestampExt for SystemTime { + fn sigv4_date(self) -> TimeWithFormat<'static> { + TimeWithFormat { + time: self, + format: SIGV4_DATE, + } + } + + fn sigv4_timestamp(self) -> TimeWithFormat<'static> { + TimeWithFormat { + time: self, + format: SIGV4_TIMESTAMP, + } + } +} diff --git a/crates/git-remote-codecommit/src/hex.rs b/crates/git-remote-codecommit/src/hex.rs new file mode 100644 index 0000000..bbb3b2b --- /dev/null +++ b/crates/git-remote-codecommit/src/hex.rs @@ -0,0 +1,21 @@ +pub struct HexDisplay(T); + +impl> core::fmt::Display for HexDisplay { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + for b in self.0.as_ref() { + write!(f, "{b:02x}")?; + } + Ok(()) + } +} + +pub trait HexDisplayExt: AsRef<[u8]> { + fn hex_display(self) -> HexDisplay + where + Self: Sized, + { + HexDisplay(self) + } +} + +impl> HexDisplayExt for T {} diff --git a/crates/git-remote-codecommit/src/hostname.rs b/crates/git-remote-codecommit/src/hostname.rs new file mode 100644 index 0000000..e7d1c76 --- /dev/null +++ b/crates/git-remote-codecommit/src/hostname.rs @@ -0,0 +1,21 @@ +pub struct InferredHostname<'a> { + region: &'a str, +} + +impl<'a> InferredHostname<'a> { + pub fn new(region: &'a str) -> Self { + Self { region } + } +} + +impl core::fmt::Display for InferredHostname<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let Self { region } = self; + let partition = if region.starts_with("cn-") { + "amazonaws.com.cn" + } else { + "amazonaws.com" + }; + write!(f, "git-codecommit.{region}.{partition}") + } +} diff --git a/crates/git-remote-codecommit/src/logging.rs b/crates/git-remote-codecommit/src/logging.rs new file mode 100644 index 0000000..cbfef52 --- /dev/null +++ b/crates/git-remote-codecommit/src/logging.rs @@ -0,0 +1,23 @@ +use std::io::IsTerminal; + +use tracing::Level; +use tracing_subscriber::EnvFilter; + +pub fn init_logging() { + let filter = EnvFilter::builder() + .with_default_directive(Level::ERROR.into()) + .from_env_lossy(); + tracing_subscriber::fmt() + .with_ansi(term_color()) + .with_writer(std::io::stderr) + .with_env_filter(filter) + .init(); +} + +fn term_color() -> bool { + match std::env::var_os("CARGO_TERM_COLOR") { + Some(val) if val == "always" => true, + Some(val) if val == "never" => false, + _ => std::io::stderr().is_terminal(), + } +} diff --git a/crates/git-remote-codecommit/src/main.rs b/crates/git-remote-codecommit/src/main.rs new file mode 100644 index 0000000..5b87c2d --- /dev/null +++ b/crates/git-remote-codecommit/src/main.rs @@ -0,0 +1,179 @@ +mod canonical_request; +mod credential_scope; +mod datetime; +mod hex; +mod hostname; +mod logging; +mod sdk_context; +mod string_to_sign; +mod uri; +mod urlsafe; +mod username; + +use std::time::SystemTime; + +use anyhow::Context; +use clap::Parser; +use hmac::digest::FixedOutput; +use hmac::Mac; +use tracing::debug; +use tracing::trace; + +use self::canonical_request::CanonicalRequest; +use self::credential_scope::CredentialScope; +use self::datetime::TimestampExt; +use self::hex::HexDisplayExt; +use self::hostname::InferredHostname; +use self::sdk_context::SdkContext; +use self::string_to_sign::StringToSign; +use self::uri::ParsedUri; +use self::urlsafe::UrlSafeQuote; +use self::username::Username; + +const SERVICE: &str = "codecommit"; + +const URL_PATH_PREFIX: &str = "v1/repos"; + +#[derive(Debug, Clone, Parser)] +#[command(name = "git-remote-codecommit", version, about)] +/// A Git remote helper for AWS CodeCommit. +/// +/// This is normally invoked by git any time it needs to interact with a remote +/// with the `codecommit://` scheme. +/// +/// https://git-scm.com/docs/gitremote-helpers +/// +/// Git invokes the helper with one or two arguments; however, this helper +/// requires both arguments to be present. See the url above for more details; +/// but briefly: +/// +/// - The first argument is the name of the remote. In most cases, this is the +/// name of the remote configured in the git repo. However, this can also be +/// the URL to the remote if URL was encountered on the command line. +/// +/// - The second argument is the url of the remote. Git will not provide this if +/// the remote is configured in the config as `remote..vcs = codecommit` +/// and `remote..url` is not set. This is not supported. +/// +/// ## URL format +/// +/// This helper accepts the following URLs: +/// +/// - `codecommit://[@]`: Use the default AWS region. Use +/// the specified profile otherwise use the default. +/// +/// - `codecommit::://[@]`: Override the AWS +/// region. +/// +/// - Note: Git strips the `codecommit::` prefix when invoking the helper and +/// the remote uses the region form. +struct Cli { + /// Override the default AWS endpoint for CodeCommit. + /// + /// If not provided, the default is + /// `git-codecommit.${region}.${aws-partition}`. + /// + /// Where `${region}` is taken from the environment or profile and + /// `${aws-partition}` is `amazonaws.com` for AWS regions and + /// `amazonaws.cn` for AWS China regions. + #[arg(long, env, value_name = "URL")] + code_commit_endpoint: Option, + + /// The first argument to the git-remote helper. + remote_name: String, + + /// The second argument to the git-remote helper. + remote_uri: String, +} + +fn main() -> anyhow::Result<()> { + crate::logging::init_logging(); + trace!("initialized logging"); + + let Cli { + code_commit_endpoint, + remote_name, + remote_uri, + } = Cli::parse(); + debug!( + ?code_commit_endpoint, + ?remote_name, + ?remote_uri, + "parsed cli arguments" + ); + + let parsed_uri = ParsedUri::try_from(&remote_uri).context("failed to parse uri")?; + debug!(?parsed_uri, "parsed uri"); + + let sdk_context = SdkContext::load_context_sync(parsed_uri.region(), parsed_uri.profile())?; + debug!(?sdk_context, "loaded sdk context"); + + let url = generate_url(parsed_uri, code_commit_endpoint, sdk_context); + debug!(?url, "generated url"); + + let err = exec::execvp("git", ["git", "remote-https", &remote_name, &url]); + anyhow::bail!("failed to execute git: {err}") +} + +fn generate_url( + parsed_uri: ParsedUri<'_>, + override_endpoint: Option, + sdk_context: SdkContext, +) -> String { + let hostname = override_endpoint + .unwrap_or_else(|| InferredHostname::new(sdk_context.region().as_ref()).to_string()); + debug!(?hostname, "using hostname for codecommit endpoint"); + + let username = Username { + access_key_id: sdk_context.credentials().access_key_id(), + session_token: sdk_context.credentials().session_token(), + } + .to_string(); + debug!(?username, "generated username"); + + let signature = generate_signature(&hostname, parsed_uri.repository(), &sdk_context); + debug!(?signature, "generated signature"); + + format!( + "https://{username}:{signature}@{hostname}/{URL_PATH_PREFIX}/{repo}", + username = UrlSafeQuote(&username), + repo = parsed_uri.repository(), + ) +} + +fn generate_signature(hostname: &str, repo: &str, context: &SdkContext) -> String { + let region = context.region().as_ref(); + let timestamp = SystemTime::now(); + + let string_to_sign = StringToSign { + timestamp, + credential_scope: CredentialScope { timestamp, region }, + canonical_request: CanonicalRequest { repo, hostname }, + }; + + if tracing::enabled!(tracing::Level::DEBUG) { + let canonical_request = string_to_sign.canonical_request.to_string(); + debug!(?canonical_request, "canonical request for signature"); + } + + let string_to_sign = string_to_sign.to_string(); + debug!(?string_to_sign, "string to sign"); + + let signing_key = aws_sigv4::sign::v4::generate_signing_key( + context.credentials().secret_access_key(), + timestamp, + region, + SERVICE, + ); + + let signature = hmac::Hmac::::new_from_slice(signing_key.as_ref()) + .expect("HMAC can take key of any size") + .chain_update(string_to_sign.as_bytes()) + .finalize_fixed(); + + format!( + "{}Z{}", + timestamp.sigv4_timestamp(), + signature.hex_display() + ) +} diff --git a/crates/git-remote-codecommit/src/sdk_context.rs b/crates/git-remote-codecommit/src/sdk_context.rs new file mode 100644 index 0000000..96aaa6f --- /dev/null +++ b/crates/git-remote-codecommit/src/sdk_context.rs @@ -0,0 +1,90 @@ +use anyhow::Context; +use aws_config::meta::region::ProvideRegion; +use aws_config::meta::region::RegionProviderChain; +use aws_config::AppName; +use aws_config::BehaviorVersion; +use aws_config::Region; +use aws_credential_types::provider::ProvideCredentials; +use aws_credential_types::Credentials; + +const APP_NAME: &str = "git-remote-codecommit"; + +#[derive(Debug)] +pub struct SdkContext { + region: Region, + credentials: Credentials, +} + +impl SdkContext { + pub fn load_context_sync( + override_region: Option<&str>, + override_profile: Option<&str>, + ) -> anyhow::Result { + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build() + .context("failed to build tokio runtime")? + .block_on(Self::load_context(override_region, override_profile)) + } + + pub async fn load_context( + override_region: Option<&str>, + override_profile: Option<&str>, + ) -> anyhow::Result { + let mut config_loader = aws_config::ConfigLoader::default() + .behavior_version(BehaviorVersion::v2024_03_28()) + .region(region_provider(override_region)) + .app_name(app_name()); + + if let Some(profile) = override_profile { + config_loader = config_loader.profile_name(profile); + } + + let sdk_config = config_loader.load().await; + + let credentials = sdk_config + .credentials_provider() + .context("credentials not set")? + .provide_credentials() + .await + .context("failed to resolve credentials")?; + + let region = sdk_config.region().context("region not set")?.clone(); + + Ok(Self { + region, + credentials, + }) + } + + pub fn region(&self) -> &Region { + &self.region + } + + pub fn credentials(&self) -> &Credentials { + &self.credentials + } +} + +fn app_name() -> AppName { + AppName::new(APP_NAME).expect("constant app name to be valid") +} + +fn region_provider(maybe_region: Option<&str>) -> RegionProviderChain { + RegionProviderChain::first_try(MaybeRegion::from(maybe_region)).or_default_provider() +} + +#[derive(Debug)] +struct MaybeRegion(Option); + +impl ProvideRegion for MaybeRegion { + fn region(&self) -> aws_config::meta::region::future::ProvideRegion<'_> { + aws_config::meta::region::future::ProvideRegion::ready(self.0.clone()) + } +} + +impl From> for MaybeRegion { + fn from(value: Option<&str>) -> Self { + Self(value.map(str::to_owned).map(Region::new)) + } +} diff --git a/crates/git-remote-codecommit/src/string_to_sign.rs b/crates/git-remote-codecommit/src/string_to_sign.rs new file mode 100644 index 0000000..6d0450a --- /dev/null +++ b/crates/git-remote-codecommit/src/string_to_sign.rs @@ -0,0 +1,28 @@ +use std::time::SystemTime; + +use crate::CanonicalRequest; +use crate::CredentialScope; +use crate::TimestampExt; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub struct StringToSign<'a> { + pub timestamp: SystemTime, + pub credential_scope: CredentialScope<'a>, + pub canonical_request: CanonicalRequest<'a>, +} + +impl core::fmt::Display for StringToSign<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let Self { + timestamp, + credential_scope, + canonical_request, + } = self; + let timestamp = timestamp.sigv4_timestamp(); + let canonical_request = canonical_request.sha256(); + write!( + f, + "AWS4-HMAC-SHA256\n{timestamp}\n{credential_scope}\n{canonical_request}" + ) + } +} diff --git a/crates/git-remote-codecommit/src/uri/error.rs b/crates/git-remote-codecommit/src/uri/error.rs new file mode 100644 index 0000000..28603f8 --- /dev/null +++ b/crates/git-remote-codecommit/src/uri/error.rs @@ -0,0 +1,36 @@ +use uriparse::URIError; + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +pub enum ParseUriError { + InvalidUri(URIError), + MissingAuthority, + UnexpectedPath, + UnexpectedQuery, + UnexpectedFragment, + UnexpectedPassword, + UnexpectedPort, + UnexpectedIpForRepositoryName, +} + +impl From for ParseUriError { + fn from(value: URIError) -> Self { + Self::InvalidUri(value) + } +} + +impl core::fmt::Display for ParseUriError { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + match self { + Self::InvalidUri(err) => write!(f, "invalid URI: {err}"), + Self::MissingAuthority => f.write_str("missing authority"), + Self::UnexpectedPath => f.write_str("unexpected path"), + Self::UnexpectedQuery => f.write_str("unexpected query"), + Self::UnexpectedFragment => f.write_str("unexpected fragment"), + Self::UnexpectedPassword => f.write_str("unexpected password"), + Self::UnexpectedPort => f.write_str("unexpected port"), + Self::UnexpectedIpForRepositoryName => f.write_str("unexpected IP for repository name"), + } + } +} + +impl std::error::Error for ParseUriError {} diff --git a/crates/git-remote-codecommit/src/uri/mod.rs b/crates/git-remote-codecommit/src/uri/mod.rs new file mode 100644 index 0000000..ef9042f --- /dev/null +++ b/crates/git-remote-codecommit/src/uri/mod.rs @@ -0,0 +1,150 @@ +mod error; + +use uriparse::Host; +use uriparse::RegisteredName; +use uriparse::Scheme; +use uriparse::Username; +use uriparse::URI; + +pub use self::error::ParseUriError; + +const SCHEME: &str = "codecommit"; + +// Note the double colon. It is not a typo. +const PREFIX_WITH_REGION: &str = "codecommit::"; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub struct ParsedUri<'a> { + region: Option>, + profile: Option>, + repository: RegisteredName<'a>, +} + +impl ParsedUri<'_> { + pub fn region(&self) -> Option<&str> { + self.region.as_ref().map(Scheme::as_str) + } + + pub fn profile(&self) -> Option<&str> { + self.profile.as_deref() + } + + pub fn repository(&self) -> &str { + self.repository.as_str() + } + + pub fn into_owned(self) -> ParsedUri<'static> { + ParsedUri { + region: self.region.map(Scheme::into_owned), + profile: self.profile.map(Username::into_owned), + repository: self.repository.into_owned(), + } + } +} + +impl<'a> TryFrom<&'a String> for ParsedUri<'a> { + type Error = ParseUriError; + + fn try_from(value: &'a String) -> Result { + Self::try_from(value.as_str()) + } +} + +impl<'a> TryFrom<&'a str> for ParsedUri<'a> { + type Error = ParseUriError; + + fn try_from(input: &'a str) -> Result { + // Git removes this prefix before invoking the helper; but, we're checking for + // it anyways to be safe as otherwise it would be an invalid URI. + let value = input.strip_prefix(PREFIX_WITH_REGION).unwrap_or(input); + + let (scheme, authority, path, query, fragment) = URI::try_from(value)?.into_parts(); + + let (profile, password, host, port) = authority + .ok_or(ParseUriError::MissingAuthority)? + .into_parts(); + + path.segments() + .single() + .map_or(false, |only| only.is_empty() || only == "/") + .ok_or(ParseUriError::UnexpectedPath)?; + + query.is_none().ok_or(ParseUriError::UnexpectedQuery)?; + + fragment + .is_none() + .ok_or(ParseUriError::UnexpectedFragment)?; + + password + .is_none() + .ok_or(ParseUriError::UnexpectedPassword)?; + + port.is_none().ok_or(ParseUriError::UnexpectedPort)?; + + let repository = match host { + Host::RegisteredName(rn) => rn, + _ => return Err(ParseUriError::UnexpectedIpForRepositoryName), + }; + + // TODO: should this be validated? The original code validates it to + // `\w{2}-\w*.*-\d` which is a bit too strict. + let region = if scheme == SCHEME { None } else { Some(scheme) }; + + Ok(Self { + region, + profile, + repository, + }) + } +} + +impl core::fmt::Display for ParsedUri<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + if let Some(region) = self.region() { + f.write_str(PREFIX_WITH_REGION)?; + f.write_str(region)?; + } else { + f.write_str(SCHEME)?; + } + + f.write_str("://")?; + + if let Some(profile) = self.profile() { + f.write_str(profile)?; + f.write_str("@")?; + } + + f.write_str(self.repository()) + } +} + +trait SingleExt: IntoIterator { + fn single(self) -> Option + where + Self: Sized, + { + let mut iter = self.into_iter(); + let first = iter.next()?; + if iter.next().is_some() { + None + } else { + Some(first) + } + } +} + +impl SingleExt for T {} + +trait BoolExt { + fn ok_or(self, or: E) -> Result<(), E>; +} + +impl BoolExt for bool { + fn ok_or(self, or: E) -> Result<(), E> { + if self { + Ok(()) + } else { + Err(or) + } + } +} diff --git a/crates/git-remote-codecommit/src/urlsafe.rs b/crates/git-remote-codecommit/src/urlsafe.rs new file mode 100644 index 0000000..261482b --- /dev/null +++ b/crates/git-remote-codecommit/src/urlsafe.rs @@ -0,0 +1,28 @@ +pub struct UrlSafeQuote<'a>(pub &'a str); + +impl core::fmt::Display for UrlSafeQuote<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + let mut cur = 0; + + for (idx, c) in self.0.char_indices() { + if is_urlsafe(c) { + continue; + } + + let slice = &self.0[cur..idx]; + f.write_str(slice)?; + + for b in c.encode_utf8(&mut [0; 4]).as_bytes() { + write!(f, "%{b:02X}")?; + } + + cur = idx + c.len_utf8(); + } + Ok(()) + } +} + +const fn is_urlsafe(c: char) -> bool { + // "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-~"; + matches!(c, 'A'..='Z' | 'a'..='z' | '0'..='9' | '_' | '.' | '-' | '~') +} diff --git a/crates/git-remote-codecommit/src/username.rs b/crates/git-remote-codecommit/src/username.rs new file mode 100644 index 0000000..a93b6e3 --- /dev/null +++ b/crates/git-remote-codecommit/src/username.rs @@ -0,0 +1,15 @@ +pub struct Username<'a> { + pub access_key_id: &'a str, + pub session_token: Option<&'a str>, +} + +impl core::fmt::Display for Username<'_> { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + f.write_str(self.access_key_id)?; + if let Some(token) = self.session_token { + f.write_str("%")?; + f.write_str(token)?; + } + Ok(()) + } +}