mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 09:33:01 +03:00
move time module to it's own crate
This commit is contained in:
parent
bf373c5d8f
commit
9023382c78
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -2355,6 +2355,7 @@ dependencies = [
|
||||
"gitbutler-project",
|
||||
"gitbutler-reference",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-time",
|
||||
"gitbutler-user",
|
||||
"log",
|
||||
"resolve-path",
|
||||
@ -2488,6 +2489,10 @@ dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-time"
|
||||
version = "0.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "gitbutler-user"
|
||||
version = "0.0.0"
|
||||
@ -2526,6 +2531,7 @@ dependencies = [
|
||||
"gitbutler-repo",
|
||||
"gitbutler-serde",
|
||||
"gitbutler-testsupport",
|
||||
"gitbutler-time",
|
||||
"gitbutler-user",
|
||||
"glob",
|
||||
"hex",
|
||||
|
@ -25,6 +25,7 @@ members = [
|
||||
"crates/gitbutler-id",
|
||||
"crates/gitbutler-storage",
|
||||
"crates/gitbutler-fs",
|
||||
"crates/gitbutler-time",
|
||||
]
|
||||
resolver = "2"
|
||||
|
||||
@ -61,6 +62,7 @@ gitbutler-secret = { path = "crates/gitbutler-secret" }
|
||||
gitbutler-id = { path = "crates/gitbutler-id" }
|
||||
gitbutler-storage = { path = "crates/gitbutler-storage" }
|
||||
gitbutler-fs = { path = "crates/gitbutler-fs" }
|
||||
gitbutler-time = { path = "crates/gitbutler-time" }
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1 # Compile crates one after another so the compiler can optimize better
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
pub mod git;
|
||||
pub mod path;
|
||||
pub mod time;
|
||||
pub mod types;
|
||||
#[cfg(target_os = "windows")]
|
||||
pub mod windows;
|
||||
|
@ -26,6 +26,7 @@ gitbutler-branch.workspace = true
|
||||
gitbutler-reference.workspace = true
|
||||
gitbutler-error.workspace = true
|
||||
gitbutler-id.workspace = true
|
||||
gitbutler-time.workspace = true
|
||||
|
||||
[[test]]
|
||||
name="repo"
|
||||
|
@ -64,7 +64,7 @@ impl RepoActions for ProjectRepo {
|
||||
|
||||
let commit_id: git2::Oid = branch.get().peel_to_commit()?.id();
|
||||
|
||||
let now = gitbutler_core::time::now_ms();
|
||||
let now = gitbutler_time::time::now_ms();
|
||||
let branch_name = format!("test-push-{now}");
|
||||
|
||||
let refname =
|
||||
|
8
crates/gitbutler-time/Cargo.toml
Normal file
8
crates/gitbutler-time/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "gitbutler-time"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
authors = ["GitButler <gitbutler@gitbutler.com>"]
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
1
crates/gitbutler-time/src/lib.rs
Normal file
1
crates/gitbutler-time/src/lib.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod time;
|
@ -20,6 +20,7 @@ gitbutler-reference.workspace = true
|
||||
gitbutler-error.workspace = true
|
||||
gitbutler-serde.workspace = true
|
||||
gitbutler-id.workspace = true
|
||||
gitbutler-time.workspace = true
|
||||
serde = { workspace = true, features = ["std"]}
|
||||
bstr = "1.9.1"
|
||||
diffy = "0.3.0"
|
||||
|
@ -206,7 +206,7 @@ pub fn set_base_branch(
|
||||
},
|
||||
);
|
||||
|
||||
let now_ms = gitbutler_core::time::now_ms();
|
||||
let now_ms = gitbutler_time::time::now_ms();
|
||||
|
||||
let (upstream, upstream_head) = if let Refname::Local(head_name) = &head_name {
|
||||
let upstream_name = target_branch_ref.with_branch(head_name.branch());
|
||||
|
@ -35,10 +35,10 @@ use crate::integration::{get_integration_commiter, get_workspace_head};
|
||||
use crate::remote::{branch_to_remote_branch, RemoteBranch};
|
||||
use gitbutler_branch::target;
|
||||
use gitbutler_core::git::{CommitExt, CommitHeadersV2, HasCommitHeaders};
|
||||
use gitbutler_core::time::now_since_unix_epoch_ms;
|
||||
use gitbutler_error::error::Code;
|
||||
use gitbutler_error::error::Marker;
|
||||
use gitbutler_repo::rebase::{cherry_rebase, cherry_rebase_group};
|
||||
use gitbutler_time::time::now_since_unix_epoch_ms;
|
||||
|
||||
type AppliedStatuses = Vec<(branch::Branch, BranchStatus)>;
|
||||
|
||||
@ -830,7 +830,7 @@ pub fn create_virtual_branch(
|
||||
}
|
||||
}
|
||||
|
||||
let now = gitbutler_core::time::now_ms();
|
||||
let now = gitbutler_time::time::now_ms();
|
||||
|
||||
let mut branch = Branch {
|
||||
id: BranchId::generate(),
|
||||
@ -1764,7 +1764,7 @@ pub fn reset_branch(
|
||||
let old_head = get_workspace_head(&vb_state, project_repository)?;
|
||||
|
||||
branch.head = target_commit_id;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
let updated_head = get_workspace_head(&vb_state, project_repository)?;
|
||||
@ -2100,7 +2100,7 @@ pub fn commit(
|
||||
let vb_state = project_repository.project().virtual_branches();
|
||||
branch.tree = tree_oid;
|
||||
branch.head = commit_oid;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -2696,7 +2696,7 @@ pub fn reorder_commit(
|
||||
let new_head = cherry_rebase_group(project_repository, parent_oid, &mut ids_to_rebase)
|
||||
.context("rebase failed")?;
|
||||
branch.head = new_head;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -2730,7 +2730,7 @@ pub fn reorder_commit(
|
||||
.context("rebase failed")?;
|
||||
|
||||
branch.head = new_head;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -2789,7 +2789,7 @@ pub fn insert_blank_commit(
|
||||
}
|
||||
}
|
||||
}
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
Ok(())
|
||||
@ -2837,7 +2837,7 @@ pub fn undo_commit(
|
||||
|
||||
if new_commit_oid != commit_oid {
|
||||
branch.head = new_commit_oid;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -2925,7 +2925,7 @@ pub fn squash(
|
||||
Ok(new_head_id) => {
|
||||
// save new branch head
|
||||
branch.head = new_head_id;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -3002,7 +3002,7 @@ pub fn update_commit_message(
|
||||
.map_err(|err| err.context("rebase error"))?;
|
||||
// save new branch head
|
||||
branch.head = new_head_id;
|
||||
branch.updated_timestamp_ms = gitbutler_core::time::now_ms();
|
||||
branch.updated_timestamp_ms = gitbutler_time::time::now_ms();
|
||||
vb_state.set_branch(branch.clone())?;
|
||||
|
||||
crate::integration::update_gitbutler_integration(&vb_state, project_repository)
|
||||
@ -3447,7 +3447,7 @@ pub fn create_virtual_branch_from_branch(
|
||||
.any(|b| b.selected_for_changes.is_some()))
|
||||
.then_some(now_since_unix_epoch_ms());
|
||||
|
||||
let now = gitbutler_core::time::now_ms();
|
||||
let now = gitbutler_time::time::now_ms();
|
||||
|
||||
// add file ownership based off the diff
|
||||
let target_commit = repo.find_commit(default_target.sha)?;
|
||||
|
Loading…
Reference in New Issue
Block a user