Skip to content
Closed
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
16 changes: 15 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
# 👉mostly powered by legacy, but will help to transition to `but-db` backing.
"crates/but-meta", # 📄An interface to support Git-entity metadata;
# 👉lacks tests
"crates/but-hooks", # 📄Git hook management: external manager detection and managed hook installation.
"crates/but-hunk-assignment", # 📄Assign uncommitted changes to stacks/lanes.
# 👉uses `but-ctx`.
"crates/but-hunk-dependency", # 📄Assuming it works, it feels close to 'Exemplary',
Expand Down Expand Up @@ -156,6 +157,7 @@ but-worktrees = { path = "crates/but-worktrees" }
but-db = { path = "crates/but-db" }
but-path = { path = "crates/but-path" }
but-graph = { path = "crates/but-graph" }
but-hooks = { path = "crates/but-hooks" }
but-meta = { path = "crates/but-meta" }
but-rules = { path = "crates/but-rules" }
but-action = { path = "crates/but-action" }
Expand Down Expand Up @@ -209,6 +211,7 @@ gitbutler-workspace = { path = "crates/gitbutler-workspace" }
rusqlite = { version = "0.39.0", features = ["bundled"] }
backoff = "0.4.0"
bstr = "1.12.1"
which = "8.0.0"
# Add the `tracing` or `tracing-detail` features to see more of gitoxide in the logs. Useful to see which programs it invokes.
# When adjusting this, update `gix-testtools` as well!
gix = { version = "0.81.0", git = "https://github.com/GitoxideLabs/gitoxide", rev = "50fb46f17acba7d75d4ed6795b7b9cef484e34c6", default-features = false, features = [
Expand Down
2 changes: 1 addition & 1 deletion crates/but-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ gix = { workspace = true, features = ["worktree-mutation"] }
open.workspace = true
url = { version = "2.5", optional = true }
uuid.workspace = true
which = "8.0.0"
which.workspace = true
but-schemars.workspace = true

[dev-dependencies]
Expand Down
5 changes: 4 additions & 1 deletion crates/but-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ mod ext;
pub use ext::ObjectStorageExt;

mod repo_ext;
pub use repo_ext::{RepositoryExt, update_head_reference};
pub use repo_ext::{
GITBUTLER_COMMIT_AUTHOR_EMAIL, GITBUTLER_COMMIT_AUTHOR_NAME, RepositoryExt, commit_time,
committer_signature, update_head_reference,
};

/// Return `true` if `ref_name` looks like the standard GitButler workspace.
///
Expand Down
10 changes: 6 additions & 4 deletions crates/but-core/src/repo_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,14 @@ impl RepositoryExt for gix::Repository {
}
}

const GITBUTLER_COMMIT_AUTHOR_NAME: &str = "GitButler";
const GITBUTLER_COMMIT_AUTHOR_EMAIL: &str = "gitbutler@gitbutler.com";
/// The display name used for commits authored by GitButler itself.
pub const GITBUTLER_COMMIT_AUTHOR_NAME: &str = "GitButler";
/// The email address used for commits authored by GitButler itself.
pub const GITBUTLER_COMMIT_AUTHOR_EMAIL: &str = "gitbutler@gitbutler.com";

/// Provide a signature with the GitButler author, and the current time or the time overridden
/// depending on the value for `purpose`.
fn committer_signature() -> gix::actor::Signature {
pub fn committer_signature() -> gix::actor::Signature {
gix::actor::Signature {
name: GITBUTLER_COMMIT_AUTHOR_NAME.into(),
email: GITBUTLER_COMMIT_AUTHOR_EMAIL.into(),
Expand All @@ -483,7 +485,7 @@ fn committer_signature() -> gix::actor::Signature {

/// Return the time of a commit as `now` unless the `overriding_variable_name` contains a parseable date,
/// which is used instead.
fn commit_time(overriding_variable_name: &str) -> gix::date::Time {
pub fn commit_time(overriding_variable_name: &str) -> gix::date::Time {
std::env::var(overriding_variable_name)
.ok()
.and_then(|time| gix::date::parse(&time, Some(std::time::SystemTime::now())).ok())
Expand Down
34 changes: 34 additions & 0 deletions crates/but-hooks/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
name = "but-hooks"
version = "0.0.0"
edition.workspace = true
publish = false
rust-version.workspace = true

[lib]
doctest = false

[features]
## Enables env-var overrides for `is_binary_in_path` used by integration tests
## to simulate binary presence/absence without touching the real PATH.
## Must NOT be enabled in production builds.
test-overrides = []

[dependencies]
but-core.workspace = true

anyhow.workspace = true
gix.workspace = true
tracing.workspace = true
which.workspace = true

[[test]]
name = "hooks"
required-features = ["test-overrides"]

[dev-dependencies]
temp-env = "0.3"
tempfile.workspace = true

[lints]
workspace = true
Loading
Loading