summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Gerace <nickagerace@gmail.com>2022-10-20 10:11:30 -0400
committerNick Gerace <nick@pop-os.localdomain>2022-10-20 12:30:59 -0400
commit478ec5413d811964845354bef6e48117145294cd (patch)
tree692b6ac2c546aee03f345315089ed7cf0b562ed2
parent9f27d8be6b3bf3ac0c1ed36c8ef3ead893f02ca4 (diff)
downloadgfold-478ec5413d811964845354bef6e48117145294cd.zip
Update to 4.1.0 and switch from argh to clap v4
- Update to 4.1.0 - Switch from argh to clap v4 - Remove ability to combine display flag with version flag - Move pre-4.0.0 changelog entries to their own file - Ensure integration test artifacts are built in the correct location Signed-off-by: Nick Gerace <nickagerace@gmail.com> Signed-off-by: Nick Gerace <nick@pop-os.localdomain>
-rw-r--r--CHANGELOG.md580
-rw-r--r--Cargo.lock272
-rw-r--r--crates/gfold/Cargo.toml7
-rw-r--r--crates/gfold/src/cli.rs70
-rw-r--r--crates/gfold/src/main.rs147
-rw-r--r--crates/gfold/src/report.rs2
-rw-r--r--crates/gfold/src/status.rs2
-rw-r--r--docs/CHANGELOG_PRE_V4.md522
-rw-r--r--docs/RELEASE.md2
9 files changed, 847 insertions, 757 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 810ccb5..138d2b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,70 +1,79 @@
# Changelog
-All notable changes to this project will be documented in this file.
-All changes are from [@nickgerace](https://github.com/nickgerace) unless otherwise specified.
+For new changes prior to version 4.0.0, please see [CHANGELOG_PRE_V4](./docs/CHANGELOG_PRE_V4.md).
-The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+- All notable changes to this project will be documented in this file
+- All changes are from [@nickgerace](https://github.com/nickgerace) unless otherwise specified
+- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
-## [Unreleased]
+## Unreleased
-<!-- The latest version contains all changes. -->
+The latest version contains all changes.
-### Added
+## 4.1.0 - 2022-10-20
-- Debug symbol stripping for `cargo install` users (result: ~79% of the size of `4.0.1`)
+- Add debug symbol stripping for `cargo install` users (result: ~79% of the size of `4.0.1`)
### Changed
-- Switched to `cargo` workspaces
+- Bump dependencies
+- Change CLI library from `argh` to `clap v4`
+- Ensure integration test artifacts exist in the correct location
+- Refactor to use `cargo` workspaces, which should unlock the ability to create "scripts" via sub-crates
+
+### Removed
+
+- Remove ability to print the version as a single JSON field (combine `-V/--version` with `-d/--display json`)
+ - Normally, this would necessitate a bump of the "major" field in the version, but `-V/--version` is serializable to JSON (just a string)
-### [4.0.1] - 2022-07-05
+## 4.0.1 - 2022-07-05
### Changed
- Bump dependencies
-### [4.0.0] - 2022-05-10
+## 4.0.0 - 2022-05-10
### Added
-- [Bors](https://bors.tech/) to avoid merge skew / semantic merge conflicts
-- Color mode option with the following choices: "always", "compatibility" and "never"
+- Add [Bors](https://bors.tech/) to avoid merge skew/semantic merge conflicts
+- Add color mode option with the following choices: "always", "compatibility" and "never"
- "always": display with rich colors (default)
- "compatibility": display with portable colors
- "never": display with no color
-- Display flag with the following choices: "standard" (or "default"), "json" and "classic"
+- Add display flag with the following choices: "standard" (or "default"), "json" and "classic"
- "standard" (or "default") and "classic" output options return from the previous release
- "json" output is a new option that displays all results in valid JSON, which is useful for third party applications, plugins, parsers, etc.
-- Documentation comments almost everywhere for `cargo doc`
-- [git2-rs](https://github.com/rust-lang/git2-rs), which replaces `git` subcommand usage
+- Add documentation comments almost everywhere for `cargo doc`
+- Add [git2-rs](https://github.com/rust-lang/git2-rs), which replaces `git` subcommand usage
- Even though `git` subcommands were used over **git2-rs** to reduce binary size, significant speed increases could only be achieved by using the latter
- More consistent behavior since git2-rs can be tested at a locked version
-- JSON output flag for both version and results printing
-- Troubleshooting section to CLI help
-- Troubleshooting section to README for using `RUST_LOG` and `RUST_BACKTRACE`
+- Add JSON output flag for both version and results printing
+- Add roubleshooting section to CLI help
+- Add troubleshooting section to README for using `RUST_LOG` and `RUST_BACKTRACE`
### Changed
-- Config file location from `<prefix>/gfold/gfold.json` to `<prefix>/gfold.toml`
-- Config file type from JSON to TOML
-- CLI help sections to be divided by headers
-- Major performance improvements due to moving from sequential target generation to nested, parallel iterators for target generation
-- Module layout
+- Change config file location from `<prefix>/gfold/gfold.json` to `<prefix>/gfold.toml`
+- Change config file type from JSON to TOML
+- Change CLI help sections to be divided by headers
+- Drastically improve performance by moving from sequential target generation to nested, parallel iterators for target generation
+- Modify grey color default to avoid a bug where the `stdout` color is not refreshed within `tmux` when using macOS `Terminal.app`
+- Refactor module layout
- `display` now contains its child, `color`
- `report` now contains its child, `target`
-- Grey color default to avoid a bug where the `stdout` color is not refreshed within `tmux` when using macOS `Terminal.app`
-- Testing for the entire crate
+- Refactor testing for the entire crate
- All tests have been replaced in favor on one integration test
- The old tests relied on developer's environment, which is highly variable
- The new test creates multiple files, directories, and repositories in the `target` directory to simulate an actual development environment
-- The `color` module now uses a harness rather than individual functions
+- Use a harness for the `color` module instead of individual functions
### Removed
-- Debug flag in favor of using `RUST_LOG`
-- Display of `none` fields for the standard (default) display of result (i.e. now, if an optional field was not found, it is not shown)
-- Git path option for CLI and config file
-- `git` subcommand usage
+- Remove debug flag in favor of using `RUST_LOG`
+- Remove display of `none` fields for the standard (default) display of result (i.e. now, if an optional field was not found, it is not shown)
+- Remove git path option for CLI and config file
+- Remove `git` subcommand usage
### Notes
@@ -73,513 +82,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Binary size has increased, but speed has taken priority for this release
- Using `RUST_LOG` and `RUST_BACKTRACE` should be more helpful when debugging unexpected output, performance or suspected bugs
-### [3.0.0] - 2022-01-06
-
-### Added
-
-- Ability to ignore config file options
-- Ability to print merged config options
-- Ability to specify path to `git`
-- Ability to store default path target in config file (defaults to current working directory)
-- Ability to use config file in `$HOME/.config/gfold/gfold.json` and `{FOLDERID_Profile}\.config\gfold\gfold.json`
-- Ability to use old display mode with `--classic` flag and store preference in config file
-- Formal CLI parsing library, `argh`
-- Install and uninstall scripts
-- New display mode that avoids grouping repositories (API-breaking since this is the new default display mode)
-
-### Changed
-
-- Codebase to a domain-driven architecture (major refactor)
-
-### Removed
-
-- Mention of the [deprecated, old Homebrew tap](https://github.com/nickgerace/homebrew-gfold) in the README
-- Short `-h` flag due to CLI crate addition (`argh`)
-
-### Notes
-
-- Evaluated using `tracing` and `tracing-subscriber` over `log` and `env_logger`, but due to their combined larger size, the logging crates remain the same as before.
-- The config file can be non-existent, empty, partially filled out or completely filled out. There's also an option to ignore the config file completely and only use CLI options.
-- This crate has used other CLI parsing libraries in the past, and recently did not use any, but with manual testing and [publicly available benchmarks](https://github.com/rust-cli/argparse-benchmarks-rs/blob/c37e78aabdaa4384a9c49be3735a686803d0e37a/README.md#results), `argh` is now in use.
-
-## [2.0.2] - 2021-12-02
-
-### Changed
-
-- Misc package bumps
-
-## [2.0.1] - 2021-10-29
-
-### Added
-
-- Logger that can be set via an environment variable (`RUST_LOG`)
-
-### Changed
-
-- Permission denied errors to be logged rather than displayed to `stderr`
-
-### Misc
-
-- Ensure `crates.io` and `git` tag are in sync (very slight and accidental derivation for `2.0.0`)
-
-## [2.0.0] - 2021-10-29
-
-### Added
-
-- Discrete Code of Conduct file
-- Unpushed commit checking by default (greedy static analysis, so this may need to be tuned for edge cases)
-- `git` CLI wrapper instead of Git library usage due to security, Git already being installed, inconsistencies between the library and the CLI, and more
-
-### Changed
-
-- Codebase re-write geared towards data-efficiency and parallelism
-- Dramatic runtime speed and binary size improvements (consistently able to reproduce, but heavily variable based on payload, OS, etc.)
-- Entire structure from library-driven to application-driven (no `lib.rs`)
-
-### Removed
-
-- All CLI flags except for `-h/--help` and `-V/--version`
-- CLI crate since it is unneeded
-- Git library usage in favor of leveraging `git` subcommands due to security, Git already being installed, inconsistencies between the library and the CLI, and more
-- `DEVELOPING.md` and `EXTRA.md` since they were outdated/unimportant
-- `lib.rs` and the crate's library-based components
-
-## [1.4.1] - 2021-08-02
-
-### Changed
-
-- Misc package bumps
-
-## [1.4.0] - 2021-06-17
-
-### Changed
-
-- Continue upon PermissionDenied errors rather than exiting
-- Documentation to be moved to the new `docs` directory
-
-## [1.3.0] - 2021-05-25
-
-### Changed
-
-- Config type to be embedded within the Driver
- - Not in public library modules, but this should improve generation efficiency
-
-### Removed
-
-- `-d/--debug` flag since all logging has been removed from the librariy, and `main.rs` does not log
-- `env_logger` crate
-- `log` crate
-- Logging from the entire library in favor of returning errors when needed and handling when possible/preferred
-
-## [1.2.1] - 2021-05-23
-
-### Changed
-
-- Bold table headers instead of repo names
-
-### Removed
-
-- Extra newline before first entry when printing all tables
-
-## [1.2.0] - 2021-05-16
-
-### Removed
-
-- Middleware `run` function in `lib.rs` since it's unecessary and unintuitive
- - Before, you used a type from the `driver` module as a parameter for `run`
- - Now, you only use types from `driver`
-
-## [1.1.1] - 2021-05-16
-
-### Changed
-
-- Config management to be done by applications consuming the library (moved out of `lib.rs`)
-- Driver module to be public
-- Printing to STDOUT to be done by applications consuming the library (moved out of `lib.rs`)
-- `TableWrapper` type to be a private, internal type
-
-## [1.1.0] - 2021-05-15
-
-### Added
-
-- Shallow search flag to disable recursive search (accessible via `-s/--shallow`)
-
-### Changed
-
-- Binary size to be ~60% of the size of `gfold 1.0.4`
- - Primarily, this was achieved by removing unused default features from imported crates
- - Runtime speed is the same, better, or more consistent
-- Default search behavior to be recursive rather than shallow
-- Short flag for `--skip-sort` from `-s` to `-x`
-- Workspace implementation to a single crate (similar to before `gfld`)
-
-### Removed
-
-- `gfld`, the lightweight version of `gfold` due the following reasons:
- - its over ~105% average slower runtime speed (despite it being ~40% of the size)
- - printing to STDOUT was not consistent in subcommand scenarios
-- Recursive flag since `gfold` uses recursive search by default
-
-## [1.0.4] - 2021-04-04
-
-### Changed
-
-- Fixed final output order (sorted by name, then by status)
-
-## [1.0.3] - 2021-04-02
-
-### Changed
-
-- Directory name finder to default to the current working directory if empty (`gfld`)
-- Misc. optimizations in `gfld`
-- Release profile optimizations to be at workspace scope for binaries
-
-## [1.0.2] - 2021-04-01
-
-### Changed
-
-- `gfld` output to not include parent root since all results started with the same string
-
-## [1.0.1] - 2021-03-30
-
-### Added
-
-- `Cargo.lock` to the workspace to fix AUR builds
-
-## Changed
-
-- CI to use `--locked` for builds
-
-## [1.0.0] - 2021-03-29
-
-### Added
-
-- A brand new, minimal CLI: `gfld`
-- `DEVELOPING.md` for instructions on building `gfld`
-
-### Changed
-
-- Documentation to include `gfld`
-- GitHub issue template to include `gfld` information
-- GitHub PR CI to only build for Linux while keeping macOS and Windows for release CI
-- The repository to be split into two crates: `gfold` and `gfld`
-- Unnecessary `PathBuf` usages to `Path` when possible in `util.rs`
-
-### Removed
-
-- Release workflow for GitHub actions (now, it is "merge only")
-- Uploaded binaries due to lack of checksums and maintenance
-
-## [0.9.1] - 2021-03-16
-
-### Added
-
-- RELEASE file for releasing `gfold`
-
-### Changed
-
-- README installation section to be condensed
-- LICENSE to not use copyright dates or name (reduce maintenance)
-
-### Removed
-
-- Makefile in order to be cross-platform-friendly
-
-## [0.9.0] - 2021-02-15
-
-### Added
-
-- Email display feature
-- Include standard directory feature
-- Shorthand flag for all features without one
-
-### Changed
-
-- Directory walking to skip hidden directories
-- Repository opening check to log error in debug mode rather than panic
-
-### Removed
-
-- File header comments
-- Prettytable macros
-
-## [0.8.4] - 2021-01-26
-
-### Added
-
-- Dependencies section to CHANGELOG
-- `paru` to suggested AUR helpers in README
-
-### Changed
-
-- All CRLF files to LF
-- Condense tests into loops where possible
-- Label `unpush_check` as an experimental feature
-- `macos-amd64` to `darwin-amd64`
-- `unpush_check` from `disable` to `enable`
-
-## [0.8.3] - 2020-12-15
-
-### Added
-
-- Disable unpushed commit check flag and functionality
-- Logging for origin and local reference names for unpushed commit check
-
-## [0.8.2] - 2020-12-14
-
-### Added
-
-- `gfold --version` to issue template
-- Unpush functionality (again)
-
-### Changed
-
-- Unpush function to only return boolean
-
-### Removed
-
-- Contributing section from README to reduce requirements
-- Empty results message since it was potentially misleading
-
-## [0.8.1] - 2020-12-01
-
-### Added
-
-- Condition enum for adding rows to final table
-- Debug flag
-- Many debug statements for the new debug flag
-
-### Changed
-
-- Bare repository checking to original behavior
-- `util.rs` results generation to include Condition enum
-
-### Removed
-
-- Carets from `Cargo.toml` to maintain stability
-- Unpush functionality temporarily
-
-## [0.8.0] - 2020-11-26
-
-### Added
-
-- Debugging calls for general usage and the new unpushed commit code
-- Derive debug to the `Config` struct
-- Lightweight logging stack with `env_logger` and `log`
-- Two files: `driver.rs` and `util.rs`
-- Unpushed commit status functionality and output
-
-### Changed
-
-- Bare repository detection to use upstream function
-- Library contents into `driver.rs` and `util.rs` through a major refactor
-
-## [0.7.1] - 2020-11-18
-
-### Added
-
-- In-depth description of the `run` function
-
-### Changed
-
-- Consolidated boolean test permutations into one test
-
-### Removed
-
-- All non-public comments in `*.rs` files
-
-## [0.7.0] - 2020-11-11
-
-### Added
-
-- Crate to crates.io
-- Crates.io publishing requirements to `[package]` in `Cargo.toml`
-- Homebrew tap
-- Library description to `lib.rs`
-
-### Changed
-
-- Dependency versioning to use carets
-- README mentions of specific version tags
-- README plaintext blocks to single quotes when mixed with formatted text
-- README to sort installation method by package managers first
-
-### Removed
-
-- Public structs and functions without only `run` (primary backend driver) remaining
-
-## [0.6.2] - 2020-11-03
-
-### Added
-
-- No color flag and functionality
-
-### Removed
-
-- Pull request template
-
-## [0.6.1] - 2020-10-12
-
-### Added
-
-- Code of Conduct link
-- GitHub issue template
-- GitHub pull request template
-
-### Changed
-
-- LICENSE to be extended through 2021
-- Match blocks in `lib.rs` to be consolidated
-- Nearly all contents of `lib.rs` to return errors back to the calling function in `main.rs`
-
-### Removed
-
-- Duplicate code related to the match block consolidation
-
-## [0.6.0] - 2020-10-10
-
-### Added
-
-- Doc comments and `cargo doc` to `release` target
-- `eyre` for simple backtrace reporting
-- `gfold-bin` to AUR portion of README
-- `lib.rs` as part of major refactor
-
-### Changed
-
-- Pre-build Makefile targets to be consolidated
-- Refactor source code to be driven by a library, helmed by `lib.rs`
-
-### Removed
-
-- `util.rs` and `gfold.rs` as part of major refactor
-
-## [0.5.2] - 2020-10-08
-
-### Added
-
-- GitHub release downloads to README
-- Binary publishing workflow to the dummy file
-
-### Changed
-
-- Existing merge workflow to use debug building instead of release building
-- Makefile target containing the old default branch name
-
-### Removed
-
-- Makefile target for statically-linked building
-
-## [0.5.1] - 2020-10-07
-
-### Added
-
-- Release dummy GitHub Action
-- Version README badge
-
-### Changed
-
-- A reduction to CI build time and complexity by combining the test and check steps,
-- GitHub workflow "merge" file name to "merge.yml"
-- GitHub workflow name to "merge"
-- OS compatibility claims in README through a simplified list
-- README badges to use shields.io
-
-### Removed
-
-- MUSL mentions in docs
-
-## [0.5.0] - 2020-09-02
-
-### Added
-
-- Recursive search feature and flag
-- Skip sort feature and flag
-- Unit tests for recursive search and skip sort
-- AUR PKGBUILD GitHub repository to README
-- Results and TableWrapper structs, and relevant functions,
-- Three methods for Results struct (printing/sorting/populating results)
-- Make targets for `run-recursive` and `install-local`
-
-### Changed
-
-- Switch from `walk_dir` function to object-driven harness for execution
-- Move `walk_dir` function logic to `Results` method
-- Function `is_git_repo` to its own file
-- Any unnecessary match block to use "expect" instead
-- Cargo install to use a specific tag
-- Version upgrade workflow to Makefile
-
-### Removed
-
-- Leftover "FIXME" comments for recursive search ideas
-
-## [0.4.0] - 2020-08-31
-
-### Added
-
-- Changelog
-- Tags automation
-
-### Changed
-
-- Example output to use mythical repositories
-- Path flag to positional argument
-- Switched to structopt library for CLI parsing
-
-### Removed
-
-- Tag v0.3.0 (duplicate of 0.3.0 with the "v" character)
-- All GitHub releases before 0.3.1
-- Releases information from README
-
-## [0.3.1] - 2020-08-30
-
-### Added
-
-- Add AUR installation documentation
-- Add AUR packages from [@orhun](https://github.com/orhun)
-
-### Changed
-
-- Switch to Apache 2.0 license from MIT license
-- Reorganize build tags, and add test build target
-
-## [0.3.0] - 2020-08-24
-
-### Changed
-
-- Handling for bare repositories to print their status to STDOUT with the mentorship of [@yaahc](https://github.com/yaahc)
-
-## [0.2.2] - 2020-08-24
-
-### Changed
-
-- "Continue" to the next repository object if the current object is bare
-- Release availability in README
-
-## [0.2.1] - 2020-06-08
-
-### Added
-
-- Experimental statically-linked, MUSL support
-
-## [0.2.0] - 2020-05-10
-
-### Changed
-
-- Switched to prettytable-rs
-- Unit tests to work with prettytable-rs
-
-## [0.1.1] - 2020-04-10
-
-### Added
-
-- Example output, contributors, and usage in README
-- Building for Windows, macOS, and Linux amd64 in CI pipeline from [@jrcichra](https://github.com/jrcichra)
-
-## [0.1.0] - 2020-04-08
-
-### Added
+## Before 4.0.0
-- Base contents
+Please see [CHANGELOG_PRE_V4](./docs/CHANGELOG_PRE_V4.md).
diff --git a/Cargo.lock b/Cargo.lock
index b84a94e..c94a9c1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -19,43 +19,14 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "anyhow"
-version = "1.0.60"
+version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c794e162a5eff65c72ef524dfe393eb923c354e350bb78b9c7383df13f3bc142"
+checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
dependencies = [
"backtrace",
]
[[package]]
-name = "argh"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7e7e4aa7e40747e023c0761dafcb42333a9517575bbf1241747f68dd3177a62"
-dependencies = [
- "argh_derive",
- "argh_shared",
-]
-
-[[package]]
-name = "argh_derive"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "69f2bd7ff6ed6414f4e5521bd509bae46454bbd513801767ced3f21a751ab4bc"
-dependencies = [
- "argh_shared",
- "heck",
- "proc-macro2",
- "quote",
- "syn",
-]
-
-[[package]]
-name = "argh_shared"
-version = "0.1.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "47253b98986dafc7a3e1cf3259194f1f47ac61abb57a57f46ec09e48d004ecda"
-
-[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -116,6 +87,43 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
+name = "clap"
+version = "4.0.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06badb543e734a2d6568e19a40af66ed5364360b9226184926f89d229b4b4267"
+dependencies = [
+ "atty",
+ "bitflags",
+ "clap_derive",
+ "clap_lex",
+ "once_cell",
+ "strsim",
+ "termcolor",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.0.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
+dependencies = [
+ "heck",
+ "proc-macro-error",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "0.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8"
+dependencies = [
+ "os_str_bytes",
+]
+
+[[package]]
name = "crossbeam-channel"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -138,29 +146,43 @@ dependencies = [
[[package]]
name = "crossbeam-epoch"
-version = "0.9.10"
+version = "0.9.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1"
+checksum = "f916dfc5d356b0ed9dae65f1db9fc9770aa2851d2662b988ccf4fe3516e86348"
dependencies = [
"autocfg",
"cfg-if",
"crossbeam-utils",
"memoffset",
- "once_cell",
"scopeguard",
]
[[package]]
name = "crossbeam-utils"
-version = "0.8.11"
+version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
+checksum = "edbafec5fa1f196ca66527c1b12c2ec4745ca14b50f1ad8f9f6f720b55d11fac"
dependencies = [
"cfg-if",
- "once_cell",
]
[[package]]
+name = "ctor"
+version = "0.1.26"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096"
+dependencies = [
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "diff"
+version = "0.1.13"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8"
+
+[[package]]
name = "dirs"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -182,15 +204,15 @@ dependencies = [
[[package]]
name = "either"
-version = "1.7.0"
+version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3f107b87b6afc2a64fd13cac55fe06d6c8859f12d4b14cbcdd2c67d0976781be"
+checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "env_logger"
-version = "0.9.0"
+version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b2cf0344971ee6c64c31be0d530793fba457d322dfec2810c453d0ef228f9c3"
+checksum = "c90bf5f19754d10198ccb95b70664fc925bd1fc090a0fd9a6ebc54acc8cd6272"
dependencies = [
"atty",
"humantime",
@@ -199,11 +221,10 @@ dependencies = [
[[package]]
name = "form_urlencoded"
-version = "1.0.1"
+version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191"
+checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8"
dependencies = [
- "matches",
"percent-encoding",
]
@@ -220,14 +241,15 @@ dependencies = [
[[package]]
name = "gfold"
-version = "4.0.1"
+version = "4.1.0"
dependencies = [
"anyhow",
- "argh",
+ "clap",
"dirs",
"env_logger",
"git2",
"log",
+ "pretty_assertions",
"rayon",
"serde",
"serde_json",
@@ -257,12 +279,9 @@ dependencies = [
[[package]]
name = "heck"
-version = "0.3.3"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
-dependencies = [
- "unicode-segmentation",
-]
+checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
@@ -281,35 +300,34 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "idna"
-version = "0.2.3"
+version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8"
+checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6"
dependencies = [
- "matches",
"unicode-bidi",
"unicode-normalization",
]
[[package]]
name = "itoa"
-version = "1.0.3"
+version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754"
+checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]]
name = "jobserver"
-version = "0.1.24"
+version = "0.1.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af25a77299a7f711a01975c35a6a424eb6862092cc2d6c72c4ed6cbc56dfc1fa"
+checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b"
dependencies = [
"libc",
]
[[package]]
name = "libc"
-version = "0.2.127"
+version = "0.2.135"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "505e71a4706fa491e9b1b55f51b95d4037d0821ee40131190475f692b35b009b"
+checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
[[package]]
name = "libgit2-sys"
@@ -345,12 +363,6 @@ dependencies = [
]
[[package]]
-name = "matches"
-version = "0.1.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
-
-[[package]]
name = "memchr"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -367,9 +379,9 @@ dependencies = [
[[package]]
name = "miniz_oxide"
-version = "0.5.3"
+version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc"
+checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34"
dependencies = [
"adler",
]
@@ -395,15 +407,30 @@ dependencies = [
[[package]]
name = "once_cell"
-version = "1.13.0"
+version = "1.15.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
+
+[[package]]
+name = "os_str_bytes"
+version = "6.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff"
+
+[[package]]
+name = "output_vt100"
+version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
+checksum = "628223faebab4e3e40667ee0b2336d34a5b960ff60ea743ddfdbcf7770bcfb66"
+dependencies = [
+ "winapi",
+]
[[package]]
name = "percent-encoding"
-version = "2.1.0"
+version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
+checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pkg-config"
@@ -412,10 +439,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae"
[[package]]
+name = "pretty_assertions"
+version = "1.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
+dependencies = [
+ "ctor",
+ "diff",
+ "output_vt100",
+ "yansi",
+]
+
+[[package]]
+name = "proc-macro-error"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
+dependencies = [
+ "proc-macro-error-attr",
+ "proc-macro2",
+ "quote",
+ "syn",
+ "version_check",
+]
+
+[[package]]
+name = "proc-macro-error-attr"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "version_check",
+]
+
+[[package]]
name = "proc-macro2"
-version = "1.0.43"
+version = "1.0.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a2ca2c61bc9f3d74d2886294ab7b9853abd9c1ad903a3ac7815c58989bb7bab"
+checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
dependencies = [
"unicode-ident",
]
@@ -493,18 +556,18 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "serde"
-version = "1.0.143"
+version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53e8e5d5b70924f74ff5c6d64d9a5acd91422117c60f48c4e07855238a254553"
+checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.143"
+version = "1.0.145"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d3d8e8de557aee63c26b85b947f5e59b690d0454c753f3adeb5cd7835ab88391"
+checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c"
dependencies = [
"proc-macro2",
"quote",
@@ -513,9 +576,9 @@ dependencies = [
[[package]]
name = "serde_json"
-version = "1.0.83"
+version = "1.0.87"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
+checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45"
dependencies = [
"itoa",
"ryu",
@@ -530,10 +593,16 @@ dependencies = [
]
[[package]]
+name = "strsim"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
+
+[[package]]
name = "syn"
-version = "1.0.99"
+version = "1.0.102"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "58dbef6ec655055e20b86b15a8cc6d439cca19b667537ac6a1369572d151ab13"
+checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1"
dependencies = [
"proc-macro2",
"quote",
@@ -551,18 +620,18 @@ dependencies = [
[[package]]
name = "thiserror"
-version = "1.0.32"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
+checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
-version = "1.0.32"
+version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
+checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2",
"quote",
@@ -601,34 +670,27 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
-version = "1.0.3"
+version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4f5b37a154999a8f3f98cc23a628d850e154479cd94decf3414696e12e31aaf"
+checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "unicode-normalization"
-version = "0.1.21"
+version = "0.1.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6"
+checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921"
dependencies = [
"tinyvec",
]
[[package]]
-name = "unicode-segmentation"
-version = "1.9.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
-
-[[package]]
name = "url"
-version = "2.2.2"
+version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c"
+checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643"
dependencies = [
"form_urlencoded",
"idna",
- "matches",
"percent-encoding",
]
@@ -639,6 +701,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
+name = "version_check"
+version = "0.9.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
+
+[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -674,3 +742,9 @@ 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 = "yansi"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
diff --git a/crates/gfold/Cargo.toml b/crates/gfold/Cargo.toml
index f9202af..2e6b688 100644
--- a/crates/gfold/Cargo.toml
+++ b/crates/gfold/Cargo.toml
@@ -10,11 +10,11 @@ readme = "README.md"
repository = "https://github.com/nickgerace/gfold/"
edition = "2021"
-version = "4.0.1"
+version = "4.1.0"
[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
-argh = "0"
+clap = { version = "4", features = ["derive"] }
dirs = "4"
git2 = { version = "0", default_features = false }
log = "0"
@@ -28,3 +28,6 @@ toml = "0"
# Source: https://github.com/env-logger-rs/env_logger/blob/v0.9.0/Cargo.toml#L47
# Removed features: ["regex", "termcolor"]
env_logger = { version = "0", features = ["atty", "humantime"], default_features = false }
+
+[dev-dependencies]
+pretty_assertions = "1"
diff --git a/crates/gfold/src/cli.rs b/crates/gfold/src/cli.rs
index 89518c2..4ccf474 100644
--- a/crates/gfold/src/cli.rs
+++ b/crates/gfold/src/cli.rs
@@ -4,12 +4,12 @@
use crate::config::{ColorMode, Config, DisplayMode};
use crate::error::Error;
use crate::run;
-use argh::FromArgs;
+use clap::Parser;
use log::debug;
use std::env;
-#[derive(FromArgs)]
-#[argh(description = "More information: https://github.com/nickgerace/gfold
+const HELP: &str = "\
+More information: https://github.com/nickgerace/gfold
Description:
This application helps you keep track of multiple Git repositories via CLI.
@@ -27,39 +27,33 @@ Config File Usage:
Troubleshooting:
Investigate unexpected behavior by prepending execution with
\"RUST_BACKTRACE=1\"and \"RUST_LOG=debug\". You can adjust those variable's
- values to aid investigation.")]
-struct Args {
- #[argh(
- positional,
- description = "specify path to target directory (defaults to current working directory)"
- )]
+ values to aid investigation.";
+
+#[derive(Parser)]
+#[command(version, about = HELP, long_about = None)]
+struct Cli {
+ #[arg(help = "specify path to target directory (defaults to current working directory)")]
path: Option<String>,
- #[argh(
- option,
- short = 'c',
- description = "specify color mode [options: \"always\", \"compatibility\", \"never\"]"
+ #[arg(
+ short,
+ long,
+ help = "specify color mode (options: [\"always\", \"compatibility\", \"never\"])"
)]
color_mode: Option<String>,
- #[argh(
- option,
- short = 'd',
- description = "specify display format [options: \"standard\" or \"default\", \"json\", \"classic\"]"
+ #[arg(
+ short,
+ long,
+ help = "specify display format (options: [\"standard\", \"default\", \"json\", \"classic\"])"
)]
display_mode: Option<String>,
- #[argh(
- switch,
- description = "display finalized config options and exit (merged options from an optional config file and command line arguments)"
+ #[arg(
+ long,
+ help = "display finalized config options and exit (merged options from an optional config file and command line arguments)"
)]
dry_run: bool,
- #[argh(switch, short = 'i', description = "ignore config file settings")]
+ #[arg(short, long, help = "ignore config file settings")]
ignore_config_file: bool,
- #[argh(
- switch,
- short = 'V',
- description = "display version information (tip: set display mode (-d/--display-mode) to \"json\" to display version information as valid JSON"
- )]
- version: bool,
}
/// Parse CLI arguments, initialize the logger, merge configurations as needed, and call
@@ -67,16 +61,16 @@ struct Args {
pub fn parse_and_run() -> anyhow::Result<()> {
// First and foremost, get logging up and running. We want logs as quickly as possible for
// debugging by setting "RUST_LOG".
- let args: Args = argh::from_env();
+ let cli = Cli::parse();
debug!("collected args");
- let mut config = match args.ignore_config_file {
+ let mut config = match cli.ignore_config_file {
true => Config::new()?,
false => Config::try_config()?,
};
debug!("loaded initial config");
- if let Some(found_display_mode) = &args.display_mode {
+ if let Some(found_display_mode) = &cli.display_mode {
config.display_mode = match found_display_mode.to_lowercase().as_str() {
"classic" => DisplayMode::Classic,
"json" => DisplayMode::Json,
@@ -85,17 +79,7 @@ pub fn parse_and_run() -> anyhow::Result<()> {
}
}
- // If the version flag is enabled, we need to use display mode to determine its output shape
- // and then return once version information is displayed.
- if args.version {
- match &config.display_mode {
- DisplayMode::Json => println!("{}", serde_json::to_string(env!("CARGO_PKG_VERSION"))?),
- _ => println!("gfold {}", env!("CARGO_PKG_VERSION")),
- }
- return Ok(());
- }
-
- if let Some(found_color_mode) = &args.color_mode {
+ if let Some(found_color_mode) = &cli.color_mode {
config.color_mode = match found_color_mode.to_lowercase().as_str() {
"always" => ColorMode::Always,
"compatibility" => ColorMode::Compatibility,
@@ -104,12 +88,12 @@ pub fn parse_and_run() -> anyhow::Result<()> {
}
}
- if let Some(found_path) = &args.path {
+ if let Some(found_path) = &cli.path {
config.path = env::current_dir()?.join(found_path).canonicalize()?;
}
debug!("finalized config options");
- match &args.dry_run {
+ match &cli.dry_run {
true => config.print()?,
false => run::run(&config)?,
}
diff --git a/crates/gfold/src/main.rs b/crates/gfold/src/main.rs
index dc47f75..b0d069a 100644
--- a/crates/gfold/src/main.rs
+++ b/crates/gfold/src/main.rs
@@ -35,14 +35,20 @@ mod tests {
use crate::config::{ColorMode, Config, DisplayMode};
use crate::report::{LabeledReports, Report};
use crate::status::Status;
+
+ use anyhow::{anyhow, Result};
use git2::ErrorCode;
use git2::Repository;
+ use pretty_assertions::assert_eq;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::{env, fs, io};
+ /// This integration test for `gfold` covers an end-to-end usage scenario. It does not
+ /// _remove_ anything in the filesystem (for saftey), so you must delete the `test`
+ /// directory underneath `target` to regenerate a clean dataset.
#[test]
- fn integration() {
+ fn integration() -> Result<()> {
// Test directory structure within "target":
// └── test
// ├── bar
@@ -54,56 +60,34 @@ mod tests {
// │ └── newfile
// ├── three
// └── two
-
- let manifest_directory = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
- let target = manifest_directory
- .parent()
- .expect("could not get parent")
- .parent()
- .expect("could not get parent")
- .parent()
- .expect("could not get parent")
- .join("target");
- create_directory(&target);
-
- // Warning: setting up test directory by removing it and its contents recursively.
- let test = target.join("test");
- if let Err(e) = fs::remove_dir_all(&test) {
- if e.kind() != io::ErrorKind::NotFound {
- panic!(
- "could not remove directory and its contents ({:?}) due to error kind: {:?}",
- &test,
- e.kind()
- );
- }
- }
- create_directory(&test);
+ let test_directory = integration_init()?;
+ create_directory(&test_directory)?;
for name in ["foo", "bar", "baz"] {
- let current = test.join(name);
- create_directory(&current);
- Repository::init(&current).expect("could not initialize repository");
+ let current = test_directory.join(name);
+ create_directory(&current)?;
+ Repository::init(&current)?;
if name == "foo" {
- create_file(&current.join("newfile"));
+ create_file(&current.join("newfile"))?;
}
}
- let nested = test.join("nested");
- create_directory(&nested);
+ let nested = test_directory.join("nested");
+ create_directory(&nested)?;
for name in ["one", "two", "three"] {
let current = nested.join(name);
- create_directory(&current);
- let repository = Repository::init(&current).expect("could not initialize repository");
+ create_directory(&current)?;
+ let repository = Repository::init(&current)?;
if name == "one" {
- create_file(&current.join("newfile"));
+ create_file(&current.join("newfile"))?;
}
if name == "two" {
if let Err(e) = repository.remote("origin", "https://github.com/nickgerace/gfold") {
if e.code() != ErrorCode::Exists {
- panic!("{}", e);
+ return Err(e.into());
}
}
}
@@ -111,48 +95,54 @@ mod tests {
if name == "three" {
if let Err(e) = repository.remote("fork", "https://github.com/nickgerace/gfold") {
if e.code() != ErrorCode::Exists {
- panic!("{}", e);
+ return Err(e.into());
}
}
}
}
- let mut config = Config::new().expect("could not create new config");
- config.path = test;
+ let mut config = Config::new()?;
+ config.path = test_directory.clone();
config.color_mode = ColorMode::Never;
assert!(run::run(&config).is_ok());
// Now, let's ensure our reports are what we expect.
- let test_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
- .parent()
- .expect("could not get parent")
- .parent()
- .expect("could not get parent")
- .parent()
- .expect("could not get parent")
- .join("target")
- .join("test");
let mut expected_reports: LabeledReports = BTreeMap::new();
- let key = test_dir
+ let key = test_directory
.to_str()
- .expect("could not convert to str")
+ .ok_or_else(|| anyhow!("could not convert PathBuf to &str"))?
.to_string();
let mut reports = vec![
- Report::new(&test_dir.join("foo"), "HEAD", &Status::Unclean, None, None)
- .expect("could not create report"),
- Report::new(&test_dir.join("bar"), "HEAD", &Status::Clean, None, None)
- .expect("could not create report"),
- Report::new(&test_dir.join("baz"), "HEAD", &Status::Clean, None, None)
- .expect("could not create report"),
+ Report::new(
+ &test_directory.join("foo"),
+ "HEAD",
+ &Status::Unclean,
+ None,
+ None,
+ )?,
+ Report::new(
+ &test_directory.join("bar"),
+ "HEAD",
+ &Status::Clean,
+ None,
+ None,
+ )?,
+ Report::new(
+ &test_directory.join("baz"),
+ "HEAD",
+ &Status::Clean,
+ None,
+ None,
+ )?,
];
reports.sort_by(|a, b| a.name.cmp(&b.name));
expected_reports.insert(Some(key), reports);
- let nested_test_dir = test_dir.join("nested");
+ let nested_test_dir = test_directory.join("nested");
let key = nested_test_dir
.to_str()
- .expect("could not convert to str")
+ .ok_or_else(|| anyhow!("could not convert PathBuf to &str"))?
.to_string();
let mut reports = vec![
Report::new(
@@ -161,32 +151,28 @@ mod tests {
&Status::Unclean,
None,
None,
- )
- .expect("could not create report"),
+ )?,
Report::new(
&nested_test_dir.join("two"),
"HEAD",
&Status::Clean,
Some("https://github.com/nickgerace/gfold".to_string()),
None,
- )
- .expect("could not create report"),
+ )?,
Report::new(
&nested_test_dir.join("three"),
"HEAD",
&Status::Clean,
Some("https://github.com/nickgerace/gfold".to_string()),
None,
- )
- .expect("could not create report"),
+ )?,
];
reports.sort_by(|a, b| a.name.cmp(&b.name));
expected_reports.insert(Some(key), reports);
// Use classic display mode to avoid collecting email results.
config.display_mode = DisplayMode::Classic;
- let found_labeled_reports = report::generate_reports(&config.path, &config.display_mode)
- .expect("could not generate reports");
+ let found_labeled_reports = report::generate_reports(&config.path, &config.display_mode)?;
let mut found_labeled_reports_sorted = LabeledReports::new();
for labeled_report in found_labeled_reports {
let mut value = labeled_report.1;
@@ -195,29 +181,48 @@ mod tests {
}
assert_eq!(found_labeled_reports_sorted, expected_reports);
+ Ok(())
+ }
+
+ /// Ensure we are underneath the repository root. Safely create the test directory.
+ fn integration_init() -> Result<PathBuf> {
+ let manifest_directory = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
+ let repo_root = manifest_directory
+ .parent()
+ .ok_or_else(|| anyhow!("could not get parent"))?
+ .parent()
+ .ok_or_else(|| anyhow!("could not get parent"))?;
+ assert!(Repository::open(repo_root).is_ok());
+
+ let target = repo_root.join("target");
+ create_directory(&target)?;
+ let test = target.join("test");
+ Ok(test)
}
- fn create_directory(path: &Path) {
+ fn create_directory(path: &Path) -> Result<()> {
if let Err(e) = fs::create_dir(path) {
if e.kind() != io::ErrorKind::AlreadyExists {
- panic!(
+ return Err(anyhow!(
"could not create directory ({:?}) due to error kind: {:?}",
path,
e.kind()
- );
+ ));
}
}
+ Ok(())
}
- fn create_file(path: &Path) {
+ fn create_file(path: &Path) -> Result<()> {
if let Err(e) = fs::File::create(path) {
if e.kind() != io::ErrorKind::AlreadyExists {
- panic!(
+ return Err(anyhow!(
"could not create file ({:?}) due to error kind: {:?}",
path,
e.kind()
- );
+ ));
}
}
+ Ok(())
}
}
diff --git a/crates/gfold/src/report.rs b/crates/gfold/src/report.rs
index 8e4a483..4d5c20c 100644
--- a/crates/gfold/src/report.rs
+++ b/crates/gfold/src/report.rs
@@ -21,7 +21,7 @@ const HEAD: &str = "HEAD";
pub type LabeledReports = BTreeMap<Option<String>, Vec<Report>>;
/// A collection of results for a Git repository at a given path.
-#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
+#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Report {
/// The directory name of the Git repository.
pub name: String,
diff --git a/crates/gfold/src/status.rs b/crates/gfold/src/status.rs
index 2301dc9..799ac8d 100644
--- a/crates/gfold/src/status.rs
+++ b/crates/gfold/src/status.rs
@@ -3,7 +3,7 @@
use serde::{Deserialize, Serialize};
/// A summarized interpretation of the status of a Git working tree.
-#[derive(Debug, Clone, Copy, Deserialize, Serialize, PartialEq)]
+#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum Status {
Bare,
Clean,
diff --git a/docs/CHANGELOG_PRE_V4.md b/docs/CHANGELOG_PRE_V4.md
new file mode 100644
index 0000000..f54b116
--- /dev/null
+++ b/docs/CHANGELOG_PRE_V4.md
@@ -0,0 +1,522 @@
+# Changelog Before Version 4.0.0
+
+For new changes, please see the current [CHANGELOG](../CHANGELOG.md).
+
+- All notable changes to this project will be documented in this file
+- All changes are from [@nickgerace](https://github.com/nickgerace) unless otherwise specified
+- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
+
+## [After 3.0.0]
+
+Please see [CHANGELOG](../CHANGELOG.md).
+
+## [3.0.0] - 2022-01-06
+
+### Added
+
+- Ability to ignore config file options
+- Ability to print merged config options
+- Ability to specify path to `git`
+- Ability to store default path target in config file (defaults to current working directory)
+- Ability to use config file in `$HOME/.config/gfold/gfold.json` and `{FOLDERID_Profile}\.config\gfold\gfold.json`
+- Ability to use old display mode with `--classic` flag and store preference in config file
+- Formal CLI parsing library, `argh`
+- Install and uninstall scripts
+- New display mode that avoids grouping repositories (API-breaking since this is the new default display mode)
+
+### Changed
+
+- Codebase to a domain-driven architecture (major refactor)
+
+### Removed
+
+- Mention of the [deprecated, old Homebrew tap](https://github.com/nickgerace/homebrew-gfold) in the README
+- Short `-h` flag due to CLI crate addition (`argh`)
+
+### Notes
+
+- Evaluated using `tracing` and `tracing-subscriber` over `log` and `env_logger`, but due to their combined larger size, the logging crates remain the same as before.
+- The config file can be non-existent, empty, partially filled out or completely filled out. There's also an option to ignore the config file completely and only use CLI options.
+- This crate has used other CLI parsing libraries in the past, and recently did not use any, but with manual testing and [publicly available benchmarks](https://github.com/rust-cli/argparse-benchmarks-rs/blob/c37e78aabdaa4384a9c49be3735a686803d0e37a/README.md#results), `argh` is now in use.
+
+## [2.0.2] - 2021-12-02
+
+### Changed
+
+- Misc package bumps
+
+## [2.0.1] - 2021-10-29
+
+### Added
+
+- Logger that can be set via an environment variable (`RUST_LOG`)
+
+### Changed
+
+- Permission denied errors to be logged rather than displayed to `stderr`
+
+### Misc
+
+- Ensure `crates.io` and `git` tag are in sync (very slight and accidental derivation for `2.0.0`)
+
+## [2.0.0] - 2021-10-29
+
+### Added
+
+- Discrete Code of Conduct file
+- Unpushed commit checking by default (greedy static analysis, so this may need to be tuned for edge cases)
+- `git` CLI wrapper instead of Git library usage due to security, Git already being installed, inconsistencies between the library and the CLI, and more
+
+### Changed
+
+- Codebase re-write geared towards data-efficiency and parallelism
+- Dramatic runtime speed and binary size improvements (consistently able to reproduce, but heavily variable based on payload, OS, etc.)
+- Entire structure from library-driven to application-driven (no `lib.rs`)
+
+### Removed
+
+- All CLI flags except for `-h/--help` and `-V/--version`
+- CLI crate since it is unneeded
+- Git library usage in favor of leveraging `git` subcommands due to security, Git already being installed, inconsistencies between the library and the CLI, and more
+- `DEVELOPING.md` and `EXTRA.md` since they were outdated/unimportant
+- `lib.rs` and the crate's library-based components
+
+## [1.4.1] - 2021-08-02
+
+### Changed
+
+- Misc package bumps
+
+## [1.4.0] - 2021-06-17
+
+### Changed
+
+- Continue upon PermissionDenied errors rather than exiting
+- Documentation to be moved to the new `docs` directory
+
+## [1.3.0] - 2021-05-25
+
+### Changed
+
+- Config type to be embedded within the Driver
+ - Not in public library modules, but this should improve generation efficiency
+
+### Removed
+
+- `-d/--debug` flag since all logging has been removed from the librariy, and `main.rs` does not log
+- `env_logger` crate
+- `log` crate
+- Logging from the entire library in favor of returning errors when needed and handling when possible/preferred
+
+## [1.2.1] - 2021-05-23
+
+### Changed
+
+- Bold table headers instead of repo names
+
+### Removed
+
+- Extra newline before first entry when printing all tables
+
+## [1.2.0] - 2021-05-16
+
+### Removed
+
+- Middleware `run` function in `lib.rs` since it's unecessary and unintuitive
+ - Before, you used a type from the `driver` module as a parameter for `run`
+ - Now, you only use types from `driver`
+
+## [1.1.1] - 2021-05-16
+
+### Changed
+
+- Config management to be done by applications consuming the library (moved out of `lib.rs`)
+- Driver module to be public
+- Printing to STDOUT to be done by applications consuming the library (moved out of `lib.rs`)
+- `TableWrapper` type to be a private, internal type
+
+## [1.1.0] - 2021-05-15
+
+### Added
+
+- Shallow search flag to disable recursive search (accessible via `-s/--shallow`)
+
+### Changed
+
+- Binary size to be ~60% of the size of `gfold 1.0.4`
+ - Primarily, this was achieved by removing unused default features from imported crates
+ - Runtime speed is the same, better, or more consistent
+- Default search behavior to be recursive rather than shallow
+- Short flag for `--skip-sort` from `-s` to `-x`
+- Workspace implementation to a single crate (similar to before `gfld`)
+
+### Removed
+
+- `gfld`, the lightweight version of `gfold` due the following reasons:
+ - its over ~105% average slower runtime speed (despite it being ~40% of the size)
+ - printing to STDOUT was not consistent in subcommand scenarios
+- Recursive flag since `gfold` uses recursive search by default
+
+## [1.0.4] - 2021-04-04
+
+### Changed
+
+- Fixed final output order (sorted by name, then by status)
+
+## [1.0.3] - 2021-04-02
+
+### Changed
+
+- Directory name finder to default to the current working directory if empty (`gfld`)
+- Misc. optimizations in `gfld`
+- Release profile optimizations to be at workspace scope for binaries
+
+## [1.0.2] - 2021-04-01
+
+### Changed
+
+- `gfld` output to not include parent root since all results started with the same string
+
+## [1.0.1] - 2021-03-30
+
+### Added
+
+- `Cargo.lock` to the workspace to fix AUR builds
+
+## Changed
+
+- CI to use `--locked` for builds
+
+## [1.0.0] - 2021-03-29
+
+### Added
+
+- A brand new, minimal CLI: `gfld`
+- `DEVELOPING.md` for instructions on building `gfld`
+
+### Changed
+
+- Documentation to include `gfld`
+- GitHub issue template to include `gfld` information
+- GitHub PR CI to only build for Linux while keeping macOS and Windows for release CI
+- The repository to be split into two crates: `gfold` and `gfld`
+- Unnecessary `PathBuf` usages to `Path` when possible in `util.rs`
+
+### Removed
+
+- Release workflow for GitHub actions (now, it is "merge only")
+- Uploaded binaries due to lack of checksums and maintenance
+
+## [0.9.1] - 2021-03-16
+
+### Added
+
+- RELEASE file for releasing `gfold`
+
+### Changed
+
+- README installation section to be condensed
+- LICENSE to not use copyright dates or name (reduce maintenance)
+
+### Removed
+
+- Makefile in order to be cross-platform-friendly
+
+## [0.9.0] - 2021-02-15
+
+### Added
+
+- Email display feature
+- Include standard directory feature
+- Shorthand flag for all features without one
+
+### Changed
+
+- Directory walking to skip hidden directories
+- Repository opening check to log error in debug mode rather than panic
+
+### Removed
+
+- File header comments
+- Prettytable macros
+
+## [0.8.4] - 2021-01-26
+
+### Added
+
+- Dependencies section to CHANGELOG
+- `paru` to suggested AUR helpers in README
+
+### Changed
+
+- All CRLF files to LF
+- Condense tests into loops where possible
+- Label `unpush_check` as an experimental feature
+- `macos-amd64` to `darwin-amd64`
+- `unpush_check` from `disable` to `enable`
+
+## [0.8.3] - 2020-12-15
+
+### Added
+
+- Disable unpushed commit check flag and functionality
+- Logging for origin and local reference names for unpushed commit check
+
+## [0.8.2] - 2020-12-14
+
+### Added
+
+- `gfold --version` to issue template
+- Unpush functionality (again)
+
+### Changed
+
+- Unpush function to only return boolean
+
+### Removed
+
+- Contributing section from README to reduce requirements
+- Empty results message since it was potentially misleading
+
+## [0.8.1] - 2020-12-01
+
+### Added
+
+- Condition enum for adding rows to final table
+- Debug flag
+- Many debug statements for the new debug flag
+
+### Changed
+
+- Bare repository checking to original behavior
+- `util.rs` results generation to include Condition enum
+
+### Removed
+
+- Carets from `Cargo.toml` to maintain stability
+- Unpush functionality temporarily
+
+## [0.8.0] - 2020-11-26
+
+### Added
+
+- Debugging calls for general usage and the new unpushed commit code
+- Derive debug to the `Config` struct
+- Lightweight logging stack with `env_logger` and `log`
+- Two files: `driver.rs` and `util.rs`
+- Unpushed commit status functionality and output
+
+### Changed
+
+- Bare repository detection to use upstream function
+- Library contents into `driver.rs` and `util.rs` through a major refactor
+
+## [0.7.1] - 2020-11-18
+
+### Added
+
+- In-depth description of the `run` function
+
+### Changed
+
+- Consolidated boolean test permutations into one test
+
+### Removed
+
+- All non-public comments in `*.rs` files
+
+## [0.7.0] - 2020-11-11
+
+### Added
+
+- Crate to crates.io
+- Crates.io publishing requirements to `[package]` in `Cargo.toml`
+- Homebrew tap
+- Library description to `lib.rs`
+
+### Changed
+
+- Dependency versioning to use carets
+- README mentions of specific version tags
+- README plaintext blocks to single quotes when mixed with formatted text
+- README to sort installation method by package managers first
+
+### Removed
+
+- Public structs and functions without only `run` (primary backend driver) remaining
+
+## [0.6.2] - 2020-11-03
+
+### Added
+
+- No color flag and functionality
+
+### Removed
+
+- Pull request template
+
+## [0.6.1] - 2020-10-12
+
+### Added
+
+- Code of Conduct link
+- GitHub issue template
+- GitHub pull request template
+
+### Changed
+
+- LICENSE to be extended through 2021
+- Match blocks in `lib.rs` to be consolidated
+- Nearly all contents of `lib.rs` to return errors back to the calling function in `main.rs`
+
+### Removed
+
+- Duplicate code related to the match block consolidation
+
+## [0.6.0] - 2020-10-10
+
+### Added
+
+- Doc comments and `cargo doc` to `release` target
+- `eyre` for simple backtrace reporting
+- `gfold-bin` to AUR portion of README
+- `lib.rs` as part of major refactor
+
+### Changed
+
+- Pre-build Makefile targets to be consolidated
+- Refactor source code to be driven by a library, helmed by `lib.rs`
+
+### Removed
+
+- `util.rs` and `gfold.rs` as part of major refactor
+
+## [0.5.2] - 2020-10-08
+
+### Added
+
+- GitHub release downloads to README
+- Binary publishing workflow to the dummy file
+
+### Changed
+
+- Existing merge workflow to use debug building instead of release building
+- Makefile target containing the old default branch name
+
+### Removed
+
+- Makefile target for statically-linked building
+
+## [0.5.1] - 2020-10-07
+
+### Added
+
+- Release dummy GitHub Action
+- Version README badge
+
+### Changed
+
+- A reduction to CI build time and complexity by combining the test and check steps,
+- GitHub workflow "merge" file name to "merge.yml"
+- GitHub workflow name to "merge"
+- OS compatibility claims in README through a simplified list
+- README badges to use shields.io
+
+### Removed
+
+- MUSL mentions in docs
+
+## [0.5.0] - 2020-09-02
+
+### Added
+
+- Recursive search feature and flag
+- Skip sort feature and flag
+- Unit tests for recursive search and skip sort
+- AUR PKGBUILD GitHub repository to README
+- Results and TableWrapper structs, and relevant functions,
+- Three methods for Results struct (printing/sorting/populating results)
+- Make targets for `run-recursive` and `install-local`
+
+### Changed
+
+- Switch from `walk_dir` function to object-driven harness for execution
+- Move `walk_dir` function logic to `Results` method
+- Function `is_git_repo` to its own file
+- Any unnecessary match block to use "expect" instead
+- Cargo install to use a specific tag
+- Version upgrade workflow to Makefile
+
+### Removed
+
+- Leftover "FIXME" comments for recursive search ideas
+
+## [0.4.0] - 2020-08-31
+
+### Added
+
+- Changelog
+- Tags automation
+
+### Changed
+
+- Example output to use mythical repositories
+- Path flag to positional argument
+- Switched to structopt library for CLI parsing
+
+### Removed
+
+- Tag v0.3.0 (duplicate of 0.3.0 with the "v" character)
+- All GitHub releases before 0.3.1
+- Releases information from README
+
+## [0.3.1] - 2020-08-30
+
+### Added
+
+- Add AUR installation documentation
+- Add AUR packages from [@orhun](https://github.com/orhun)
+
+### Changed
+
+- Switch to Apache 2.0 license from MIT license
+- Reorganize build tags, and add test build target
+
+## [0.3.0] - 2020-08-24
+
+### Changed
+
+- Handling for bare repositories to print their status to STDOUT with the mentorship of [@yaahc](https://github.com/yaahc)
+
+## [0.2.2] - 2020-08-24
+
+### Changed
+
+- "Continue" to the next repository object if the current object is bare
+- Release availability in README
+
+## [0.2.1] - 2020-06-08
+
+### Added
+
+- Experimental statically-linked, MUSL support
+
+## [0.2.0] - 2020-05-10
+
+### Changed
+
+- Switched to prettytable-rs
+- Unit tests to work with prettytable-rs
+
+## [0.1.1] - 2020-04-10
+
+### Added
+
+- Example output, contributors, and usage in README
+- Building for Windows, macOS, and Linux amd64 in CI pipeline from [@jrcichra](https://github.com/jrcichra)
+
+## [0.1.0] - 2020-04-08
+
+### Added
+
+- Base contents
diff --git a/docs/RELEASE.md b/docs/RELEASE.md
index 7d177c5..d18cd14 100644
--- a/docs/RELEASE.md
+++ b/docs/RELEASE.md
@@ -16,7 +16,7 @@ Steps should be executed in sequential order.
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo test
-cargo doc
+RUSTDOCFLAGS="-Dwarnings" cargo doc --all
cargo build
```