diff options
author | Nick <nickagerace@gmail.com> | 2021-03-29 21:38:07 -0400 |
---|---|---|
committer | Nick Gerace <nickagerace@gmail.com> | 2021-03-29 21:38:45 -0400 |
commit | 78f13f391fd6c5e4b6093f6dde9315e0d692d8e1 (patch) | |
tree | f28d73615ac864f7cc9ed6da8494688d0587286c | |
parent | 4d98f4ddcbdf5995debc71703e221130a303cb0a (diff) | |
download | gfold-78f13f391fd6c5e4b6093f6dde9315e0d692d8e1.zip |
Add gfld
Add gfld. Consult CHANGELOG.md for more information.
-rw-r--r-- | .github/ISSUE_TEMPLATE/issue.md | 7 | ||||
-rw-r--r-- | .github/workflows/merge.yml | 23 | ||||
-rw-r--r-- | .github/workflows/release.yml | 2 | ||||
-rw-r--r-- | .gitignore | 23 | ||||
-rw-r--r-- | CHANGELOG.md | 15 | ||||
-rw-r--r-- | Cargo.lock | 45 | ||||
-rw-r--r-- | Cargo.toml | 22 | ||||
-rw-r--r-- | DEVELOPING.md | 16 | ||||
-rw-r--r-- | README.md | 136 | ||||
-rw-r--r-- | RELEASE.md | 24 | ||||
-rw-r--r-- | gfld/Cargo.lock | 233 | ||||
-rw-r--r-- | gfld/Cargo.toml | 24 | ||||
-rw-r--r-- | gfld/src/lib.rs | 137 | ||||
-rw-r--r-- | gfld/src/main.rs | 32 | ||||
-rw-r--r-- | gfold/Cargo.lock | 723 | ||||
-rw-r--r-- | gfold/Cargo.toml | 20 | ||||
-rw-r--r-- | gfold/src/driver.rs (renamed from src/driver.rs) | 0 | ||||
-rw-r--r-- | gfold/src/lib.rs (renamed from src/lib.rs) | 0 | ||||
-rw-r--r-- | gfold/src/main.rs (renamed from src/main.rs) | 0 | ||||
-rw-r--r-- | gfold/src/util.rs (renamed from src/util.rs) | 6 |
20 files changed, 1362 insertions, 126 deletions
diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md index 1d00a2f..4e31db3 100644 --- a/.github/ISSUE_TEMPLATE/issue.md +++ b/.github/ISSUE_TEMPLATE/issue.md @@ -9,14 +9,17 @@ assignees: nickgerace ### Describe the issue. <!--answer-here--> +### Is this about `gfold`, `gfld`, or both? +<!--answer-here--> + ### Is this a bug report, feature request, or another type of issue? <!--answer-here--> ### Are you using Windows, macOS, Linux, or another OS? <!--answer-here--> -### Are you using a pre-built binary? If not, how did you obtain `gfold`? +### How did you obtain the application? <!--answer-here--> -### Paste the output of `gfold --version`. +### Paste the output of the relevant application(s) with `-h`. <!--answer-here--> diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 7c0bded..8af382a 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -1,8 +1,8 @@ on: [push] name: merge jobs: - pre-build: - name: Pre-Build + build: + name: Build runs-on: ubuntu-latest steps: - name: Checkout sources @@ -14,10 +14,6 @@ jobs: toolchain: stable override: true components: rustfmt, clippy - - name: cargo check - uses: actions-rs/cargo@v1 - with: - command: check - name: cargo fmt uses: actions-rs/cargo@v1 with: @@ -32,21 +28,6 @@ jobs: uses: actions-rs/cargo@v1 with: command: test - build: - name: Build - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest,windows-latest,macos-latest] - steps: - - name: Checkout sources - uses: actions/checkout@v2 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - name: Run cargo build uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2fc4bdb..6d9c586 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,6 +26,6 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/release/${{ matrix.artifact_name }} + file: gfold/target/release/${{ matrix.artifact_name }} asset_name: ${{ matrix.asset_name }} tag: ${{ github.ref }} @@ -1,19 +1,10 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ - -# These are backup files generated by rustfmt +# Ignore for the entire repository. +**/target/ **/*.rs.bk - -# Added by cargo -/target - -# Visual studio -.vs/* -.vscode/* - -# macOS +**/.vs/* +**/.vscode/* **/.DS_Store +**/.idea/ -# IDEs -.idea/ +# Only ignore for the workspace; keep for the sub-crates. +Cargo.lock diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a6b52b..93ce9d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased] -The latest version contains all changes. +<!-- The latest version contains all changes. --> + +### 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` ## [0.9.1] - 2021-03-16 @@ -219,6 +219,15 @@ dependencies = [ ] [[package]] +name = "gfld" +version = "0.1.0" +dependencies = [ + "git2", + "log", + "walkdir", +] + +[[package]] name = "gfold" version = "0.9.1" dependencies = [ @@ -309,9 +318,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.89" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" [[package]] name = "libgit2-sys" @@ -529,10 +538,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" [[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 = "serde" -version = "1.0.124" +version = "1.0.125" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" +checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171" [[package]] name = "strsim" @@ -566,9 +584,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.64" +version = "1.0.67" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" dependencies = [ "proc-macro2", "quote", @@ -681,9 +699,20 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" [[package]] name = "version_check" -version = "0.9.2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "walkdir" +version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] [[package]] name = "wasi" @@ -1,20 +1,2 @@ -[package] -name = "gfold" -version = "0.9.1" -license = "Apache-2.0" -authors = ["Nick Gerace <nickagerace@gmail.com>"] -description = "CLI tool to help keep track of your Git repositories." -homepage = "https://nickgerace.dev" -repository = "https://github.com/nickgerace/gfold/" -readme = "README.md" -edition = "2018" -keywords = ["git", "cli"] -categories = ["command-line-utilities", "command-line-interface"] - -[dependencies] -env_logger = "0.8" -eyre = "0.6" -git2 = "0.13" -log = "0.4" -prettytable-rs = "0.8" -structopt = "0.3" +[workspace] +members = ["gfold", "gfld"]
\ No newline at end of file diff --git a/DEVELOPING.md b/DEVELOPING.md new file mode 100644 index 0000000..1dfef55 --- /dev/null +++ b/DEVELOPING.md @@ -0,0 +1,16 @@ +# Developing + +This document contains all tips, tricks and notes related to developing `gfold` and `gfld`. + +## Building `gfld` + +Since `gfld` is the minimal version of `gfold`, we need to slim it down for general testing and usage. +On a compatible platform, execute the following commands: + +```sh +cargo fmt +cargo clippy +cargo build --release +strip target/release/gfld +du -h target/release/gfld | cut -f -1 +```
\ No newline at end of file @@ -5,9 +5,9 @@ [![Crates.io](https://img.shields.io/crates/v/gfold?style=flat-square)](https://crates.io/crates/gfold) [![Build Status](https://img.shields.io/github/workflow/status/nickgerace/gfold/merge/main?style=flat-square)](https://github.com/nickgerace/gfold/actions?query=workflow%3Amerge+branch%3Amain) -`gfold` is a CLI application that helps you keep track of multiple Git repositories. +`gfold` is a CLI-driven application that helps you keep track of multiple Git repositories. -```bash +```sh user at hostname in ~/git % gfold great-journey unclean main git@github.com:truth/great-journey.git @@ -27,68 +27,99 @@ It prints each repository in alphabetical order, and pads each result based on t By default, `gfold` looks at every Git repository in the current working directory. However, if you would like to target another directory, you can pass that path (relative or absolute) as the first argument. +## Should I use `gfold` or `gfld`? + +[![Crates.io](https://img.shields.io/crates/v/gfld?style=flat-square)](https://crates.io/crates/gfld) + +`gfld` is the new, minimal version of `gfold`. +It contains only one configurable option (an optional, single command-line argument for the target path) and is much smaller than the original application in size. + +It is intended for fans of the original application who want a near-configurationaless usability and a smaller footprint on their systems. +It does *not* promise faster runtime performance, but it delivers on the two former goals. + +There are two major behavioral differences from the original application: only recursive search is available (similar to `gfold -r`), and all results are combined into one table (inspired by `kubectl get pods -A`). + ## Installation -You can use **[macOS Homebrew](https://brew.sh)** or **[Linuxbrew](https://docs.brew.sh/Homebrew-on-Linux)** to install the [tap](https://github.com/nickgerace/homebrew-gfold). +This repository contains two applications: `gfold`, the primary, fully-featured version, and `gfld`, the minimal version. +There is only one recommended method for installing the latter, and the original version has multiple methods for installation. +Thus, this section starts with the minimal version. + +### Installing `gfld` + +Currently, the only recommended method to install `gfld` is by using **[cargo](https://crates.io)** to install the [crate](https://crates.io/crates/gfld). +Fortunately, the minimal application should work on nearly every major platform. + +```sh +cargo install gfld +``` + +After installation, you can make the binary even smaller. +The following commands were tested on Linux and macOS systems: + +```sh +strip path/to/gfld +du -h path/to/gfld | cut -f -1 +``` + +If you do not know where `gfld` was installed, you can use `which gfld` on compatible platforms or check your `cargo install` settings. + +> Keeping the crate up to date is easy with [cargo-update](https://crates.io/crates/cargo-update). +> +> ```sh +> cargo install cargo-update +> cargo install-update -a +> ``` + +### Installing `gfold` -```bash +**You can use [macOS Homebrew](https://brew.sh) or [Linuxbrew](https://docs.brew.sh/Homebrew-on-Linux)** to install the [tap](https://github.com/nickgerace/homebrew-gfold). + +```sh brew install nickgerace/gfold/gfold ``` -If using a **Linux distribution that supports installing packages from the AUR**, you can install from three packages: [gfold](https://aur.archlinux.org/packages/gfold/) (builds from source), [gfold-bin](https://aur.archlinux.org/packages/gfold-bin/) (uses the GitHub release binary), and [gfold-git](https://aur.archlinux.org/packages/gfold-git/) (VCS/development package). +**You can use a Linux distribution that supports installing packages from the AUR** to install: [gfold](https://aur.archlinux.org/packages/gfold/) (builds from source), [gfold-bin](https://aur.archlinux.org/packages/gfold-bin/) (uses the GitHub release binary), and/or [gfold-git](https://aur.archlinux.org/packages/gfold-git/) (VCS/development package). Many people choose to use an [AUR helper](https://wiki.archlinux.org/index.php/AUR_helpers), such as [yay](https://github.com/Jguer/yay) or [paru](https://github.com/Morganamilo/paru), in order to install their AUR packages. -```bash +```sh yay -S gfold paru -S gfold ``` -You can install the [crate](https://crates.io/crates/gfold) on any platform with **[cargo](https://crates.io)**. - -```bash -cargo install gfold -``` - -Keeping the crate up to date is easy with [cargo-update](https://crates.io/crates/cargo-update). +**You can use [cargo](https://crates.io)** to install the [crate](https://crates.io/crates/gfold) on almost any platform. +Consult the `gfld` section above on how to keep the crate up to date with `cargo-update`. ```sh -cargo install cargo-update -cargo install-update -a +cargo install gfold ``` -You can obtain `gfold` via the **[latest GitHub release](https://github.com/nickgerace/gfold/releases/latest)**. +**You can obtain `gfold` via the [latest GitHub release](https://github.com/nickgerace/gfold/releases/latest)**. Once you have it downloaded, you can add it to your `PATH`. You may have to reload your shell in order to see `gfold` in your `PATH`. -```bash +```sh chmod +x gfold mv gfold /usr/local/bin/ ``` -You can use symbolic links to swap between versions, and manage multiple at a time. -With this workflow, you can add/remove versions of the binary from `/usr/local/gfold/`, and change the symbolic link as needed. - -```bash -wget https://github.com/nickgerace/gfold/releases/download/$VERSION/gfold-$PLATFORM -mv gfold-$PLATFORM gfold-$VERSION -chmod +x gfold-$VERSION - -mkdir /usr/local/gfold/ -mv gfold-$VERSION /usr/local/gfold/ -ln -s /usr/local/gfold/gfold-$VERSION /usr/local/bin/gfold -``` +> You can use symbolic links to swap between versions, and manage multiple at a time. +> With this workflow, you can add/remove versions of the binary from `/usr/local/gfold/`, and change the symbolic link as needed. +> +> ```sh +> wget https://github.com/nickgerace/gfold/releases/download/$VERSION/gfold-$PLATFORM +> mv gfold-$PLATFORM gfold-$VERSION +> chmod +x gfold-$VERSION +> mkdir /usr/local/gfold/ +> mv gfold-$VERSION /usr/local/gfold/ +> ln -s /usr/local/gfold/gfold-$VERSION /usr/local/bin/gfold +> ``` ## Usage -For all the ways on how to use this application, pass in the `-h`, or `--help`, flag. +For `gfold`: pass in the `-h`, or `--help`, flag to see all the options for using this application. -```bash -gfold --help -``` - -Here are some example invocations... - -```bash +```sh gfold gfold .. gfold $HOME @@ -98,19 +129,28 @@ gfold ~/path/to/multiple/repositories/ -r gfold -r $HOME/path/to/multiple/repositories ``` -## Compatibility +For `gfld`: you can pass in the `-h`, or `--help` too. +However, there is only one method of configuration: an optional, single command-line argument for the target path. +This is a result of the minimal application's design. -`gfold`, and its external crates, support all three major desktop platforms. -It is tested for the latest versions of the following systems, but may work on more... +```sh +gfld +gfld .. +gfld $HOME +gfld /this/is/an/absolute/path +gfld ../../this/is/a/relative/path +``` + +## Compatibility -- **Linux**: `linux-gnu-amd64` -- **macOS**: `darwin-amd64` -- **Windows 10**: `windows-amd64` +Both applications are intended to be ran on *any* tier one Rust target. +Please [file an issue](https://github.com/nickgerace/gfold/issues) if your platform is unsupported. -## Changelog +## Other Documentation -Please check out [CHANGELOG.md](./CHANGELOG.md) for more information. -It follows the [Keep a Changelog](https://keepachangelog.com/) format. +- **[CHANGELOG.md](./CHANGELOG.md):** follows the [Keep a Changelog](https://keepachangelog.com/) format +- **[DEVELOPING.md](./DEVELOPING.md):** developer tips, tricks, and notes +- **[RELEASE.md](./RELEASE.md):** release process notes ## Code of Conduct @@ -124,5 +164,5 @@ This repository follows and enforces the Rust programming language's [Code of Co ## Special Thanks To... - [@jrcichra](https://github.com/jrcichra) for adding multi-OS support to the original CI pipeline -- [@orhun](https://github.com/orhun) for maintaining [all three AUR packages](https://github.com/orhun/PKGBUILDs) -- [@yaahc](https://github.com/yaahc) for mentoring +- [@orhun](https://github.com/orhun) for maintaining [all three AUR packages](https://github.com/orhun/PKGBUILDs) for `gfold` +- [@yaahc](https://github.com/yaahc) for mentoring during an early refactor @@ -1,14 +1,17 @@ # Release This document contains all information related to release. +Currently, both `gfold` and `gfld` share the same semver, which is not ideal, but practical for keeping both projects in one repository. ## Preparation -1. Change the version in `Cargo.toml` to the `<new-tag>`. +Run each step in both subcrates. + +1. Change the version in `Cargo.toml` to the `<new-tag>` for both `gfold` and `gfld`. 1. Run the commands below this list and verify that everything looks/works as expected. 1. Change the version in `CHANGELOG.md` and uncomment the line, `<!--The latest version contains all changes.-->`. 1. Create a commit with the following message: `Update to <new-tag>`. Do not push (or merge) the commit. -1. Test the publishing workflow: `cargo publish --dry-run`. +1. Test the publishing workflow within each crate: `cargo publish --dry-run`. 1. Push (or merge) the preparation commit. ```sh @@ -27,16 +30,25 @@ Once the prepation commit has been pushed (or merged) into `main`, execute the f ```sh git tag <new-tag> git push --tags origin main -cargo publish ``` -Check [crates.io and docs.rs](https://crates.io/crates/gfold) afterwards. +Now, publish each crate. + +```sh +( cd gfold; cargo publish ) +( cd gfld; cargo publish ) +``` + +Check `crates.io` and `docs.rs` afterwards: + +- [gfold crate](https://crates.io/crates/gfold) +- [gfld crate](https://crates.io/crates/gfld) -## Updating the Tap +## Updating the Tap (`gfold` only) Update the formula for the [tap](https://github.com/nickgerace/homebrew-gfold). -## Edit the Release +## Edit the Release (`gfold` only) Check the release description and edit as necessary. diff --git a/gfld/Cargo.lock b/gfld/Cargo.lock new file mode 100644 index 0000000..c5631ce --- /dev/null +++ b/gfld/Cargo.lock @@ -0,0 +1,233 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "gfld" +version = "0.1.0" +dependencies = [ + "git2", + "log", + "walkdir", +] + +[[package]] +name = "git2" +version = "0.13.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "url", +] + +[[package]] +name = "idna" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +dependencies = [ + "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 = "libc" +version = "0.2.91" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8916b1f6ca17130ec6568feccee27c156ad12037880833a3b842a823236502e7" + +[[package]] +name = "libgit2-sys" +version = "0.12.18+1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885" +dependencies = [ + "cc", + "libc", + "libz-sys", + "pkg-config", +] + +[[package]] +name = "libz-sys" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[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 = "tinyvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "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", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" + +[[package]] +name = "walkdir" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" +dependencies = [ + "same-file", + "winapi", + "winapi-util", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/gfld/Cargo.toml b/gfld/Cargo.toml new file mode 100644 index 0000000..0e46a9c --- /dev/null +++ b/gfld/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "gfld" +version = "0.1.0" +license = "Apache-2.0" +authors = ["Nick Gerace <nickagerace@gmail.com>"] +description = "The minimal version of gfold, a CLI tool to help keep track of your Git repositories." +homepage = "https://nickgerace.dev" +repository = "https://github.com/nickgerace/gfold/" +readme = "README.md" +edition = "2018" +keywords = ["git", "cli"] +categories = ["command-line-utilities", "command-line-interface"] + +# This release optimizations minimally impact runtime performance and minimize executable size. +[profile.release] +panic = 'abort' +codegen-units = 1 +lto = true +opt-level = 'z' + +[dependencies] +git2 = { version = "^0.13", default-features = false } +log = { version = "^0.4", default-features = false } +walkdir = { version = "^2", default-features = false }
\ No newline at end of file diff --git a/gfld/src/lib.rs b/gfld/src/lib.rs new file mode 100644 index 0000000..95ad165 --- /dev/null +++ b/gfld/src/lib.rs @@ -0,0 +1,137 @@ +//! This is the minimal version of `gfold`, a CLI tool to help keep track of your Git repositories. + +use std::error::Error; +use std::path::{Path, PathBuf}; + +use git2::{ErrorClass, ErrorCode, Repository, StatusOptions}; +use log::debug; +use walkdir::WalkDir; + +#[derive(Debug, Eq, PartialEq, Ord, PartialOrd)] +struct Outcome { + name: String, + status: String, + branch: String, + source: String, +} + +/// This function is the primary driver for `gfld`. +pub fn run(path: &Path) -> Result<(), Box<dyn Error>> { + let mut vec = Vec::new(); + let shorthand = PathBuf::from(path.file_name().ok_or("Path terminates in '..'")?); + let mut max_name: usize = 0; + let mut max_status: usize = 0; + let mut max_branch: usize = 0; + let mut max_source: usize = 0; + + // Ensure that the directory is neither hidden nor is its parent a git repository. + for item in WalkDir::new(path) + .into_iter() + .filter_entry(|e| { + !e.file_name() + .to_str() + .map(|s| s.starts_with('.')) + .unwrap_or(false) + && match e.path().parent() { + Some(s) => Repository::open(s).is_err(), + None => false, + } + }) + .filter_map(|e| e.ok()) + { + let entry = item.into_path(); + let path = path.to_path_buf(); + if let Ok(repository) = Repository::open(&entry) { + let origin = match repository.find_remote("origin") { + Ok(o) => o, + Err(e) => { + debug!("{}", e); + continue; + } + }; + let source = origin.url().unwrap_or("none"); + + let head = match repository.head() { + Ok(o) => o, + Err(e) => { + debug!("{}", e); + continue; + } + }; + let branch = head.shorthand().unwrap_or("none"); + + let mut opts = StatusOptions::new(); + let status = match repository.statuses(Some(&mut opts)) { + Ok(statuses) if statuses.is_empty() => "clean", + Ok(_) => "unclean", + Err(error) + if error.code() == ErrorCode::BareRepo + && error.class() == ErrorClass::Repository => + { + "bare" + } + Err(_) => "error", + }; + + let child = match entry.strip_prefix(&path) { + Ok(o) => o, + Err(e) => { + debug!("{}", e); + continue; + } + }; + let name = shorthand.join(&child); + let name = name.to_str().unwrap_or("none"); + + if name.len() > max_name { + max_name = name.len(); + } + if status.len() > max_status { + max_status = status.len(); + } + if branch.len() > max_branch { + max_branch = branch.len(); + } + if source.len() > max_source { + max_source = source.len(); + } + + vec.push(Outcome { + name: name.to_string(), + status: status.to_string(), + branch: branch.to_string(), + source: source.to_string(), + }); + } + } + + // Imperceptible time savings without this sort. + vec.sort_unstable(); + + // Need to insert after the sort is finished. + vec.insert( + 0, + Outcome { + name: String::from("NAME"), + status: String::from("STATUS"), + branch: String::from("BRANCH"), + source: String::from("SOURCE"), + }, + ); + + // Despite using "println!" N times, this loop has minimal impact on runtime performance. + for outcome in vec { + println!( + "{:<width_name$} {:<width_status$} {:<width_branch$} {:<width_source$}", + outcome.name, + outcome.status, + outcome.branch, + outcome.source, + width_name = max_name, + width_status = max_status, + width_branch = max_branch, + width_source = max_source + ); + } + Ok(()) +} diff --git a/gfld/src/main.rs b/gfld/src/main.rs new file mode 100644 index 0000000..e7911e4 --- /dev/null +++ b/gfld/src/main.rs @@ -0,0 +1,32 @@ +use std::env; +use std::error::Error; +use std::path::PathBuf; + +fn main() -> Result<(), Box<dyn Error>> { + let args: Vec<String> = env::args().collect(); + let mut path = env::current_dir()?; + match args.len() { + args_length if args_length < 2 => launch(path)?, + _ if args[1].as_str() == "-h" || args[1].as_str() == "--help" => println!( + "gfld {} +https://github.com/nickgerace/gfld + +Lists the status of all Git projects in a directory recursively. +Uses the current working directory by default, and can use a path as the first argument. + +USAGE: + gfld [path/-h/--help]", + option_env!("CARGO_PKG_VERSION").unwrap_or("v?") + ), + _ => { + path.push(args[1].clone()); + launch(path)?; + } + } + Ok(()) +} + +fn launch(path: PathBuf) -> Result<(), Box<dyn Error>> { + gfld::run(&path.canonicalize()?)?; + Ok(()) +} diff --git a/gfold/Cargo.lock b/gfold/Cargo.lock new file mode 100644 index 0000000..c43e759 --- /dev/null +++ b/gfold/Cargo.lock @@ -0,0 +1,723 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7404febffaa47dac81aa44dba71523c9d069b1bdc50a77db41195149e17f68e5" +dependencies = [ + "memchr", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi", +] + +[[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.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "base64" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" + +[[package]] +name = "bitflags" +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 = "bstr" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a40b47ad93e1a5404e6c18dec46b628214fee441c70f4ab5d6942142cc268a3d" +dependencies = [ + "lazy_static", + "memchr", + "regex-automata", + "serde", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "cc" +version = "1.0.67" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c69b077ad434294d3ce9f1f6143a2a4b89a8a2d54ef813d85003a4fd1137fd" +dependencies = [ + "jobserver", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +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.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9d99fa91428effe99c5c6d4634cdeba32b8cf784fc428a2a687f61a952c49" +dependencies = [ + "autocfg", + "cfg-if", + "lazy_static", +] + +[[package]] +name = "csv" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22813a6dc45b335f9bade10bf7271dc477e81113e89eb251a0bc2a8a81c536e1" +dependencies = [ + "bstr", + "csv-core", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "csv-core" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" +dependencies = [ + "memchr", +] + +[[package]] +name = "dirs" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "encode_unicode" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" + +[[package]] +name = "env_logger" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17392a012ea30ef05a610aa97dfb49496e71c9f676b27879922ea5bdf60d9d3f" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "eyre" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "221239d1d5ea86bf5d6f91c9d6bc3646ffe471b08ff9b0f91c44f115ac969d2b" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "form_urlencoded" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" +dependencies = [ + "matches", + "percent-encoding", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gfold" +version = "0.9.1" +dependencies = [ + "env_logger", + "eyre", + "git2", + "log", + "prettytable-rs", + "structopt", +] + +[[package]] +name = "git2" +version = "0.13.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986" +dependencies = [ + "bitflags", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + +[[package]] +name = "heck" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + +[[package]] +name = "idna" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89829a5d69c23d348314a7ac337fe39173b61149a9864deabd260983aed48c21" +dependencies = [ + "matches", + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "itoa" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" + +[[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.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "538c092e5586f4cdd7dd8078c4a79220e3e168880218124dcbce860f0ea938c6" + +[[package]] +name = "libgit2-sys" +version = "0.12.18+1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + +[[package]] +name = "libssh2-sys" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0186af0d8f171ae6b9c4c90ec51898bad5d08a2d5e470903a50d9ad8959cbee" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "602113192b08db8f38796c4e85c39e960c145965140e918018bcde1952429655" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "matches" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "once_cell" +version = "1.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3" + +[[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.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "313752393519e876837e09e1fa183ddef0be7735868dced3196f4472d536277f" +dependencies = [ + "autocfg", + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "prettytable-rs" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fd04b170004fa2daccf418a7f8253aaf033c27760b5f225889024cf66d7ac2e" +dependencies = [ + "atty", + "csv", + "encode_unicode", + "lazy_static", + "term", + "unicode-width", +] + +[[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.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" +dependencies = [ + "proc-macro2", +] + +[[package]] +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 = [ + "getrandom", + "redox_syscall", + "rust-argon2", +] + +[[package]] +name = "regex" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "957056ecddbeba1b26965114e191d2e8589ce74db242b6ea25fc4062427a5c19" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae1ded71d66a4a97f5e961fd0cb25a5f366a42a41570d16a763a69c092c26ae4" +dependencies = [ + "byteorder", +] + +[[package]] +name = "regex-syntax" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5f089152e60f62d28b835fbff2cd2e8dc0baf1ac13343bef92ab7eed84548" + +[[package]] +name = "rust-argon2" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" +dependencies = [ + "base64", + "blake2b_simd", + "constant_time_eq", + "crossbeam-utils", +] + +[[package]] +name = "ryu" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" + +[[package]] +name = "serde" +version = "1.0.124" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd761ff957cb2a45fbb9ab3da6512de9de55872866160b23c25f1a841e99d29f" + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "structopt" +version = "0.3.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5277acd7ee46e63e5168a80734c9f6ee81b1367a7d8772a2d765df2a3705d28c" +dependencies = [ + "clap", + "lazy_static", + "structopt-derive", +] + +[[package]] +name = "structopt-derive" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ba9cdfda491b814720b6b06e0cac513d922fc407582032e8706e9f137976f90" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "term" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" +dependencies = [ + "byteorder", + "dirs", + "winapi", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "tinyvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023" +dependencies = [ + "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", +] + +[[package]] +name = "unicode-normalization" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07fbfce1c8a97d547e8b5334978438d9d6ec8c20e38f56d4a4374d181493eaef" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb0d2e7be6ae3a5fa87eed5fb451aff96f2573d2694942e40543ae0bbe19c796" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "url" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ccd964113622c8e9322cfac19eb1004a07e636c545f325da085d5cdde6f1f8b" +dependencies = [ + "form_urlencoded", + "idna", + "matches", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[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.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/gfold/Cargo.toml b/gfold/Cargo.toml new file mode 100644 index 0000000..8038b59 --- /dev/null +++ b/gfold/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "gfold" +version = "0.9.1" +license = "Apache-2.0" +authors = ["Nick Gerace <nickagerace@gmail.com>"] +description = "CLI tool to help keep track of your Git repositories." +homepage = "https://nickgerace.dev" +repository = "https://github.com/nickgerace/gfold/" +readme = "README.md" +edition = "2018" +keywords = ["git", "cli"] +categories = ["command-line-utilities", "command-line-interface"] + +[dependencies] +env_logger = "0.8" +eyre = "0.6" +git2 = "0.13" +log = "0.4" +prettytable-rs = "0.8" +structopt = "0.3" diff --git a/src/driver.rs b/gfold/src/driver.rs index b113921..b113921 100644 --- a/src/driver.rs +++ b/gfold/src/driver.rs diff --git a/src/lib.rs b/gfold/src/lib.rs index f94592f..f94592f 100644 --- a/src/lib.rs +++ b/gfold/src/lib.rs diff --git a/src/main.rs b/gfold/src/main.rs index 59df5cc..59df5cc 100644 --- a/src/main.rs +++ b/gfold/src/main.rs diff --git a/src/util.rs b/gfold/src/util.rs index 0d16a3c..7364c89 100644 --- a/src/util.rs +++ b/gfold/src/util.rs @@ -131,8 +131,8 @@ pub fn create_table_from_paths( } } -pub fn get_short_name_for_directory(child: &PathBuf, parent: &Path) -> String { - let temp_dir = child.clone(); +pub fn get_short_name_for_directory(child: &Path, parent: &Path) -> String { + let temp_dir = child.to_path_buf(); let path = match Path::new(&temp_dir).strip_prefix(parent) { Ok(o) => o, Err(e) => { @@ -180,7 +180,7 @@ fn is_unpushed(repo: &git2::Repository, head: &git2::Reference) -> bool { matches!(repo.graph_ahead_behind(local.id(), upstream.id()), Ok(ahead) if ahead.0 > 0) } -fn get_email(repo_path: &PathBuf) -> String { +fn get_email(repo_path: &Path) -> String { let func = |cfg: git2::Config| -> Option<String> { let entries = match cfg.entries(None) { Ok(o) => o, |