Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade git-repository 0.30 to gix 0.36 #963

Merged
merged 1 commit into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
843 changes: 571 additions & 272 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clap_complete = "4.1.0"
git-features-for-configuration-only = { package = "git-features", version = "0.23.1", features = [
"zlib-ng-compat",
] }
git-repository = { version = "0.30.2", default-features = false, features = [
gix = { version = "0.36.0", default-features = false, features = [
"max-performance-safe",
] }
git2 = { version = "0.16.1", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion benches/repo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use git_repository::{open, ThreadSafeRepository};
use gix::{open, ThreadSafeRepository};
use onefetch::{cli::Config, info::Info};

fn bench_repo_info(c: &mut Criterion) {
Expand Down
5 changes: 2 additions & 3 deletions src/info/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::{
utils::info_field::{InfoField, InfoType},
},
};
use git_repository as git;
use owo_colors::{DynColors, OwoColorize};
use serde::Serialize;
use std::fmt::Write;
Expand All @@ -26,8 +25,8 @@ pub struct Author {

impl Author {
pub fn new(
name: git::bstr::BString,
email: git::bstr::BString,
name: gix::bstr::BString,
email: gix::bstr::BString,
nbr_of_commits: usize,
total_nbr_of_commits: usize,
show_email: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/info/contributors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod test {
#[test]
fn test_display_contributors_info() {
use crate::info::utils::git::Commits;
use git_repository::actor::Time;
use gix::actor::Time;

let timestamp = Time::now_utc();
let commits = Commits {
Expand Down
2 changes: 1 addition & 1 deletion src/info/head.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::{Context, Result};
use git_repository::{reference::Category, Reference, Repository};
use gix::{reference::Category, Reference, Repository};
use serde::Serialize;

#[derive(Serialize)]
Expand Down
4 changes: 2 additions & 2 deletions src/info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl std::fmt::Display for Info {

impl Info {
pub fn new(config: &Config) -> Result<Self> {
let git_repo = git_repository::discover(&config.input)?;
let git_repo = gix::discover(&config.input)?;
let repo_path = get_work_dir(&git_repo)?;

let loc_by_language_sorted_handle = std::thread::spawn({
Expand Down Expand Up @@ -267,7 +267,7 @@ fn get_manifest(repo_path: &Path) -> Result<Option<Manifest>> {
}
}

pub fn get_work_dir(repo: &git_repository::Repository) -> Result<std::path::PathBuf> {
pub fn get_work_dir(repo: &gix::Repository) -> Result<std::path::PathBuf> {
Ok(repo
.work_dir()
.context("please run onefetch inside of a non-bare git repository")?
Expand Down
2 changes: 1 addition & 1 deletion src/info/pending.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git2::{Status, StatusOptions, StatusShow};
use git_repository::Repository;
use gix::Repository;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
6 changes: 3 additions & 3 deletions src/info/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
},
};
use anyhow::Result;
use git_repository::{bstr::ByteSlice, Repository};
use gix::{bstr::ByteSlice, Repository};
use onefetch_manifest::Manifest;
use serde::Serialize;
use std::ffi::OsStr;
Expand Down Expand Up @@ -44,8 +44,8 @@ fn get_repo_name(repo_url: &str, manifest: Option<&Manifest>) -> Result<String>
if repo_url.is_empty() {
return Ok(String::default());
}
let url = git_repository::url::parse(repo_url.into())?;
let path = git_repository::path::from_bstr(url.path.as_bstr());
let url = gix::url::parse(repo_url.into())?;
let path = gix::path::from_bstr(url.path.as_bstr());
let repo_name = path
.with_extension("")
.file_name()
Expand Down
2 changes: 1 addition & 1 deletion src/info/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
},
};
use byte_unit::Byte;
use git_repository::Repository;
use gix::Repository;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
6 changes: 4 additions & 2 deletions src/info/title.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::get_style;
use crate::cli;
use git_repository::Repository;
use gix::Repository;
use owo_colors::{DynColors, OwoColorize};
use serde::Serialize;

Expand Down Expand Up @@ -41,6 +41,8 @@ impl Title {
}
pub fn get_git_username(repo: &Repository) -> String {
repo.committer()
.map(Result::ok)
.flatten()
.map(|c| c.name.to_string())
.unwrap_or_default()
}
Expand Down Expand Up @@ -86,7 +88,7 @@ impl std::fmt::Display for Title {
mod tests {
use super::*;
use anyhow::Result;
use git_repository::{open, Repository, ThreadSafeRepository};
use gix::{open, Repository, ThreadSafeRepository};
use owo_colors::AnsiColors;

fn repo(name: &str) -> Result<Repository> {
Expand Down
2 changes: 1 addition & 1 deletion src/info/url.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git_repository::Repository;
use gix::Repository;
use serde::Serialize;

#[derive(Serialize)]
Expand Down
19 changes: 9 additions & 10 deletions src/info/utils/git.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::cli::{MyRegex, NumberSeparator};
use crate::info::author::Author;
use anyhow::Result;
use git::bstr::BString;
use git_repository as git;
use git_repository::bstr::ByteSlice;
use gix::bstr::BString;
use gix::bstr::ByteSlice;
use regex::Regex;
use std::collections::HashMap;
use std::str::FromStr;
Expand All @@ -14,25 +13,25 @@ pub struct Commits {
pub num_commits: usize,
/// false if we have found the first commit that started it all, true if the repository is shallow.
pub is_shallow: bool,
pub time_of_most_recent_commit: git::actor::Time,
pub time_of_first_commit: git::actor::Time,
pub time_of_most_recent_commit: gix::actor::Time,
pub time_of_first_commit: gix::actor::Time,
}

#[derive(Hash, PartialOrd, Ord, Eq, PartialEq)]
pub struct Sig {
name: git::bstr::BString,
email: git::bstr::BString,
name: gix::bstr::BString,
email: gix::bstr::BString,
}

impl From<git::actor::Signature> for Sig {
fn from(git::actor::Signature { name, email, .. }: git::actor::Signature) -> Self {
impl From<gix::actor::Signature> for Sig {
fn from(gix::actor::Signature { name, email, .. }: gix::actor::Signature) -> Self {
Self { name, email }
}
}

impl Commits {
pub fn new(
mut repo: git::Repository,
mut repo: gix::Repository,
no_merges: bool,
no_bots: &Option<Option<MyRegex>>,
number_of_authors_to_display: usize,
Expand Down
2 changes: 1 addition & 1 deletion src/info/utils/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use git_repository::actor::Time;
use gix::actor::Time;
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
use time_humanize::HumanTime;

Expand Down
2 changes: 1 addition & 1 deletion src/info/version.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::info::utils::info_field::{InfoField, InfoType};
use anyhow::Result;
use git_repository::Repository;
use gix::Repository;
use onefetch_manifest::Manifest;
use serde::Serialize;

Expand Down
2 changes: 1 addition & 1 deletion tests/repo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::Result;
use git_repository::{open, Repository, ThreadSafeRepository};
use gix::{open, Repository, ThreadSafeRepository};
use onefetch::cli::Config;
use onefetch::info::{get_work_dir, Info};

Expand Down