Skip to content

Commit

Permalink
Complete implementation for VERGEN_GIT_DIRTY (#283)
Browse files Browse the repository at this point in the history
* [ENH] Added a VERGEN_GIT_DIRTY output to git2 and gitcl.

* [FIX] Fixed a few clippy lints.

* [FIX] Fixed a trivial formatting issue (removed a comma).

* [FIX] Fixed clippy lint in which first if statement was the negated.

* [FIX] Fixed clippy lints in the git_output tests.

* [FIX] Cleaned up some more general clippy lints.

* added support for git_dirty in gix, refactored repo utils, cleaned up cmd, updated tests

* fixed lint issue, updated action

* Tweaks for coverage, fixed broken gix describe

* Teaks to git_output tests

---------

Co-authored-by: Henry Gomersall <henry.gomersall@smartacoustics.co.uk>
  • Loading branch information
CraZySacX and hgomersall authored Jan 12, 2024
1 parent a63aca1 commit 118d7b6
Show file tree
Hide file tree
Showing 18 changed files with 1,094 additions and 587 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
cargo clippy -p vergen --all-targets --features build,cargo,git,git2,rustc,si -- -Dwarnings
cargo clippy -p vergen --all-targets --features build,cargo,git,gix,rustc,si -- -Dwarnings
cargo clippy -p vergen-pretty --all-targets --all-features -- -Dwarnings
cargo clippy -p repo_util --all-targets --all-features -- -Dwarnings
lints-macos:
name: 🕳️ Lints MacOS 🕳️
needs: rustfmt
Expand Down Expand Up @@ -114,6 +115,7 @@ jobs:
cargo clippy -p vergen --all-targets --features build,cargo,git,git2,rustc,si -- -Dwarnings
cargo clippy -p vergen --all-targets --features build,cargo,git,gix,rustc,si -- -Dwarnings
cargo clippy -p vergen-pretty --all-targets --all-features -- -Dwarnings
cargo clippy -p repo_util --all-targets --all-features -- -Dwarnings
lints-windows:
name: 🕳️ Lints Windows 🕳️
needs: rustfmt
Expand Down Expand Up @@ -154,6 +156,7 @@ jobs:
cargo clippy -p vergen --all-targets --features build,cargo,git,git2,rustc,si -- -Dwarnings
cargo clippy -p vergen --all-targets --features build,cargo,git,gix,rustc,si -- -Dwarnings
cargo clippy -p vergen-pretty --all-targets --all-features -- -Dwarnings
cargo clippy -p repo_util --all-targets --all-features -- -Dwarnings
test-linux:
name: 🧪 Linux 🧪
needs: lints-linux
Expand Down
5 changes: 1 addition & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
[workspace]
resolver = "2"

members = [
"vergen",
"vergen-pretty",
]
members = ["repo_util", "vergen", "vergen-pretty"]
20 changes: 20 additions & 0 deletions repo_util/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "repo_util"
version = "0.1.0"
edition = "2021"

[dependencies]
anyhow = "1.0.79"
gix = { version = "0.57.1", default-features = false, features = [
"revision",
"worktree-mutation",
"blocking-network-client",
] }
rand = "0.8.5"

[dev-dependencies]
serial_test = "3.0.0"
temp-env = "0.3.6"

[build-dependencies]
rustversion = "1.0.14"
48 changes: 48 additions & 0 deletions repo_util/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
pub fn main() {
println!("cargo:rerun-if-changed=build.rs");
nightly();
beta();
stable();
msrv();
lints_fix();
}

#[rustversion::nightly]
fn nightly() {
println!("cargo:rustc-cfg=nightly");
}

#[rustversion::not(nightly)]
fn nightly() {}

#[rustversion::beta]
fn beta() {
println!("cargo:rustc-cfg=beta");
}

#[rustversion::not(beta)]
fn beta() {}

#[rustversion::stable]
fn stable() {
println!("cargo:rustc-cfg=stable");
}

#[rustversion::not(stable)]
fn stable() {}

#[rustversion::before(1.70)]
fn msrv() {}

#[rustversion::since(1.70)]
fn msrv() {
println!("cargo:rustc-cfg=msrv");
}

#[rustversion::before(1.75)]
fn lints_fix() {}

#[rustversion::since(1.75)]
fn lints_fix() {
println!("cargo:rustc-cfg=lints_fix")
}
236 changes: 236 additions & 0 deletions repo_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
// Copyright (c) 2022 vergen developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.

//! `repo_util` - `gix` repository test utilities

#![cfg_attr(docsrs, feature(doc_cfg))]
// rustc lints
#![cfg_attr(
all(msrv, feature = "unstable", nightly),
feature(
lint_reasons,
multiple_supertrait_upcastable,
must_not_suspend,
non_exhaustive_omitted_patterns_lint,
strict_provenance,
type_privacy_lints,
rustdoc_missing_doc_code_examples,
)
)]
#![cfg_attr(
msrv,
deny(
absolute_paths_not_starting_with_crate,
anonymous_parameters,
array_into_iter,
asm_sub_register,
bad_asm_style,
bare_trait_objects,
// box_pointers,
break_with_label_and_loop,
clashing_extern_declarations,
coherence_leak_check,
confusable_idents,
const_evaluatable_unchecked,
const_item_mutation,
dead_code,
deprecated,
deprecated_in_future,
deprecated_where_clause_location,
deref_into_dyn_supertrait,
deref_nullptr,
drop_bounds,
duplicate_macro_attributes,
dyn_drop,
elided_lifetimes_in_paths,
ellipsis_inclusive_range_patterns,
explicit_outlives_requirements,
exported_private_dependencies,
forbidden_lint_groups,
for_loops_over_fallibles,
function_item_references,
illegal_floating_point_literal_pattern,
improper_ctypes,
improper_ctypes_definitions,
incomplete_features,
indirect_structural_match,
inline_no_sanitize,
invalid_doc_attributes,
invalid_value,
irrefutable_let_patterns,
keyword_idents,
large_assignments,
late_bound_lifetime_arguments,
legacy_derive_helpers,
let_underscore_drop,
macro_use_extern_crate,
meta_variable_misuse,
missing_abi,
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
mixed_script_confusables,
named_arguments_used_positionally,
no_mangle_generic_items,
non_ascii_idents,
non_camel_case_types,
non_fmt_panics,
non_shorthand_field_patterns,
non_snake_case,
nontrivial_structural_match,
non_upper_case_globals,
noop_method_call,
opaque_hidden_inferred_bound,
overlapping_range_endpoints,
path_statements,
pointer_structural_match,
redundant_semicolons,
renamed_and_removed_lints,
repr_transparent_external_private_fields,
rust_2021_incompatible_closure_captures,
rust_2021_incompatible_or_patterns,
rust_2021_prefixes_incompatible_syntax,
rust_2021_prelude_collisions,
semicolon_in_expressions_from_macros,
single_use_lifetimes,
special_module_name,
stable_features,
suspicious_auto_trait_impls,
temporary_cstring_as_ptr,
trivial_bounds,
trivial_casts,
trivial_numeric_casts,
type_alias_bounds,
tyvar_behind_raw_pointer,
uncommon_codepoints,
unconditional_recursion,
unexpected_cfgs,
ungated_async_fn_track_caller,
uninhabited_static,
unknown_lints,
unnameable_test_items,
unreachable_code,
unreachable_patterns,
unreachable_pub,
unsafe_code,
unsafe_op_in_unsafe_fn,
unstable_features,
unstable_name_collisions,
unstable_syntax_pre_expansion,
unsupported_calling_conventions,
unused_allocation,
unused_assignments,
unused_attributes,
unused_braces,
unused_comparisons,
unused_crate_dependencies,
unused_doc_comments,
unused_extern_crates,
unused_features,
unused_import_braces,
unused_imports,
unused_labels,
unused_lifetimes,
unused_macro_rules,
unused_macros,
unused_must_use,
unused_mut,
unused_parens,
unused_qualifications,
unused_results,
unused_unsafe,
unused_variables,
variant_size_differences,
where_clauses_object_safety,
while_true,
)
)]
#![cfg_attr(msrv, allow(single_use_lifetimes))]
// If nightly or beta and unstable, allow `unstable_features`
#![cfg_attr(
all(msrv, feature = "unstable", any(nightly, beta)),
allow(unstable_features)
)]
// The unstable lints
#![cfg_attr(
all(msrv, feature = "unstable", nightly),
deny(
ffi_unwind_calls,
fuzzy_provenance_casts,
lossy_provenance_casts,
multiple_supertrait_upcastable,
must_not_suspend,
non_exhaustive_omitted_patterns,
private_bounds,
private_interfaces,
unfulfilled_lint_expectations,
unnameable_types,
)
)]
// If nightly and not unstable, deny `unstable_features`
#![cfg_attr(all(msrv, not(feature = "unstable"), nightly), deny(unstable_features))]
// nightly only lints
#![cfg_attr(
all(msrv, nightly),
deny(ambiguous_glob_imports, invalid_reference_casting)
)]
// nightly or beta only lints
#![cfg_attr(
all(msrv, any(beta, nightly)),
deny(
ambiguous_glob_reexports,
byte_slice_in_packed_struct_with_derive,
dropping_copy_types,
dropping_references,
forgetting_copy_types,
forgetting_references,
hidden_glob_reexports,
invalid_from_utf8,
invalid_macro_export_arguments,
invalid_nan_comparisons,
map_unit_fn,
suspicious_double_ref_op,
undefined_naked_function_abi,
unused_associated_type_bounds,
)
)]
// beta only lints
// #![cfg_attr( all(msrv, beta), deny())]
// beta or stable only lints
#![cfg_attr(all(msrv, any(beta, stable)), deny(unused_tuple_struct_fields))]
// stable only lints
#![cfg_attr(
all(msrv, stable),
deny(bindings_with_variant_name, implied_bounds_entailment)
)]
// clippy lints
#![cfg_attr(msrv, deny(clippy::all, clippy::pedantic))]
#![cfg_attr(all(msrv, lints_fix), allow(clippy::struct_field_names))]
// rustdoc lints
#![cfg_attr(
msrv,
deny(
rustdoc::bare_urls,
rustdoc::broken_intra_doc_links,
rustdoc::invalid_codeblock_attributes,
rustdoc::invalid_html_tags,
rustdoc::missing_crate_level_docs,
rustdoc::private_doc_tests,
rustdoc::private_intra_doc_links,
)
)]
#![cfg_attr(
all(msrv, feature = "unstable", nightly),
deny(rustdoc::missing_doc_code_examples)
)]
#![cfg_attr(all(doc, nightly), feature(doc_auto_cfg))]
#![cfg_attr(all(docsrs, nightly), feature(doc_cfg))]

mod repo;

pub use repo::TestRepos;
Loading

0 comments on commit 118d7b6

Please sign in to comment.