diff --git a/.travis.yml b/.travis.yml index bfdf4e1..50a9a14 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,46 +1,159 @@ -sudo: required +# Based on the "trust" template v0.1.2 +# https://github.com/japaric/trust/tree/v0.1.2 + +dist: trusty language: rust -rust: - - stable - - beta - - nightly +services: docker +sudo: required + +env: + global: + - CRATE_NAME=hermit matrix: allow_failures: - rust: nightly + # TODO These are all the build jobs. Adjust as necessary. Comment out what you + # don't need + include: + # Android + # - env: TARGET=aarch64-linux-android DISABLE_TESTS=1 + # - env: TARGET=arm-linux-androideabi DISABLE_TESTS=1 + # - env: TARGET=armv7-linux-androideabi DISABLE_TESTS=1 + # - env: TARGET=i686-linux-android DISABLE_TESTS=1 + # - env: TARGET=x86_64-linux-android DISABLE_TESTS=1 -cache: cargo + # iOS + # - env: TARGET=aarch64-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=armv7-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=armv7s-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=i386-apple-ios DISABLE_TESTS=1 + # os: osx + # - env: TARGET=x86_64-apple-ios DISABLE_TESTS=1 + # os: osx + + # Linux + - env: TARGET=aarch64-unknown-linux-gnu + if: branch = master + - env: TARGET=arm-unknown-linux-gnueabi + if: branch = master + - env: TARGET=armv7-unknown-linux-gnueabihf + if: branch = master + - env: TARGET=i686-unknown-linux-gnu + if: branch = master + - env: TARGET=i686-unknown-linux-musl + if: branch = master + - env: TARGET=mips-unknown-linux-gnu + if: branch = master + - env: TARGET=mips64-unknown-linux-gnuabi64 + if: branch = master + - env: TARGET=mips64el-unknown-linux-gnuabi64 + if: branch = master + - env: TARGET=mipsel-unknown-linux-gnu + if: branch = master + - env: TARGET=powerpc-unknown-linux-gnu + if: branch = master + - env: TARGET=powerpc64-unknown-linux-gnu + if: branch = master + - env: TARGET=powerpc64le-unknown-linux-gnu + if: branch = master + - env: TARGET=s390x-unknown-linux-gnu + if: branch = master + + - env: TARGET=x86_64-unknown-linux-gnu + - env: TARGET=x86_64-unknown-linux-musl + + # OSX + - env: TARGET=x86_64-apple-darwin + os: osx + + # *BSD + - env: TARGET=i686-unknown-freebsd DISABLE_TESTS=1 + if: branch = master + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + if: branch = master + - env: TARGET=x86_64-unknown-netbsd DISABLE_TESTS=1 + if: branch = master + + # Windows + - env: TARGET=x86_64-pc-windows-gnu + if: branch = master + + # Bare metal + # These targets don't support std and as such are likely not suitable for + # most crates. + # - env: TARGET=thumbv6m-none-eabi + # - env: TARGET=thumbv7em-none-eabi + # - env: TARGET=thumbv7em-none-eabihf + # - env: TARGET=thumbv7m-none-eabi + + # Testing other channels + - env: TARGET=x86_64-unknown-linux-gnu + rust: beta + - env: TARGET=x86_64-apple-darwin + os: osx + rust: beta + - env: TARGET=x86_64-unknown-linux-gnu + rust: nightly + - env: TARGET=x86_64-apple-darwin + os: osx + rust: nightly + +before_install: + - set -e + - rustup self update + +install: + - sh ci/install.sh + - source ~/.cargo/env || true -before_script: - - cargo +nightly clippy --version || ( rustup install nightly && rustup component add clippy-preview --toolchain=nightly ) - - cargo +nightly tarpaulin --version || RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo +nightly install cargo-tarpaulin - - curl -o /tmp/urchin https://raw.githubusercontent.com/tlevine/urchin/v0.0.6/urchin && chmod +x /tmp/urchin - - git fetch --unshallow - - git config remote.$(git remote | head -n1).fetch "+refs/heads/*:refs/remotes/$(git remote | head -n1)/*" - - git fetch $(git remote | head -n1) master - - git checkout master - - git checkout - script: - - cargo +nightly clippy - - ./runtests.sh + - bash ci/script.sh + +after_script: set +e + +before_deploy: + - sh ci/before_deploy.sh after_success: | if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then + rustup install nightly cargo +nightly tarpaulin --ciserver travis-ci --coveralls $TRAVIS_JOB_ID fi +deploy: + api_key: + secure: "Sz3ZolD+gLnRA/MGIW7C1jnKWbdVuaGqxNWNVS9mlLdZAydnrl+gBBMLhc2I20Kl44fEpOXVfC0HlmGN7M2sYeI7Q7jufuQSQzNFbgeb4VXoFvGNvO+dz1XyoUFi/CXFGS4kcafbA7CjFtLXEgdd0Z9rQP/dLB3y6gZZXBMAXy8=" + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + on: + condition: $TRAVIS_RUST_VERSION = stable + tags: true + provider: releases + skip_cleanup: true + addons: - apt: - sources: - - kalakris-cmake + homebrew: packages: - - cmake - - libcurl4-openssl-dev - - libelf-dev - - libdw-dev - - libssl-dev + - openssl@1.1 + +cache: cargo +before_cache: + # Travis can't cache files that are not readable by "others" + - chmod -R a+r $HOME/.cargo + +branches: + only: + # release tags + - /^v\d+\.\d+\.\d+.*$/ + - master notifications: + email: + on_success: never slack: on_success: always on_failure: always diff --git a/Cargo.lock b/Cargo.lock index 8ea93f9..5c26ac8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,458 +1,607 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "ansi_term" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] +[[package]] +name = "anyhow" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68803225a7b13e47191bab76f2687382b60d259e8cf37f6e1893658b84bb9479" + +[[package]] +name = "arrayref" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" + +[[package]] +name = "arrayvec" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" + [[package]] name = "atty" -version = "0.2.6" +version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "hermit-abi", + "libc", + "winapi", ] [[package]] -name = "backtrace" -version = "0.3.9" +name = "autocfg" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] -name = "backtrace-sys" -version = "0.1.23" +name = "base64" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "bitflags" -version = "1.0.1" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "blake2b_simd" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" +dependencies = [ + "arrayref", + "arrayvec", + "constant_time_eq", +] [[package]] name = "cc" -version = "1.0.30" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" -version = "0.1.4" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "clap" -version = "2.32.0" +version = "2.33.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" dependencies = [ - "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", ] [[package]] -name = "curl-sys" -version = "0.4.16" +name = "constant_time_eq" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cfg-if", + "lazy_static", ] [[package]] -name = "failure" -version = "0.1.1" +name = "dirs" +version = "3.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "142995ed02755914747cc6ca76fc7e4583cd18578746716d0508ea6ed558b9ff" dependencies = [ - "backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs-sys", ] [[package]] -name = "failure_derive" -version = "0.1.1" +name = "dirs-sys" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e93d7f5705de3e49895a2b5e0b8855a1c27f080192ae9c32a6432d50741a57a" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", - "synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "form_urlencoded" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ece68d15c92e84fa4f19d3780f1294e5ca82a78a6d515f1efaabcc144688be00" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "getrandom" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" +dependencies = [ + "cfg-if", + "libc", + "wasi", ] [[package]] name = "git2" -version = "0.8.0" +version = "0.13.13" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "802b535f89475f22bb2b3d589de07861417e67b1a358c7ec8e5005bf4f209133" dependencies = [ - "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", ] [[package]] name = "hermit" version = "0.0.1" dependencies = [ - "clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)", - "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", - "git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)", + "anyhow", + "clap", + "dirs", + "git2", + "once_cell", + "tempfile", + "thiserror", + "walkdir", +] + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", ] [[package]] name = "idna" -version = "0.1.4" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" dependencies = [ - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "jobserver" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c71313ebb9439f74b00d9d2dcec36440beaf57a6aa0623068441dd7cd81a7f2" +dependencies = [ + "libc", ] [[package]] name = "lazy_static" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.50" +version = "0.2.81" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" [[package]] name = "libgit2-sys" -version = "0.7.11" +version = "0.12.15+1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48c39622f3887bc7fb2fff6d06293f64b02c1dfa281212566ac155171d13b0eb" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", ] [[package]] name = "libssh2-sys" -version = "0.2.11" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df40b13fe7ea1be9b9dffa365a51273816c345fc1811478b57ed7d964fbfc4ce" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", ] [[package]] name = "libz-sys" -version = "1.0.25" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] name = "log" -version = "0.4.3" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" dependencies = [ - "cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", ] [[package]] name = "matches" -version = "0.1.2" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "once_cell" +version = "1.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13bd41f508810a131401606d54ac32a467c97172d74ba7662562ebba5ad07fa0" [[package]] name = "openssl-probe" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" [[package]] name = "openssl-sys" -version = "0.9.42" +version = "0.9.59" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe" dependencies = [ - "cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", ] [[package]] name = "percent-encoding" -version = "1.0.1" +version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pkg-config" -version = "0.3.14" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "ppv-lite86" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" + +[[package]] +name = "proc-macro2" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] [[package]] name = "quote" -version = "0.3.15" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df" +dependencies = [ + "proc-macro2", +] [[package]] -name = "redox_syscall" -version = "0.1.37" +name = "rand" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] [[package]] -name = "redox_termios" -version = "0.1.1" +name = "rand_chacha" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ - "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "ppv-lite86", + "rand_core", ] [[package]] -name = "rustc-demangle" -version = "0.1.8" +name = "rand_core" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom", +] [[package]] -name = "rustc_version" -version = "0.2.3" +name = "rand_hc" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rand_core", ] [[package]] -name = "same-file" -version = "1.0.2" +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "redox_users" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "getrandom", + "redox_syscall", + "rust-argon2", ] [[package]] -name = "semver" -version = "0.9.0" +name = "remove_dir_all" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] -name = "semver-parser" -version = "0.7.0" +name = "rust-argon2" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dab61250775933275e84053ac235621dfb739556d5c54a2f2e9313b7cf43a19" +dependencies = [ + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] [[package]] name = "strsim" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "syn" -version = "0.11.11" +version = "1.0.55" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a571a711dddd09019ccc628e1b17fe87c59b09d513c06c026877aa708334f37a" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2", + "quote", + "unicode-xid", ] [[package]] -name = "synom" -version = "0.11.3" +name = "tempfile" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" dependencies = [ - "unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if", + "libc", + "rand", + "redox_syscall", + "remove_dir_all", + "winapi", ] [[package]] -name = "synstructure" -version = "0.6.1" +name = "textwrap" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" dependencies = [ - "quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", - "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width", ] [[package]] -name = "termion" -version = "1.5.1" +name = "thiserror" +version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" dependencies = [ - "libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror-impl", ] [[package]] -name = "textwrap" -version = "0.10.0" +name = "thiserror-impl" +version = "1.0.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinyvec" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f" dependencies = [ - "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tinyvec_macros", ] +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + [[package]] name = "unicode-bidi" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" dependencies = [ - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "matches", ] [[package]] name = "unicode-normalization" -version = "0.1.5" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a13e63ab62dbe32aeee58d1c5408d35c36c392bba5d9d3142287219721afe606" +dependencies = [ + "tinyvec", +] [[package]] name = "unicode-width" -version = "0.1.4" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" [[package]] name = "unicode-xid" -version = "0.0.4" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "url" -version = "1.6.0" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5909f2b0817350449ed73e8bcd81c8c3c8d9a7a5d8acba4b27db277f1868976e" dependencies = [ - "idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "form_urlencoded", + "idna", + "matches", + "percent-encoding", ] [[package]] name = "vcpkg" -version = "0.2.2" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" [[package]] name = "vec_map" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "walkdir" -version = "2.2.7" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" dependencies = [ - "same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "same-file", + "winapi", + "winapi-util", ] +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + [[package]] name = "winapi" -version = "0.3.5" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "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-util" -version = "0.1.2" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[metadata] -"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" -"checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" -"checksum backtrace 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "89a47830402e9981c5c41223151efcced65a0510c13097c769cede7efb34782a" -"checksum backtrace-sys 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)" = "bff67d0c06556c0b8e6b5f090f0eac52d950d9dfd1d35ba04e4ca3543eaf6a7e" -"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" -"checksum cc 1.0.30 (registry+https://github.com/rust-lang/crates.io-index)" = "d01c69d08ff207f231f07196e30f84c70f1c815b04f980f8b7b01ff01f05eb92" -"checksum cfg-if 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "efe5c877e17a9c717a0bf3613b2709f723202c4e4675cc8f12926ded29bcb17e" -"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" -"checksum curl-sys 0.4.16 (registry+https://github.com/rust-lang/crates.io-index)" = "ca79238a79fb294be6173b4057c95b22a718c94c4e38475d5faa82b8383f3502" -"checksum failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "934799b6c1de475a012a02dab0ace1ace43789ee4b99bcfbf1a2e3e8ced5de82" -"checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" -"checksum git2 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7339329bfa14a00223244311560d11f8f489b453fb90092af97f267a6090ab0" -"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" -"checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" -"checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" -"checksum libgit2-sys 0.7.11 (registry+https://github.com/rust-lang/crates.io-index)" = "48441cb35dc255da8ae72825689a95368bf510659ae1ad55dc4aa88cb1789bf1" -"checksum libssh2-sys 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "126a1f4078368b163bfdee65fbab072af08a1b374a5551b21e87ade27b1fbf9d" -"checksum libz-sys 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "2eb5e43362e38e2bca2fd5f5134c4d4564a23a5c28e9b95411652021a8675ebe" -"checksum log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "61bd98ae7f7b754bc53dca7d44b604f733c6bba044ea6f41bc8d89272d8161d2" -"checksum matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "15305656809ce5a4805b1ff2946892810992197ce1270ff79baded852187942e" -"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" -"checksum openssl-sys 0.9.42 (registry+https://github.com/rust-lang/crates.io-index)" = "cb534d752bf98cf363b473950659ac2546517f9c6be9723771614ab3f03bbc9e" -"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" -"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" -"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" -"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" -"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum rustc-demangle 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "76d7ba1feafada44f2d38eed812bd2489a03c0f5abb975799251518b68848649" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum same-file 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "cfb6eded0b06a0b512c8ddbcf04089138c9b4362c2f696f3c3d76039d68f3637" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" -"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" -"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" -"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd" -"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "307686869c93e71f94da64286f9a9524c0f308a9e1c87a583de8e9c9039ad3f6" -"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" -"checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" -"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" -"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" -"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2" -"checksum vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9e0a7d8bed3178a8fb112199d466eeca9ed09a14ba8ad67718179b4fd5487d0b" -"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" -"checksum walkdir 2.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "9d9d7ed3431229a144296213105a390676cc49c9b6a72bd19f3176c98e129fa1" -"checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" -"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" -"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9" -"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 2540cbf..6adc10b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hermit" version = "0.0.1" -authors = ["Geoff Shannon ", +authors = ["Zephyr Shannon ", "Reilly Tucker Siemens ", "Joe Houng ", "Aaron Griffin "] @@ -11,14 +11,16 @@ repository = "https://github.com/bike-barn/hermit" readme = "README.md" keywords = ["home", "directory", "configuration", "management", "dotfiles"] license = "GPL-3.0" +edition = "2018" [dependencies] -clap = "~2.32.0" -failure = "~0.1.1" -failure_derive = "~0.1.1" -git2 = "~0.8.0" -walkdir = "~2.2.7" +anyhow = "1.0.36" +clap = "2.33.3" +dirs = "3.0.1" +git2 = "0.13.13" +thiserror = "1.0.22" +walkdir = "2.3.1" [dev-dependencies] -lazy_static = "~1.3.0" - +once_cell = "1.5.2" +tempfile = "3.1.0" diff --git a/README.md b/README.md index 37a1776..632ce55 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,11 @@ Bring your home with you [![Build Status][badge-build]](https://travis-ci.org/bike-barn/hermit) [![Coverage Status][badge-coverage]](https://coveralls.io/github/bike-barn/hermit) [![License GPL 3][badge-license]](http://www.gnu.org/licenses/gpl-3.0.txt) -[![Stories Ready to Work On][badge-todo]](https://waffle.io/bike-barn/hermit) [![Crabs harmed][badge-crabs]](http://shields.io/) [badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg [badge-build]: https://travis-ci.org/bike-barn/hermit.svg?branch=master [badge-coverage]: https://coveralls.io/repos/github/bike-barn/hermit/badge.svg -[badge-todo]: https://badge.waffle.io/bike-barn/hermit.svg?label=to-do&title=To-Do [badge-crabs]: http://img.shields.io/badge/crabs_harmed-0-blue.svg - + If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw64\bin' + } ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') { + $Env:PATH += ';C:\msys64\mingw32\bin' + } + - vcpkg install curl libgit2 openssl + - curl -sSfL -o rustup-init.exe https://win.rustup.rs/ + - rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION% --no-modify-path + - set PATH=%PATH%;%USERPROFILE%\.cargo\bin + - rustc -Vv + - cargo -Vv + - ps: ci\install.ps1 + +# TODO This is the "test phase", tweak it as you see fit +test_script: + # we don't run the "test phase" when doing deploys + - if [%APPVEYOR_REPO_TAG%]==[false] ( + cargo build --target %TARGET% && + cargo build --target %TARGET% --release && + cargo test --target %TARGET% && + cargo test --target %TARGET% --release + ) + +before_deploy: + - cargo rustc --target %TARGET% --release --bin hermit -- -C lto + - ps: ci\before_deploy.ps1 + +deploy: + artifact: /.*\.zip/ + auth_token: + secure: wt9Felh6IEIknK3lbhtaBhgOI+XvBY4xxTvP4puHklJXpH10BraI/3gB7B33wS5H + description: '' + on: + branch: not-a-real-branch-name + # # TODO Here you can pick which targets will generate binary releases + # # In this example, there are some targets that are tested using the stable + # # and nightly channels. This condition makes sure there is only one release + # # for such targets and that's generated using the stable channel + # RUST_VERSION: stable + # appveyor_repo_tag: true + provider: GitHub + +cache: + - C:\Users\appveyor\.cargo\registry + - target + +branches: + only: + # Release tags + - /^v\d+\.\d+\.\d+.*$/ + - master + +notifications: + - provider: Email + on_build_success: false + +# Building is done in the test phase, so we disable Appveyor's build phase. +build: false diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 new file mode 100644 index 0000000..2159ecb --- /dev/null +++ b/ci/before_deploy.ps1 @@ -0,0 +1,22 @@ +# This script takes care of packaging the build artifacts that will go in the +# release zipfile + +$SRC_DIR = $PWD.Path +$STAGE = [System.Guid]::NewGuid().ToString() + +Set-Location $ENV:Temp +New-Item -Type Directory -Name $STAGE +Set-Location $STAGE + +$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" + +Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\hermit.exe" '.\' + +7z a "$ZIP" * + +Push-AppveyorArtifact "$ZIP" + +Remove-Item *.* -Force +Set-Location .. +Remove-Item $STAGE +Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh new file mode 100644 index 0000000..e17cb70 --- /dev/null +++ b/ci/before_deploy.sh @@ -0,0 +1,31 @@ +# This script takes care of building your crate and packaging it for release + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + cross rustc --bin hermit --target $TARGET --release -- -C lto + + cp target/$TARGET/release/hermit $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/ci/install.ps1 b/ci/install.ps1 new file mode 100644 index 0000000..86fabb0 --- /dev/null +++ b/ci/install.ps1 @@ -0,0 +1,10 @@ +# This script handles fixing Rust builds with mingw + +If ($Env:TARGET -Like '*-gnu') { + $Env:MSYS_BINDIR='C:\msys64\usr\bin' + If ($Env:TARGET -Like 'i686-*') { + $Env:MSYS_BITS='32' + } ElseIf ($Env:TARGET -Like 'x86_64-*') { + $Env:MSYS_BITS='64' + } +} diff --git a/ci/install.sh b/ci/install.sh new file mode 100644 index 0000000..59a9e70 --- /dev/null +++ b/ci/install.sh @@ -0,0 +1,55 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target + + curl -LSfs https://github.com/xd009642/tarpaulin/releases/download/0.7.0/cargo-tarpaulin-0.7.0-travis.tar.gz | tar xz -C ~/.cargo/bin + curl -o /tmp/urchin https://raw.githubusercontent.com/tlevine/urchin/v0.0.6/urchin && chmod +x /tmp/urchin + git fetch --unshallow + git config remote.$(git remote | head -n1).fetch "+refs/heads/*:refs/remotes/$(git remote | head -n1)/*" + git fetch $(git remote | head -n1) master + git checkout master + git checkout - +} + +main diff --git a/ci/script.sh b/ci/script.sh new file mode 100644 index 0000000..2aa73b9 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,28 @@ +# This script takes care of testing your crate + +set -ex + +main() { + # Only run clippy on the basic linux target + if [[ "$TARGET" -eq x86_64-unknown-linux-gnu ]]; then + cargo clippy --version || ( rustup component add clippy ) + cargo clippy + fi + + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + ./runtests.sh + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi diff --git a/src/config.rs b/src/config.rs index 6e387bd..016541a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,8 +1,9 @@ -use std::borrow::Borrow; -use std::fs::File; -use std::io::prelude::*; -use std::path::{Path, PathBuf}; -use std::{fs, io}; +use std::{ + borrow::Borrow, + fs::{self, File}, + io::{self, prelude::*}, + path::{Path, PathBuf}, +}; use walkdir::{self, WalkDir}; @@ -49,16 +50,16 @@ fn config_path(root_path: &PathBuf) -> PathBuf { } impl FsConfig { - pub fn new(root_path: impl AsRef) -> FsConfig { + pub fn new(root_path: impl AsRef) -> anyhow::Result { let root_path = PathBuf::from(root_path.as_ref()); - fs::create_dir_all(&root_path); + fs::create_dir_all(&root_path)?; // TODO: what do I do with this error? let config_path = config_path(&root_path); let current_shell = read_shell_from_path(&config_path).ok(); - FsConfig { + Ok(FsConfig { root_path, current_shell, - } + }) } fn config_path(&self) -> PathBuf { @@ -74,7 +75,7 @@ impl Config for FsConfig { } fn current_shell_name(&self) -> Option<&str> { - self.current_shell.as_ref().map(|s| s.borrow()) + self.current_shell.as_ref().map(Borrow::borrow) } fn set_current_shell_name(&mut self, name: &str) -> io::Result<()> { @@ -249,19 +250,11 @@ mod test { use std::io::prelude::*; use std::path::{Path, PathBuf}; - fn clean_up(test_root: &PathBuf) { - if test_root.exists() { - fs::remove_dir_all(test_root).unwrap(); - } - assert!(!test_root.is_dir()); - } - - fn set_up(suffix: &str, current: &str, shells: Vec<&str>) -> PathBuf { - let test_root = PathBuf::from("./target/fs-config-tests-".to_owned() + suffix); + use tempfile::{tempdir, TempDir}; - clean_up(&test_root); - fs::create_dir(&test_root).unwrap(); - assert!(test_root.is_dir()); + fn set_up(current: &str, shells: Vec<&str>) -> TempDir { + let test_root_dir = tempdir().expect("failed to create tempdir"); + let test_root = test_root_dir.path(); let path = test_root.join("current_shell"); let mut file = File::create(&path).unwrap(); @@ -274,38 +267,41 @@ mod test { fs::create_dir(&new_shell).unwrap(); } - test_root + test_root_dir } #[test] fn has_a_root_path() { - let test_root = set_up("root-path", "default", vec!["default"]); - let config = FsConfig::new(&test_root); + let test_root_dir = set_up("default", vec!["default"]); + let test_root = test_root_dir.path(); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); assert_eq!(config.root_path(), &test_root); } #[test] fn creating_a_config_creates_its_root_dir() { - let test_root = set_up("root-path-create", "default", vec!["default"]); + let test_root_dir = set_up("default", vec!["default"]); + let test_root = test_root_dir.path(); let config_root = test_root.join(".hermit"); assert!(!config_root.exists()); - FsConfig::new(&config_root); + FsConfig::new(&config_root).expect("failed to create FSConfig"); assert!(config_root.exists()); } #[test] fn returns_the_current_shell_name() { - let test_root = set_up("current-shell-name", "current", vec!["current"]); - let config = FsConfig::new(&test_root); + let test_root = set_up("current", vec!["current"]); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); assert_eq!(*config.current_shell_name().unwrap(), "current".to_string()); } #[test] fn can_set_the_current_shell_name() { - let test_root = set_up("set-current-shell-name", "default", vec!["default"]); - let mut config = FsConfig::new(&test_root); + let test_root_dir = set_up("default", vec!["default"]); + let test_root = test_root_dir.path(); + let mut config = FsConfig::new(&test_root).expect("failed to create FSConfig"); config.set_current_shell_name("current").unwrap(); let mut config_file = File::open(&test_root.join("current_shell")).unwrap(); @@ -319,32 +315,24 @@ mod test { #[test] fn can_confirm_a_shell_exists() { - let test_root = set_up( - "confirm-shell-existence", - "default", - vec!["default", "other"], - ); - let config = FsConfig::new(&test_root); + let test_root = set_up("default", vec!["default", "other"]); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); assert!(config.shell_exists("other")); } #[test] fn can_confirm_a_shell_does_not_exist() { - let test_root = set_up( - "confirm-shell-non-existence", - "default", - vec!["default", "other"], - ); - let config = FsConfig::new(&test_root); + let test_root = set_up("default", vec!["default", "other"]); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); assert!(!config.shell_exists("another")); } #[test] fn can_walk_a_directory() { - let test_root = set_up("walk-directory", "default", vec!["default"]); - let config = FsConfig::new(&test_root); + let test_root = set_up("default", vec!["default"]); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); let shell_root = config.shell_root_path().join("default"); File::create(&shell_root.join("file1")).expect("Failed to create test file"); @@ -371,12 +359,8 @@ mod test { #[test] fn can_walk_a_directory_skipping_subdirectory_entries() { - let test_root = set_up( - "walk-directory-skipping-subdirs", - "default", - vec!["default"], - ); - let config = FsConfig::new(&test_root); + let test_root = set_up("default", vec!["default"]); + let config = FsConfig::new(&test_root).expect("failed to create FSConfig"); let shell_root = config.shell_root_path().join("default"); create_paths(shell_root, vec!["file1", "subdir/file2"]); diff --git a/src/env.rs b/src/env.rs index 3521cc4..aaa161c 100644 --- a/src/env.rs +++ b/src/env.rs @@ -1,14 +1,13 @@ -use std::env; -use std::path::PathBuf; +use std::{borrow::ToOwned, env, path::PathBuf}; -pub use std::env::home_dir; +pub use dirs::home_dir; pub fn get_program_name() -> String { env::args() - .nth(0) + .next() .map(PathBuf::from) - .and_then(|path| path.file_name().map(|name| name.to_owned())) - .and_then(|file_name| file_name.to_str().map(|name| name.to_owned())) + .and_then(|path| path.file_name().map(ToOwned::to_owned)) + .and_then(|file_name| file_name.to_str().map(ToOwned::to_owned)) .unwrap_or_else(|| "hermit".to_owned()) } @@ -20,24 +19,22 @@ pub fn get_hermit_dir() -> Option { } pub fn default_hermit_dir() -> Option { - env::home_dir().map(|home| home.join(".config/hermit")) + dirs::config_dir().map(|home| home.join("hermit")) } #[cfg(test)] mod tests { use super::*; - use std::env; - use std::path::PathBuf; - use std::sync::Mutex; + use std::{env, path::PathBuf, sync::Mutex}; - lazy_static! { - // This mutex is solely for preventing these two tests from - // stomping on each other. While it doesn't happen often, it's - // still an issue we want to avoid for CI builds (spurious - // build failures are the worst). - static ref ROOT_ENV_LOCK: Mutex<()> = Mutex::new(()); - } + use once_cell::sync::Lazy; + + // This mutex is solely for preventing these two tests from + // stomping on each other. While it doesn't happen often, it's + // still an issue we want to avoid for CI builds (spurious + // build failures are the worst). + static ROOT_ENV_LOCK: Lazy> = Lazy::new(|| Mutex::new(())); #[test] fn hermit_dir_defaults_to_dot_config() { diff --git a/src/file_operations.rs b/src/file_operations.rs index 80d7780..c63db37 100644 --- a/src/file_operations.rs +++ b/src/file_operations.rs @@ -1,8 +1,9 @@ -use std::os::unix; -use std::path::{Path, PathBuf}; -use std::{fs, io, mem, result}; +use std::{ + mem, + path::{Path, PathBuf}, +}; -use git2; +use crate::fs; #[derive(Debug, PartialEq, Eq)] pub enum Op { @@ -12,28 +13,7 @@ pub enum Op { Remove(PathBuf), } -#[derive(Debug, Fail)] -pub enum Error { - #[fail(display = "IO error: {}", _0)] - IoError(#[cause] io::Error), - - #[fail(display = "Git2 error: {}", _0)] - Git2Error(#[cause] git2::Error), -} - -impl From for Error { - fn from(err: io::Error) -> Error { - Error::IoError(err) - } -} - -impl From for Error { - fn from(err: git2::Error) -> Error { - Error::Git2Error(err) - } -} - -pub type Result = result::Result<(), Error>; +pub type Result = anyhow::Result<()>; pub struct FileOperations { root: PathBuf, @@ -95,32 +75,36 @@ impl FileOperations { match op { Op::MkDir(dir) => fs::create_dir_all(dir)?, Op::GitInit(dir) => git_init(dir, &self.git_init_opts)?, - Op::Link { path, target } => unix::fs::symlink(target, path)?, + Op::Link { path, target } => fs::symlink_file(target, path)?, Op::Remove(file) => fs::remove_file(file)?, }; Ok(()) } } -fn git_init( - dir: PathBuf, - options: &git2::RepositoryInitOptions, -) -> result::Result<(), git2::Error> { - git2::Repository::init_opts(dir, options).map(|_| ()) +fn git_init(dir: PathBuf, options: &git2::RepositoryInitOptions) -> Result { + git2::Repository::init_opts(dir, options) + .map(|_| ()) + .map_err(anyhow::Error::from) } #[cfg(test)] mod tests { - use std::fs; - use std::path::{Path, PathBuf}; + use std::{ + fs, + path::{Path, PathBuf}, + }; use super::FileOperations; - use test_helpers::filesystem::set_up; + use crate::test_helpers::filesystem::set_up; #[test] fn can_link_file() { - let test_root = set_up("link"); - let target_root = set_up("link-target"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); + + let target_root_dir = set_up(); + let target_root = target_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); let target_path = target_root.join("target_file"); @@ -154,7 +138,8 @@ mod tests { #[test] fn can_remove_file() { - let test_root = set_up("unlink"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); // Create file to remove @@ -169,7 +154,8 @@ mod tests { #[test] fn does_not_remove_file_without_commit() { - let test_root = set_up("no-unlink"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); let file_path = test_root.join("file_a"); // Create file to remove @@ -182,7 +168,8 @@ mod tests { #[test] fn can_create_a_directory() { - let test_root = set_up("mkdir"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); assert!(!test_root.join("test").is_dir()); @@ -196,7 +183,8 @@ mod tests { #[test] fn does_not_create_a_directory_without_commit() { - let test_root = set_up("no-mkdir"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); assert!(!test_root.join("test").is_dir()); @@ -206,7 +194,8 @@ mod tests { #[test] fn can_create_path_of_needed_directories() { - let test_root = set_up("mkdir-deep"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); let path = Path::new("test").join("one").join("two").join("three"); @@ -220,7 +209,8 @@ mod tests { #[test] fn can_init_a_git_repo() { - let test_root = set_up("git-init"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); file_set.create_git_repo("."); @@ -233,7 +223,8 @@ mod tests { #[test] fn does_not_init_without_commit() { - let test_root = set_up("no-git-init"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); let path = Path::new("test").join("repo"); let git_dir_path = path.join(".git"); @@ -245,7 +236,8 @@ mod tests { #[test] fn can_init_a_git_repo_at_a_nonexistent_path() { - let test_root = set_up("git-deep"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); let path = Path::new("test").join("sub").join("repo"); @@ -259,7 +251,8 @@ mod tests { #[test] fn wont_re_init_an_already_existing_repository() { - let test_root = set_up("git-re-init"); + let test_root_dir = set_up(); + let test_root = test_root_dir.path(); let mut file_set = FileOperations::rooted_at(&test_root); file_set.create_git_repo("."); diff --git a/src/fs.rs b/src/fs.rs new file mode 100644 index 0000000..cefd553 --- /dev/null +++ b/src/fs.rs @@ -0,0 +1,7 @@ +pub use std::fs::*; + +#[cfg(windows)] +pub use std::os::windows::fs::symlink_file; + +#[cfg(unix)] +pub use std::os::unix::fs::symlink as symlink_file; diff --git a/src/hermit.rs b/src/hermit.rs index 1d25d94..c2daa1b 100644 --- a/src/hermit.rs +++ b/src/hermit.rs @@ -1,20 +1,18 @@ -use std::rc::Rc; -use std::{io, result}; +use std::{io, rc::Rc, result}; -use config::Config; -use file_operations::FileOperations; -use message; -use shell::Shell; +use thiserror::Error; -#[derive(Clone, Debug, Fail, PartialEq, Eq)] +use crate::{config::Config, file_operations::FileOperations, message, shell::Shell}; + +#[derive(Clone, Debug, Error, PartialEq, Eq)] pub enum Error { - #[fail(display = "{} subcommand has not been implemented yet", _0)] + #[error("{0} subcommand has not been implemented yet")] SubcommandNotImplemented(&'static str), - #[fail(display = "That is not the name of a shell")] + #[error("That is not the name of a shell")] ShellDoesNotExist, - #[fail(display = "No shell is active right now")] + #[error("No shell is active right now")] NoActiveShell, } @@ -84,15 +82,13 @@ impl Hermit { #[cfg(test)] mod tests { use super::*; - use test_helpers::ops::*; - use std::path::PathBuf; - use std::rc::Rc; + use std::{path::PathBuf, rc::Rc}; - use config::mock::MockConfig; - use config::Config; - use file_operations::FileOperations; - use file_operations::Op; + use crate::{ + config::mock::MockConfig, config::Config, file_operations::FileOperations, + file_operations::Op, test_helpers::ops::*, + }; fn hermit(config: &MockConfig) -> Hermit { Hermit::new(config.clone()) diff --git a/src/macros.rs b/src/macros.rs deleted file mode 100644 index ef0fb29..0000000 --- a/src/macros.rs +++ /dev/null @@ -1,17 +0,0 @@ -macro_rules! subcommand { - { - $fn_name:ident ( $name:expr ) { - $( - $method:ident ( $($args:expr),* ) - )* - } - } => { - fn $fn_name<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { - let subcommand = SubCommand::with_name($name) - $( - .$method($($args),*) - )*; - app.subcommand(subcommand) - } - } -} diff --git a/src/main.rs b/src/main.rs index 21a4a05..7337bda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,31 +1,20 @@ -extern crate clap; -extern crate failure; -#[macro_use] -extern crate failure_derive; -extern crate git2; -extern crate walkdir; - -#[cfg(test)] -#[macro_use] -extern crate lazy_static; - mod config; mod env; mod file_operations; +mod fs; mod hermit; mod message; mod shell; -#[macro_use] -mod macros; - use std::process; use clap::{App, AppSettings, Arg, ArgMatches, SubCommand}; -use config::{Config, FsConfig}; -use file_operations::FileOperations; -use hermit::{Error, Hermit, Result}; +use crate::{ + config::{Config, FsConfig}, + file_operations::FileOperations, + hermit::{Error, Hermit, Result}, +}; #[cfg(test)] mod test_helpers; @@ -42,13 +31,13 @@ fn main() { } } -#[cfg_attr(rustfmt, rustfmt_skip)] -fn run() -> Result<()>{ +#[rustfmt::skip] +fn run() -> anyhow::Result<()>{ let app = make_app_config(); let app_matches = app.get_matches(); let hermit_root = env::get_hermit_dir().expect("Could not determine hermit root location."); - let fs_config = FsConfig::new(hermit_root); + let fs_config = FsConfig::new(hermit_root)?; let mut hermit = Hermit::new(fs_config); let home_dir = env::home_dir().expect("Could not determine home directory."); @@ -81,7 +70,7 @@ fn report_errors(results: Vec) { } } -#[cfg_attr(feature = "cargo-clippy", allow(let_and_return))] +#[allow(clippy::let_and_return)] fn make_app_config<'a, 'b>() -> App<'a, 'b> { let app = App::new("hermit") .version(env!("CARGO_PKG_VERSION")) @@ -103,18 +92,36 @@ fn make_app_config<'a, 'b>() -> App<'a, 'b> { app } +macro_rules! subcommand { + { + fn $fn_name:ident ( $name:expr ) { + $( + $method:ident ( $($args:expr),* ) + )* + } + } => { + fn $fn_name<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { + let subcommand = SubCommand::with_name($name) + $( + .$method($($args),*) + )*; + app.subcommand(subcommand) + } + } +} + // ************************************************** // Subcommand configuration and implementation // ************************************************** subcommand! { - add_add_subcommand("add") { - about("Add files to your hermit shell") + fn add_add_subcommand("add") { + about("Add files to your hermit shell") } } fn handle_add( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -122,13 +129,13 @@ fn handle_add( } subcommand! { - add_clone_subcommand("clone") { + fn add_clone_subcommand("clone") { about("Create a local shell from an existing remote shell") } } fn handle_clone( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -136,13 +143,13 @@ fn handle_clone( } subcommand! { - add_doctor_subcommand("doctor") { + fn add_doctor_subcommand("doctor") { about("Make sure your hermit setup is sane") } } fn handle_doctor( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -150,13 +157,13 @@ fn handle_doctor( } subcommand! { - add_git_subcommand("git") { + fn add_git_subcommand("git") { about("Run git operations on the current shell") } } fn handle_git( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -164,7 +171,7 @@ fn handle_git( } subcommand! { - add_init_subcommand("init") { + fn add_init_subcommand("init") { about("Create a new hermit shell called SHELL_NAME. If no shell name \ is given, \"default\" is used.") arg(shell_name_arg("The name of the shell to be created.")) @@ -172,7 +179,7 @@ subcommand! { } fn handle_init( - matches: &ArgMatches, + matches: &ArgMatches<'_>, hermit: &mut Hermit, file_operations: &mut FileOperations, ) -> Result<()> { @@ -182,13 +189,13 @@ fn handle_init( } subcommand! { - add_nuke_subcommand("nuke") { + fn add_nuke_subcommand("nuke") { about("Permanently remove a hermit shell") } } fn handle_nuke( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -196,13 +203,13 @@ fn handle_nuke( } subcommand! { - add_shell_subcommand("shell") { + fn add_shell_subcommand("shell") { about("Display the shell you are currently inhabiting") } } fn handle_shell( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -212,13 +219,13 @@ fn handle_shell( } subcommand! { - add_status_subcommand("status") { - about("Display the status of your hermit shell") - } + fn add_status_subcommand("status") { + about("Display the status of your hermit shell") + } } fn handle_status( - _matches: &ArgMatches, + _matches: &ArgMatches<'_>, _hermit: &mut Hermit, _file_operations: &mut FileOperations, ) -> Result<()> { @@ -226,13 +233,13 @@ fn handle_status( } subcommand! { - add_inhabit_subcommand("inhabit") { + fn add_inhabit_subcommand("inhabit") { about("Switch to using a different hermit shell") } } fn handle_inhabit( - matches: &ArgMatches, + matches: &ArgMatches<'_>, hermit: &mut Hermit, file_operations: &mut FileOperations, ) -> Result<()> { diff --git a/src/message.rs b/src/message.rs index 768cbd0..b7051a7 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,11 +1,11 @@ -use failure::{self, Error}; +use std::fmt::Display; -use env; +use crate::env; pub fn error_str>(details: T) -> String { - error(failure::err_msg(details.into())) + error(anyhow::Error::msg(details.into())) } -pub fn error(failure: impl Into) -> String { - format!("{}: error: {}", env::get_program_name(), failure.into()) +pub fn error(failure: impl Display) -> String { + format!("{}: error: {}", env::get_program_name(), failure) } diff --git a/src/shell.rs b/src/shell.rs index 3964b0f..a3db8a5 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -1,8 +1,6 @@ -use std::path::PathBuf; -use std::rc::Rc; +use std::{path::PathBuf, rc::Rc}; -use config::Config; -use file_operations::FileOperations; +use crate::{config::Config, file_operations::FileOperations}; pub struct Shell { pub name: String, @@ -41,13 +39,13 @@ impl Shell { #[cfg(test)] mod tests { use super::*; - use test_helpers::ops::*; - use std::path::{Path, PathBuf}; - use std::rc::Rc; + use std::{ + path::{Path, PathBuf}, + rc::Rc, + }; - use config::mock::MockConfig; - use file_operations::Op; + use crate::{config::mock::MockConfig, file_operations::Op, test_helpers::ops::*}; fn root_path(path_str: &str) -> PathBuf { PathBuf::from(path_str) diff --git a/src/test_helpers/filesystem.rs b/src/test_helpers/filesystem.rs index d54481e..7abf921 100644 --- a/src/test_helpers/filesystem.rs +++ b/src/test_helpers/filesystem.rs @@ -1,30 +1,11 @@ use std::io::Write; -use std::path::PathBuf; use std::{fs, io}; -pub fn clean_up(test_root: &PathBuf) { - if test_root.exists() && test_root.is_dir() { - match fs::remove_dir_all(test_root) { - Err(e) => match e.kind() { - io::ErrorKind::NotFound => { - write!( - io::stderr(), - "\nRemove didn't find dir '{}'", - test_root.display() - ) - .unwrap(); - } - _ => panic!(e), - }, - Ok(()) => (), - } - } -} +use tempfile::{tempdir, TempDir}; -pub fn set_up(suffix: &str) -> PathBuf { - let suffix = format!("fs-tests-{}", suffix); - let test_root = PathBuf::from("target").join(&suffix); - clean_up(&test_root); +pub fn set_up() -> TempDir { + let test_root_dir = tempdir().expect("failed to create tempdir"); + let test_root = test_root_dir.path(); match fs::create_dir_all(&test_root) { Err(e) => match e.kind() { @@ -41,5 +22,5 @@ pub fn set_up(suffix: &str) -> PathBuf { Ok(()) => (), } - test_root + test_root_dir } diff --git a/src/test_helpers/ops.rs b/src/test_helpers/ops.rs index 0cf3f17..c001bcb 100644 --- a/src/test_helpers/ops.rs +++ b/src/test_helpers/ops.rs @@ -1,4 +1,4 @@ -use file_operations::Op; +use crate::file_operations::Op; use std::path::PathBuf; pub fn link_op_for(root_path: &PathBuf, op_root: &PathBuf, filename: &str) -> Op {