summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Gerace <nickagerace@gmail.com>2022-12-21 15:51:31 -0500
committerNick Gerace <nickagerace@gmail.com>2022-12-21 16:17:01 -0500
commite0ce979dbd8a2e343a105ac874873697a2100257 (patch)
tree3184043f24fabe63e794147147ef53d992d28c45
parentd7a3510dd806b0edb2e09de2a67cc78a7a464141 (diff)
downloadgfold-e0ce979dbd8a2e343a105ac874873697a2100257.zip
Ignore "extensions.worktreeconfig" error
- Ignore "extensions.worktreeconfig" error until the upstream issue is resolved and git2-rs receives the fix. - Issue: https://github.com/libgit2/libgit2/issues/6044 - Add unknown status with red color - Change unpushed status to use blue color - Split crate imports from external ones in gfold crate Signed-off-by: Nick Gerace <nickagerace@gmail.com>
-rw-r--r--CHANGELOG.md9
-rw-r--r--Cargo.lock4
-rw-r--r--crates/gfold/src/cli.rs7
-rw-r--r--crates/gfold/src/config.rs3
-rw-r--r--crates/gfold/src/display.rs9
-rw-r--r--crates/gfold/src/display/color.rs10
-rw-r--r--crates/gfold/src/report.rs22
-rw-r--r--crates/gfold/src/status.rs2
8 files changed, 46 insertions, 20 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index df20ef6..a49b608 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,14 @@ For new changes prior to version 4.0.0, please see [CHANGELOG_PRE_V4](./docs/CHA
## Unreleased
-The latest version contains all changes.
+<!-- The latest version contains all changes. -->
+
+### Changed
+
+- Add "unknown" status for repositories hitting the "extensions.worktreeconfig" error
+- Bump dependencies
+- Change "unpushed" color to blue
+- Ignore the "extensions.worktreeconfig" error until the corresponding upstream issue is resolved: https://github.com/libgit2/libgit2/issues/6044
## 4.1.2 - 2022-12-20
diff --git a/Cargo.lock b/Cargo.lock
index d9aecb2..24f9b8f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -77,9 +77,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
-version = "4.0.29"
+version = "4.0.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d"
+checksum = "656ad1e55e23d287773f7d8192c300dc715c3eeded93b3da651d11c42cfd74d2"
dependencies = [
"bitflags",
"clap_derive",
diff --git a/crates/gfold/src/cli.rs b/crates/gfold/src/cli.rs
index 8408bfd..09b58f1 100644
--- a/crates/gfold/src/cli.rs
+++ b/crates/gfold/src/cli.rs
@@ -1,13 +1,14 @@
//! This module contains the CLI entrypoint, CLI options and config generation based on the user's
//! settings and environment.
-use crate::config::{ColorMode, Config, DisplayMode};
-use crate::error::Error;
-use crate::run;
use clap::Parser;
use log::debug;
use std::env;
+use crate::config::{ColorMode, Config, DisplayMode};
+use crate::error::Error;
+use crate::run;
+
const HELP: &str = "\
More information: https://github.com/nickgerace/gfold
diff --git a/crates/gfold/src/config.rs b/crates/gfold/src/config.rs
index 7562cb4..7b8d472 100644
--- a/crates/gfold/src/config.rs
+++ b/crates/gfold/src/config.rs
@@ -1,10 +1,11 @@
//! This module contains the config specification and functionality for creating a config.
-use crate::error::Error;
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
use std::{env, fs, io};
+use crate::error::Error;
+
/// This struct is the actual config type consumed through the codebase. It is boostrapped via its
/// public methods and uses [`EntryConfig`], a private struct, under the hood in order to
/// deserialize empty, non-existent, partial, and complete config files.
diff --git a/crates/gfold/src/display.rs b/crates/gfold/src/display.rs
index 98f320b..40f088e 100644
--- a/crates/gfold/src/display.rs
+++ b/crates/gfold/src/display.rs
@@ -1,14 +1,15 @@
//! This module contains the functionality for displaying reports to `stdout`.
-use crate::config::{ColorMode, DisplayMode};
-use crate::display::color::ColorHarness;
-use crate::error::Error;
-use crate::report::LabeledReports;
use log::debug;
use log::warn;
use std::io;
use std::path::Path;
+use crate::config::{ColorMode, DisplayMode};
+use crate::display::color::ColorHarness;
+use crate::error::Error;
+use crate::report::LabeledReports;
+
mod color;
const PAD: usize = 2;
diff --git a/crates/gfold/src/display/color.rs b/crates/gfold/src/display/color.rs
index 47ae7a0..6072963 100644
--- a/crates/gfold/src/display/color.rs
+++ b/crates/gfold/src/display/color.rs
@@ -1,10 +1,11 @@
//! This module provides a harness for non-trivial displays of information to `stdout`.
-use crate::config::ColorMode;
-use crate::status::Status;
use std::io::{self, Write};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
+use crate::config::ColorMode;
+use crate::status::Status;
+
/// This harness provides methods to write to `stdout`. It maps the internal [`ColorMode`] type to
/// our dependency's [`ColorChoice`] type due to discrepancies in behavior and naming.
pub struct ColorHarness {
@@ -26,9 +27,10 @@ impl ColorHarness {
pub fn write_status(&self, status: &Status, status_width: usize) -> io::Result<()> {
let mut stdout = StandardStream::stdout(self.color_choice);
stdout.set_color(ColorSpec::new().set_fg(Some(match status {
- Status::Bare => Color::Red,
+ Status::Bare | Status::Unknown => Color::Red,
Status::Clean => Color::Green,
- _ => Color::Yellow,
+ Status::Unpushed => Color::Blue,
+ Status::Unclean => Color::Yellow,
})))?;
write!(
&mut stdout,
diff --git a/crates/gfold/src/report.rs b/crates/gfold/src/report.rs
index 6043235..df8f523 100644
--- a/crates/gfold/src/report.rs
+++ b/crates/gfold/src/report.rs
@@ -1,15 +1,16 @@
//! This module contains the functionality for generating reports.
-use crate::config::DisplayMode;
-use crate::error::Error;
-use crate::status::Status;
use git2::{ErrorCode, Reference, Remote, Repository, StatusOptions};
-use log::{debug, trace};
+use log::{debug, error, trace};
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::path::Path;
+use crate::config::DisplayMode;
+use crate::error::Error;
+use crate::status::Status;
+
mod target;
const HEAD: &str = "HEAD";
@@ -106,7 +107,17 @@ fn generate_report(repo_path: &Path, include_email: bool) -> anyhow::Result<Repo
"attempting to generate report for repository at path: {:?}",
repo_path
);
- let repo = Repository::open(repo_path)?;
+
+ let repo = match Repository::open(repo_path) {
+ Ok(repo) => repo,
+ Err(e) if e.message() == "unsupported extension name extensions.worktreeconfig" => {
+ error!("skipping error ({e}) until upstream libgit2 issue is resolved: https://github.com/libgit2/libgit2/issues/6044");
+ let unknown_report = Report::new(repo_path, "unknown", &Status::Unknown, None, None)?;
+ return Ok(unknown_report);
+ }
+ Err(e) => return Err(e.into()),
+ };
+
let head = match repo.head() {
Ok(head) => Some(head),
Err(ref e) if e.code() == ErrorCode::UnbornBranch || e.code() == ErrorCode::NotFound => {
@@ -114,6 +125,7 @@ fn generate_report(repo_path: &Path, include_email: bool) -> anyhow::Result<Repo
}
Err(e) => return Err(e.into()),
};
+
let branch = match &head {
Some(head) => head
.shorthand()
diff --git a/crates/gfold/src/status.rs b/crates/gfold/src/status.rs
index 799ac8d..e6e104a 100644
--- a/crates/gfold/src/status.rs
+++ b/crates/gfold/src/status.rs
@@ -8,6 +8,7 @@ pub enum Status {
Bare,
Clean,
Unclean,
+ Unknown,
Unpushed,
}
@@ -17,6 +18,7 @@ impl Status {
Self::Bare => "bare",
Self::Clean => "clean",
Self::Unclean => "unclean",
+ Self::Unknown => "unknown",
Self::Unpushed => "unpushed",
}
}