summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Gerace <nickagerace@gmail.com>2021-01-27 02:06:29 +0000
committerNick Gerace <nickagerace@gmail.com>2021-01-26 21:11:18 -0500
commit09c88901cbc9d4507aad348391631106d41141a9 (patch)
tree1312eeceed02c39f06f60e9b30bacdb7af048a40
parent7bdeb4bd22706fa5363196486d023b722e756bae (diff)
downloadgfold-09c88901cbc9d4507aad348391631106d41141a9.zip
Switch disable unpushed check to enable
Switch disable unpushed check to enable. Change macOS to darwin where possible.
-rw-r--r--.github/workflows/release.yml2
-rw-r--r--CHANGELOG.md13
-rw-r--r--Cargo.lock84
-rw-r--r--README.md313
-rw-r--r--src/driver.rs10
-rw-r--r--src/lib.rs34
-rw-r--r--src/main.rs13
-rw-r--r--src/util.rs27
8 files changed, 253 insertions, 243 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 73a5969..2fc4bdb 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -17,7 +17,7 @@ jobs:
asset_name: gfold-windows-amd64
- os: macos-latest
artifact_name: gfold
- asset_name: gfold-macos-amd64
+ asset_name: gfold-darwin-amd64
steps:
- uses: actions/checkout@v2
- name: Build
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ccb74c9..65d33c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,19 @@ All changes are from [@nickgerace](https://github.com/nickgerace) unless otherwi
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]
+<!-- The latest version contains all changes. -->
-The latest version contains all changes.
+### Added
+
+- Dependencies section to CHANGELOG
+- `paru` to suggested AUR helpers in README
+
+### Changed
+
+- 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
diff --git a/Cargo.lock b/Cargo.lock
index a47d38d..52db8b0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -84,9 +84,9 @@ dependencies = [
[[package]]
name = "byteorder"
-version = "1.3.4"
+version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
+checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
[[package]]
name = "cc"
@@ -195,9 +195,9 @@ dependencies = [
[[package]]
name = "eyre"
-version = "0.6.3"
+version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5f29abf4740a4778632fe27a4f681ef5b7a6f659aeba3330ac66f48e20cfa3b7"
+checksum = "221239d1d5ea86bf5d6f91c9d6bc3646ffe471b08ff9b0f91c44f115ac969d2b"
dependencies = [
"indenter",
"once_cell",
@@ -215,11 +215,11 @@ dependencies = [
[[package]]
name = "getrandom"
-version = "0.1.15"
+version = "0.1.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6"
+checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
dependencies = [
- "cfg-if 0.1.10",
+ "cfg-if 1.0.0",
"libc",
"wasi",
]
@@ -238,9 +238,9 @@ dependencies = [
[[package]]
name = "git2"
-version = "0.13.12"
+version = "0.13.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ca6f1a0238d7f8f8fd5ee642f4ebac4dbc03e03d1f78fbe7a3ede35dcf7e2224"
+checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
dependencies = [
"bitflags",
"libc",
@@ -253,27 +253,27 @@ dependencies = [
[[package]]
name = "heck"
-version = "0.3.1"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
+checksum = "87cbf45460356b7deeb5e3415b5563308c0a9b057c85e12b06ad551f98d0a6ac"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
-version = "0.1.17"
+version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8"
+checksum = "322f4de77956e22ed0e5032c359a0f1273f1f7f0d79bfa3b8ffbc730d7fbcc5c"
dependencies = [
"libc",
]
[[package]]
name = "humantime"
-version = "2.0.1"
+version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3c1ad908cc71012b7bea4d0c53ba96a8cba9962f048fa68d143376143d863b7a"
+checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "idna"
@@ -288,15 +288,15 @@ dependencies = [
[[package]]
name = "indenter"
-version = "0.3.0"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e0bd112d44d9d870a6819eb505d04dd92b5e4d94bb8c304924a0872ae7016fb5"
+checksum = "f4d5eb2e114fec2b7fe0fadc22888ad2658789bb7acac4dbee9cf8389f971ec8"
[[package]]
name = "itoa"
-version = "0.4.6"
+version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc6f3ad7b9d11a0c00842ff8de1b60ee58661048eb8049ed33c73594f359d7e6"
+checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736"
[[package]]
name = "jobserver"
@@ -315,15 +315,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
-version = "0.2.81"
+version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
+checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929"
[[package]]
name = "libgit2-sys"
-version = "0.12.14+1.1.0"
+version = "0.12.18+1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8f25af58e6495f7caf2919d08f212de550cfa3ed2f5e744988938ea292b9f549"
+checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
dependencies = [
"cc",
"libc",
@@ -361,9 +361,9 @@ dependencies = [
[[package]]
name = "log"
-version = "0.4.11"
+version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b"
+checksum = "fcf3805d4480bb5b86070dcfeb9e2cb2ebc148adb753c5cca5f884d1d65a42b2"
dependencies = [
"cfg-if 0.1.10",
]
@@ -394,9 +394,9 @@ checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de"
[[package]]
name = "openssl-sys"
-version = "0.9.59"
+version = "0.9.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de52d8eabd217311538a39bba130d7dea1f1e118010fee7a033d966845e7d5fe"
+checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6"
dependencies = [
"autocfg",
"cc",
@@ -466,9 +466,9 @@ dependencies = [
[[package]]
name = "quote"
-version = "1.0.7"
+version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37"
+checksum = "991431c3519a3f36861882da93630ce66b52918dcf1b8e2fd66b397fc96f28df"
dependencies = [
"proc-macro2",
]
@@ -492,9 +492,9 @@ dependencies = [
[[package]]
name = "regex"
-version = "1.4.2"
+version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c"
+checksum = "d9251239e129e16308e70d853559389de218ac275b515068abc96829d05b948a"
dependencies = [
"aho-corasick",
"memchr",
@@ -513,9 +513,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
-version = "0.6.21"
+version = "0.6.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189"
+checksum = "b5eb417147ba9860a96cfe72a0b93bf88fee1744b5636ec99ab20c1aa9376581"
[[package]]
name = "rust-argon2"
@@ -537,9 +537,9 @@ checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e"
[[package]]
name = "serde"
-version = "1.0.118"
+version = "1.0.123"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
+checksum = "92d5161132722baa40d802cc70b15262b98258453e85e5d1d365c757c73869ae"
[[package]]
name = "strsim"
@@ -573,9 +573,9 @@ dependencies = [
[[package]]
name = "syn"
-version = "1.0.54"
+version = "1.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44"
+checksum = "c700597eca8a5a762beb35753ef6b94df201c81cca676604f547495a0d7f0081"
dependencies = [
"proc-macro2",
"quote",
@@ -613,18 +613,18 @@ dependencies = [
[[package]]
name = "thread_local"
-version = "1.0.1"
+version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14"
+checksum = "d8208a331e1cb318dd5bd76951d2b8fc48ca38a69f5f4e4af1b6a9f8c6236915"
dependencies = [
- "lazy_static",
+ "once_cell",
]
[[package]]
name = "tinyvec"
-version = "1.1.0"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ccf8dbc19eb42fba10e8feaaec282fb50e2c14b2726d6301dbfeed0f73306a6f"
+checksum = "317cca572a0e89c3ce0ca1f1bdc9369547fe318a683418e42ac8f59d14701023"
dependencies = [
"tinyvec_macros",
]
diff --git a/README.md b/README.md
index d033c1b..86247b4 100644
--- a/README.md
+++ b/README.md
@@ -1,154 +1,159 @@
-# gfold
-
-[![GitHub](https://img.shields.io/github/license/nickgerace/gfold?style=flat-square)](./LICENSE)
-[![Latest SemVer GitHub Tag](https://img.shields.io/github/v/tag/nickgerace/gfold?label=version&style=flat-square)](https://github.com/nickgerace/gfold/releases/latest)
-[![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.
-
-```bash
-user at hostname in ~/git
-% gfold
-great-journey unclean main git@github.com:truth/great-journey.git
-installation-zero bare main https://github.com/the-ark/installation-zero.git
-sierra unpushed dev https://github.com/forward-unto-dawn/sierra.git
-spark clean issue343 git@github.com:guilty/spark.git
-tartarus unclean delta git@github.com:covenant/tartarus.git
-voi clean main https://github.com/earth/voi.git
-```
-
-## Description and Motivation
-
-This app displays relevant information for multiple Git repositories in one, or multiple, directories.
-While this tool might seem limited in scope and purpose, that is by design.
-
-It prints each repository in alphabetical order, and pads each result based on the longest directory, branch, and status string.
-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.
-
-## Installation
-
-There are multiple ways to install `gfold`, but here are some recommended methods...
-
-Installation Methods | `linux-gnu-amd64` | `macos-amd64` | `windows-amd64`
---- | --- | --- | --
-Homebrew | x | x | -
-Arch User Repository (AUR) | x | - | -
-Cargo Install | x | x | x
-GitHub Release Binary | x | x | x
-
-### Homebrew
-
-You can use [Homebrew](https://brew.sh) to install the [tap](https://github.com/nickgerace/homebrew-gfold) for `gfold`.
-
-```bash
-brew install nickgerace/gfold/gfold
-```
-
-Alternatively, you can do...
-
-```bash
-brew tap nickgerace/gfold
-brew install gfold
-```
-
-Running `brew help` or `man brew` can help you use `brew` locally.
-You can check out [Homebrew's documentation](https://docs.brew.sh) as well.
-
-### Arch User Repository (AUR)
-
-This application is available for all Linux distributions that support installing packages from the AUR.
-
-- [gfold](https://aur.archlinux.org/packages/gfold/) (builds from source)
-- [gfold-bin](https://aur.archlinux.org/packages/gfold-bin/) (uses the GitHub release binary)
-- [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) (example: `yay -S gfold`), in order to install their AUR packages.
-
-### Cargo Install
-
-You can install from [crates.io](https://crates.io/crates/gfold) by executing...
-
-```bash
-cargo install gfold
-```
-
-### GitHub Release Binary
-
-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`.
-Here is an example on how to do that on macOS and Linux...
-
-```bash
-chmod +x gfold
-mv gfold /usr/local/bin/
-```
-
-You may have to reload your shell in order to see `gfold` in your `PATH`.
-
-#### Advanced Management
-
-You can use symbolic links to swap between versions, and manage multiple at a time.
-Here is a full install workflow example...
-
-```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
-```
-
-Now, you can add/remove versions of the binary from `/usr/local/gfold/`, and change the symbolic link as needed.
-
-## Usage
-
-For all the ways on how to use this application, pass in the `-h`, or `--help`, flag.
-
-```bash
-gfold --help
-```
-
-Here are some example invocations...
-
-```bash
-gfold
-gfold ..
-gfold $HOME
-gfold /this/is/an/absolute/path
-gfold ../../this/is/a/relative/path
-gfold ~/path/to/multiple/repositories/ -r
-gfold -r $HOME/path/to/multiple/repositories
-```
-
-## Compatibility
-
-`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...
-
-- **Linux**: `linux-gnu-amd64`
-- **macOS**: `macos-amd64`
-- **Windows 10**: `windows-amd64`
-
-## Changelog
-
-Please check out [CHANGELOG.md](./CHANGELOG.md) for more information.
-It follows the [Keep a Changelog](https://keepachangelog.com/) format.
-
-## Code of Conduct
-
-This repository follows and enforces the Rust programming language's [Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct).
-
-## Additional Information
-
-- Author: [Nick Gerace](https://nickgerace.dev)
-- License: [Apache 2.0](./LICENSE)
-
-## 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
+# gfold
+
+[![GitHub](https://img.shields.io/github/license/nickgerace/gfold?style=flat-square)](./LICENSE)
+[![Latest SemVer GitHub Tag](https://img.shields.io/github/v/tag/nickgerace/gfold?label=version&style=flat-square)](https://github.com/nickgerace/gfold/releases/latest)
+[![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.
+
+```bash
+user at hostname in ~/git
+% gfold
+great-journey unclean main git@github.com:truth/great-journey.git
+installation-zero bare main https://github.com/the-ark/installation-zero.git
+sierra unpushed dev https://github.com/forward-unto-dawn/sierra.git
+spark clean issue343 git@github.com:guilty/spark.git
+tartarus unclean delta git@github.com:covenant/tartarus.git
+voi clean main https://github.com/earth/voi.git
+```
+
+## Description and Motivation
+
+This app displays relevant information for multiple Git repositories in one, or multiple, directories.
+While this tool might seem limited in scope and purpose, that is by design.
+
+It prints each repository in alphabetical order, and pads each result based on the longest directory, branch, and status string.
+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.
+
+## Installation
+
+There are multiple ways to install `gfold`, but here are some recommended methods...
+
+Installation Methods | `linux-gnu-amd64` | `darwin-amd64` | `windows-amd64`
+--- | --- | --- | --
+Homebrew | x | x | -
+Arch User Repository (AUR) | x | - | -
+Cargo Install | x | x | x
+GitHub Release Binary | x | x | x
+
+### Homebrew
+
+You can use [Homebrew](https://brew.sh) to install the [tap](https://github.com/nickgerace/homebrew-gfold) for `gfold`.
+
+```bash
+brew install nickgerace/gfold/gfold
+```
+
+Alternatively, you can do...
+
+```bash
+brew tap nickgerace/gfold
+brew install gfold
+```
+
+Running `brew help` or `man brew` can help you use `brew` locally.
+You can check out [Homebrew's documentation](https://docs.brew.sh) as well.
+
+### Arch User Repository (AUR)
+
+This application is available for all Linux distributions that support installing packages from the AUR.
+
+- [gfold](https://aur.archlinux.org/packages/gfold/) (builds from source)
+- [gfold-bin](https://aur.archlinux.org/packages/gfold-bin/) (uses the GitHub release binary)
+- [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
+yay -S gfold
+paru -S gfold
+```
+
+### Cargo Install
+
+You can install from [crates.io](https://crates.io/crates/gfold) by executing...
+
+```bash
+cargo install gfold
+```
+
+### GitHub Release Binary
+
+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`.
+Here is an example on how to do that on macOS and Linux...
+
+```bash
+chmod +x gfold
+mv gfold /usr/local/bin/
+```
+
+You may have to reload your shell in order to see `gfold` in your `PATH`.
+
+#### Advanced Management
+
+You can use symbolic links to swap between versions, and manage multiple at a time.
+Here is a full install workflow example...
+
+```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
+```
+
+Now, you can add/remove versions of the binary from `/usr/local/gfold/`, and change the symbolic link as needed.
+
+## Usage
+
+For all the ways on how to use this application, pass in the `-h`, or `--help`, flag.
+
+```bash
+gfold --help
+```
+
+Here are some example invocations...
+
+```bash
+gfold
+gfold ..
+gfold $HOME
+gfold /this/is/an/absolute/path
+gfold ../../this/is/a/relative/path
+gfold ~/path/to/multiple/repositories/ -r
+gfold -r $HOME/path/to/multiple/repositories
+```
+
+## Compatibility
+
+`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...
+
+- **Linux**: `linux-gnu-amd64`
+- **macOS**: `darwin-amd64`
+- **Windows 10**: `windows-amd64`
+
+## Changelog
+
+Please check out [CHANGELOG.md](./CHANGELOG.md) for more information.
+It follows the [Keep a Changelog](https://keepachangelog.com/) format.
+
+## Code of Conduct
+
+This repository follows and enforces the Rust programming language's [Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct).
+
+## Additional Information
+
+- Author: [Nick Gerace](https://nickgerace.dev)
+- License: [Apache 2.0](./LICENSE)
+
+## 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
diff --git a/src/driver.rs b/src/driver.rs
index 4830500..d27affb 100644
--- a/src/driver.rs
+++ b/src/driver.rs
@@ -6,17 +6,15 @@
*/
use crate::util;
-
+use eyre::Result;
+use log::debug;
use std::cmp::Ordering;
use std::fs;
use std::path::Path;
-use eyre::Result;
-use log::debug;
-
#[derive(Debug)]
pub struct Config {
- pub disable_unpushed_check: bool,
+ pub enable_unpushed_check: bool,
pub no_color: bool,
pub recursive: bool,
pub skip_sort: bool,
@@ -82,7 +80,7 @@ impl Results {
if let Some(table_wrapper) = util::create_table_from_paths(
repos,
&dir,
- &config.disable_unpushed_check,
+ &config.enable_unpushed_check,
&config.no_color,
) {
self.0.push(table_wrapper);
diff --git a/src/lib.rs b/src/lib.rs
index a1a4612..80d0bb3 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,33 +7,33 @@
//! This is a CLI tool to help keep track of your Git repositories.
-mod driver;
-mod util;
-
#[macro_use]
extern crate prettytable;
-use std::path::Path;
+mod driver;
+mod util;
use eyre::Result;
+use std::path::Path;
/// This function is the primary, backend driver for `gfold`.
///
-/// - `path`: the target path to find and parse Git repositories
+/// - `enable_unpushed_check`: enable checking for unpushed commits (experimental)
/// - `no_color`: disables color, bolding, etc.
+/// - `path`: the target path to find and parse Git repositories
/// - `recursive`: recursively searches directories for Git repositories
/// - `skip_sort`: skips sorting the repositories for output
///
/// When executed, results will be printed to STDOUT.
pub fn run(
path: &Path,
- disable_unpushed_check: bool,
+ enable_unpushed_check: bool,
no_color: bool,
recursive: bool,
skip_sort: bool,
) -> Result<()> {
let config = driver::Config {
- disable_unpushed_check,
+ enable_unpushed_check,
no_color,
recursive,
skip_sort,
@@ -65,15 +65,15 @@ mod tests {
fn parent_directory_all_options() {
let mut current_dir = env::current_dir().expect("failed to get CWD");
current_dir.pop();
-
- assert_ne!(run(&current_dir, false, true, false, false).is_err(), true);
- assert_ne!(run(&current_dir, false, true, false, true).is_err(), true);
- assert_ne!(run(&current_dir, false, true, true, false).is_err(), true);
-
- assert_ne!(run(&current_dir, false, false, true, false).is_err(), true);
- assert_ne!(run(&current_dir, false, false, true, true).is_err(), true);
- assert_ne!(run(&current_dir, false, false, false, true).is_err(), true);
-
- assert_ne!(run(&current_dir, false, true, true, true).is_err(), true);
+ for skip_sort in vec![true, false] {
+ for recursive in vec![true, false] {
+ for no_color in vec![true, false] {
+ assert_ne!(
+ run(&current_dir, false, no_color, recursive, skip_sort).is_err(),
+ true
+ );
+ }
+ }
+ }
}
}
diff --git a/src/main.rs b/src/main.rs
index 8c233f8..c3fd418 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -5,10 +5,9 @@
* License: Apache 2.0
*/
+use eyre::Result;
use std::env;
use std::path::PathBuf;
-
-use eyre::Result;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
@@ -22,8 +21,12 @@ working directory."
struct Opt {
#[structopt(short, long, help = "Set to debug mode")]
debug: bool,
- #[structopt(short, long, help = "Toggle to disable checking for unpushed commits")]
- disable_unpushed_check: bool,
+ #[structopt(
+ short,
+ long,
+ help = "Toggle to enable checking for unpushed commits (experimental)"
+ )]
+ enable_unpushed_check: bool,
#[structopt(long = "nc", help = "Disable color output")]
no_color: bool,
#[structopt(parse(from_os_str), help = "Target a different directory")]
@@ -50,7 +53,7 @@ fn main() -> Result<()> {
gfold::run(
&path,
- opt.disable_unpushed_check,
+ opt.enable_unpushed_check,
opt.no_color,
opt.recursive,
opt.skip_sort,
diff --git a/src/util.rs b/src/util.rs
index 6dda677..86a09d5 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -6,10 +6,8 @@
*/
use crate::driver;
-
-use std::path::{Path, PathBuf};
-
use log::debug;
+use std::path::{Path, PathBuf};
#[derive(Debug)]
enum Condition {
@@ -23,7 +21,7 @@ enum Condition {
pub fn create_table_from_paths(
repos: Vec<PathBuf>,
path: &Path,
- disable_unpushed_check: &bool,
+ enable_unpushed_check: &bool,
no_color: &bool,
) -> Option<driver::TableWrapper> {
let mut table = prettytable::Table::new();
@@ -54,30 +52,25 @@ pub fn create_table_from_paths(
continue;
}
};
- let url = match origin.url() {
- Some(url) => url,
- None => "none",
- };
+ let url = origin.url().unwrap_or("none");
debug!("[+] url: {:#?}", url);
let head = repo_obj.head().ok()?;
- let branch = match head.shorthand() {
- Some(branch) => branch,
- None => "none",
- };
+ let branch = head.shorthand().unwrap_or("none");
debug!("[+] branch: {:#?}", branch);
- let name = match Path::new(&repo).strip_prefix(path).ok()?.to_str() {
- Some(name) => name,
- None => "none",
- };
+ let name = Path::new(&repo)
+ .strip_prefix(path)
+ .ok()?
+ .to_str()
+ .unwrap_or("none");
debug!("[+] name: {:#?}", name);
// FIXME: test using the "is_bare()" method for a repository object.
let mut opts = git2::StatusOptions::new();
let condition = match repo_obj.statuses(Some(&mut opts)) {
Ok(statuses) if statuses.is_empty() => {
- if !disable_unpushed_check && is_unpushed(&repo_obj, &head) {
+ if *enable_unpushed_check && is_unpushed(&repo_obj, &head) {
Condition::Unpushed
} else {
Condition::Clean