Skip to content

rename the serde1 feature to serde #814

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

Merged
merged 1 commit into from
Apr 17, 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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fast = ["gix/max-performance", "gix/comfort"]
## Use `clap` 3.0 to build the prettiest, best documented and most user-friendly CLI at the expense of binary size.
## Provides a terminal user interface for detailed and exhaustive progress.
## Provides a line renderer for leaner progress display, without the need for a full-blown TUI.
pretty-cli = [ "gitoxide-core/serde1", "prodash/progress-tree", "prodash/progress-tree-log", "prodash/local-time", "env_logger/humantime", "env_logger/color", "env_logger/auto-color" ]
pretty-cli = [ "gitoxide-core/serde", "prodash/progress-tree", "prodash/progress-tree-log", "prodash/local-time", "env_logger/humantime", "env_logger/color", "env_logger/auto-color" ]

## The `--verbose` flag will be powered by an interactive progress mechanism that doubles as log as well as interactive progress
## that appears after a short duration.
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ check: ## Build all code in suitable configurations
&& cargo check
cd gix-object && cargo check --all-features \
&& cargo check --features verbose-object-parsing-errors
cd gix-index && cargo check --features serde1
cd gix-credentials && cargo check --features serde1
cd gix-sec && cargo check --features serde1
cd gix-revision && cargo check --features serde1
cd gix-attributes && cargo check --features serde1
cd gix-glob && cargo check --features serde1
cd gix-mailmap && cargo check --features serde1
cd gix-worktree && cargo check --features serde1
cd gix-actor && cargo check --features serde1
cd gix-date && cargo check --features serde1
cd gix-pack && cargo check --features serde1 \
cd gix-index && cargo check --features serde
cd gix-credentials && cargo check --features serde
cd gix-sec && cargo check --features serde
cd gix-revision && cargo check --features serde
cd gix-attributes && cargo check --features serde
cd gix-glob && cargo check --features serde
cd gix-mailmap && cargo check --features serde
cd gix-worktree && cargo check --features serde
cd gix-actor && cargo check --features serde
cd gix-date && cargo check --features serde
cd gix-pack && cargo check --features serde \
&& cargo check --features pack-cache-lru-static \
&& cargo check --features pack-cache-lru-dynamic \
&& cargo check --features object-cache-dynamic \
Expand Down Expand Up @@ -138,7 +138,7 @@ check: ## Build all code in suitable configurations
&& cargo check --no-default-features --features max-performance-safe \
&& cargo check --no-default-features --features progress-tree \
&& cargo check --no-default-features
cd gix-odb && cargo check --features serde1
cd gix-odb && cargo check --features serde
cd cargo-smart-release && cargo check --all

unit-tests: ## run all unit tests
Expand Down
4 changes: 2 additions & 2 deletions gitoxide-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async-client = ["gix/async-network-client-async-std", "gix-transport-configurati

#! ### Other
## Data structures implement `serde::Serialize` and `serde::Deserialize`.
serde1 = ["gix-commitgraph/serde1", "gix/serde1", "serde_json", "serde", "bytesize/serde"]
serde = ["gix-commitgraph/serde", "gix/serde", "serde_json", "dep:serde", "bytesize/serde"]


[dependencies]
Expand Down Expand Up @@ -73,5 +73,5 @@ rusqlite = { version = "0.29.0", optional = true, features = ["bundled"] }
document-features = { version = "0.2.0", optional = true }

[package.metadata.docs.rs]
features = ["document-features", "blocking-client", "organize", "estimate-hours", "serde1"]
features = ["document-features", "blocking-client", "organize", "estimate-hours", "serde"]
rustdoc-args = ["--cfg", "docsrs"]
4 changes: 2 additions & 2 deletions gitoxide-core/src/commitgraph/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ where
.verify_integrity(noop_processor)
.with_context(|| "Verification failure")?;

#[cfg_attr(not(feature = "serde1"), allow(clippy::single_match))]
#[cfg_attr(not(feature = "serde"), allow(clippy::single_match))]
match output_statistics {
Some(OutputFormat::Human) => drop(print_human_output(&mut out, &stats)),
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Some(OutputFormat::Json) => serde_json::to_writer_pretty(out, &stats)?,
_ => {}
}
Expand Down
10 changes: 5 additions & 5 deletions gitoxide-core/src/index/entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn entries(
use crate::OutputFormat::*;
let file = parse_file(index_path, object_hash)?;

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
if let Json = format {
out.write_all(b"[\n")?;
}
Expand All @@ -19,19 +19,19 @@ pub fn entries(
while let Some(entry) = entries.next() {
match format {
Human => to_human(&mut out, &file, entry)?,
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Json => to_json(&mut out, &file, entry, entries.peek().is_none())?,
}
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
if let Json = format {
out.write_all(b"]\n")?;
}
Ok(())
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
pub(crate) fn to_json(
mut out: &mut impl std::io::Write,
file: &gix::index::File,
Expand All @@ -40,7 +40,7 @@ pub(crate) fn to_json(
) -> anyhow::Result<()> {
use gix::bstr::ByteSlice;

#[cfg_attr(feature = "serde1", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
struct Entry<'a> {
stat: &'a gix::index::entry::Stat,
hex_id: String,
Expand Down
4 changes: 2 additions & 2 deletions gitoxide-core/src/index/information.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub struct Options {
pub extension_details: bool,
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
mod serde_only {

mod ext {
Expand Down Expand Up @@ -153,5 +153,5 @@ mod serde_only {
}
}
}
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
pub(crate) use serde_only::Collection;
8 changes: 4 additions & 4 deletions gitoxide-core/src/index/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ pub fn verify(
file.verify_integrity()?;
file.verify_entries()?;
file.verify_extensions(false, gix::index::verify::extensions::no_find)?;
#[cfg_attr(not(feature = "serde1"), allow(irrefutable_let_patterns))]
#[cfg_attr(not(feature = "serde"), allow(irrefutable_let_patterns))]
if let crate::OutputFormat::Human = format {
writeln!(out, "OK").ok();
}
Ok(())
}

#[cfg_attr(not(feature = "serde1"), allow(unused_variables, unused_mut))]
#[cfg_attr(not(feature = "serde"), allow(unused_variables, unused_mut))]
pub fn information(
index_path: impl AsRef<Path>,
out: impl std::io::Write,
Expand All @@ -60,7 +60,7 @@ pub fn information(
}: information::Options,
) -> anyhow::Result<()> {
use crate::OutputFormat::*;
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
if let Human = format {
writeln!(err, "Defaulting to JSON printing as nothing else will be implemented.").ok();
format = Json;
Expand All @@ -69,7 +69,7 @@ pub fn information(
Human => {
anyhow::bail!("Cannot print information using 'human' format.")
}
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Json => {
let info = information::Collection::try_from_file(parse_file(index_path, object_hash)?, extension_details)?;
serde_json::to_writer_pretty(out, &info)?;
Expand Down
6 changes: 3 additions & 3 deletions gitoxide-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ use std::str::FromStr;
#[derive(Debug, Eq, PartialEq, Hash, Clone, Copy)]
pub enum OutputFormat {
Human,
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Json,
}

impl OutputFormat {
pub fn variants() -> &'static [&'static str] {
&[
"human",
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
"json",
]
}
Expand All @@ -56,7 +56,7 @@ impl FromStr for OutputFormat {
let s_lc = s.to_ascii_lowercase();
Ok(match s_lc.as_str() {
"human" => OutputFormat::Human,
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
"json" => OutputFormat::Json,
_ => return Err(format!("Invalid output format: '{}'", s)),
})
Expand Down
4 changes: 2 additions & 2 deletions gitoxide-core/src/pack/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ where
fn print(stats: Statistics, format: OutputFormat, out: impl std::io::Write) -> anyhow::Result<()> {
match format {
OutputFormat::Human => human_output(stats, out).map_err(Into::into),
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
OutputFormat::Json => serde_json::to_writer_pretty(out, &stats).map_err(Into::into),
}
}
Expand Down Expand Up @@ -365,7 +365,7 @@ fn human_output(
}

#[derive(Default)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
struct Statistics {
counts: pack::data::output::count::objects::Outcome,
entries: pack::data::output::entry::iter_from_counts::Outcome,
Expand Down
2 changes: 1 addition & 1 deletion gitoxide-core/src/pack/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
.with_context(|| "Failed to write pack and index")?;
match format {
OutputFormat::Human => drop(human_output(out, res)),
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
OutputFormat::Json => serde_json::to_writer_pretty(out, &res)?,
};
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions gitoxide-core/src/pack/multi_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub fn create(
Ok(())
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
mod info {
use std::path::PathBuf;

Expand All @@ -48,7 +48,7 @@ mod info {
}
}

#[cfg_attr(not(feature = "serde1"), allow(unused_variables))]
#[cfg_attr(not(feature = "serde"), allow(unused_variables))]
pub fn info(
multi_index_path: PathBuf,
format: OutputFormat,
Expand All @@ -58,7 +58,7 @@ pub fn info(
if format == OutputFormat::Human {
writeln!(err, "Defaulting to JSON as human format isn't implemented").ok();
}
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
{
let file = gix::odb::pack::multi_index::File::at(&multi_index_path)?;
serde_json::to_writer_pretty(
Expand Down
6 changes: 3 additions & 3 deletions gitoxide-core/src/pack/receive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ mod async_io {
#[cfg(feature = "async-client")]
pub use self::async_io::receive;

#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct JsonBundleWriteOutcome {
pub index_version: pack::index::Version,
pub index_hash: String,
Expand All @@ -292,7 +292,7 @@ impl From<pack::index::write::Outcome> for JsonBundleWriteOutcome {
}
}

#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct JsonOutcome {
pub index: JsonBundleWriteOutcome,
pub pack_kind: pack::data::Version,
Expand Down Expand Up @@ -385,7 +385,7 @@ fn receive_pack_blocking<W: io::Write>(

match ctx.format {
OutputFormat::Human => drop(print(&mut ctx.out, outcome, refs)),
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
OutputFormat::Json => {
serde_json::to_writer_pretty(&mut ctx.out, &JsonOutcome::from_outcome_and_refs(outcome, refs))?
}
Expand Down
6 changes: 3 additions & 3 deletions gitoxide-core/src/pack/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
drop(print_statistics(&mut out, &stats));
}
},
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Some(OutputFormat::Json) => serde_json::to_writer_pretty(out, &multi_index.index_names().iter().zip(res.pack_traverse_statistics).collect::<Vec<_>>())?,
_ => {}
};
Expand All @@ -189,10 +189,10 @@ where
ext => return Err(anyhow!("Unknown extension {:?}, expecting 'idx' or 'pack'", ext)),
};
if let Some(stats) = res.1.as_ref() {
#[cfg_attr(not(feature = "serde1"), allow(clippy::single_match))]
#[cfg_attr(not(feature = "serde"), allow(clippy::single_match))]
match output_statistics {
Some(OutputFormat::Human) => drop(print_statistics(&mut out, stats)),
#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
Some(OutputFormat::Json) => serde_json::to_writer_pretty(out, stats)?,
_ => {}
};
Expand Down
12 changes: 6 additions & 6 deletions gitoxide-core/src/repository/mailmap.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
use std::io;

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
use gix::mailmap::Entry;

use crate::OutputFormat;

#[cfg(feature = "serde1")]
#[cfg_attr(feature = "serde1", derive(serde::Serialize))]
#[cfg(feature = "serde")]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
struct JsonEntry {
new_name: Option<String>,
new_email: Option<String>,
old_name: Option<String>,
old_email: String,
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
impl<'a> From<Entry<'a>> for JsonEntry {
fn from(v: Entry<'a>) -> Self {
use gix::bstr::ByteSlice;
Expand All @@ -30,7 +30,7 @@ impl<'a> From<Entry<'a>> for JsonEntry {
pub fn entries(
repo: gix::Repository,
format: OutputFormat,
#[cfg_attr(not(feature = "serde1"), allow(unused_variables))] out: impl io::Write,
#[cfg_attr(not(feature = "serde"), allow(unused_variables))] out: impl io::Write,
mut err: impl io::Write,
) -> anyhow::Result<()> {
if format == OutputFormat::Human {
Expand All @@ -42,7 +42,7 @@ pub fn entries(
writeln!(err, "Error while loading mailmap, the first error is: {}", e).ok();
}

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
serde_json::to_writer_pretty(
out,
&mailmap.entries().into_iter().map(JsonEntry::from).collect::<Vec<_>>(),
Expand Down
12 changes: 6 additions & 6 deletions gitoxide-core/src/repository/odb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use anyhow::bail;

use crate::OutputFormat;

#[cfg_attr(not(feature = "serde1"), allow(unused_variables))]
#[cfg_attr(not(feature = "serde"), allow(unused_variables))]
pub fn info(
repo: gix::Repository,
format: OutputFormat,
Expand All @@ -15,7 +15,7 @@ pub fn info(
writeln!(err, "Only JSON is implemented - using that instead")?;
}

#[cfg_attr(feature = "serde1", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
pub struct Statistics {
pub path: std::path::PathBuf,
pub object_hash: String,
Expand All @@ -33,7 +33,7 @@ pub fn info(
metrics: store.metrics(),
};

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
{
serde_json::to_writer_pretty(out, &stats)?;
}
Expand All @@ -53,7 +53,7 @@ pub mod statistics {
}
}

#[cfg_attr(not(feature = "serde1"), allow(unused_variables))]
#[cfg_attr(not(feature = "serde"), allow(unused_variables))]
pub fn statistics(
repo: gix::Repository,
mut progress: impl gix::Progress,
Expand All @@ -73,7 +73,7 @@ pub fn statistics(
let counter = progress.counter();
let start = std::time::Instant::now();

#[cfg_attr(feature = "serde1", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[derive(Default)]
struct Statistics {
total_objects: usize,
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn statistics(

progress.show_throughput(start);

#[cfg(feature = "serde1")]
#[cfg(feature = "serde")]
{
serde_json::to_writer_pretty(out, &stats)?;
}
Expand Down
Loading