mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2025-01-01 14:04:57 +03:00
remove chrono which was only used for 'now in milliseconds, relative to UNIX epoch'
This commit is contained in:
parent
528c0d7598
commit
2ed708b298
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2113,7 +2113,6 @@ dependencies = [
|
||||
"async-trait",
|
||||
"backtrace",
|
||||
"bstr",
|
||||
"chrono",
|
||||
"diffy",
|
||||
"dirs 5.0.1",
|
||||
"filetime",
|
||||
|
@ -17,7 +17,6 @@ anyhow = "1.0.82"
|
||||
async-trait = "0.1.80"
|
||||
backtrace = { version = "0.3.71", optional = true }
|
||||
bstr = "1.9.1"
|
||||
chrono = { version = "0.4.38", features = ["serde"] }
|
||||
diffy = "0.3.0"
|
||||
dirs = "5.0.1"
|
||||
filetime = "0.2.23"
|
||||
|
@ -10,3 +10,18 @@ pub fn now_ms() -> u128 {
|
||||
.expect("system time is set before the Unix epoch")
|
||||
.as_millis()
|
||||
}
|
||||
|
||||
pub fn now_since_unix_epoch_ms() -> i64 {
|
||||
UNIX_EPOCH
|
||||
.elapsed()
|
||||
.map(|d| i64::try_from(d.as_millis()).expect("no system date is this far in the future"))
|
||||
.unwrap_or_else(|_| {
|
||||
i64::try_from(
|
||||
UNIX_EPOCH
|
||||
.duration_since(std::time::SystemTime::now())
|
||||
.expect("a date in the past")
|
||||
.as_millis(),
|
||||
)
|
||||
.expect("no time is that far in the past")
|
||||
})
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ use super::{
|
||||
use crate::error::{self, AnyhowContextExt, Code};
|
||||
use crate::git::diff::{diff_files_into_hunks, trees, FileDiff};
|
||||
use crate::ops::snapshot::Snapshot;
|
||||
use crate::time::now_since_unix_epoch_ms;
|
||||
use crate::virtual_branches::branch::HunkHash;
|
||||
use crate::{
|
||||
dedup::{dedup, dedup_fmt},
|
||||
@ -1078,7 +1079,7 @@ pub fn create_virtual_branch(
|
||||
other_branch.selected_for_changes = None;
|
||||
vb_state.set_branch(other_branch.clone())?;
|
||||
}
|
||||
Some(chrono::Utc::now().timestamp_millis())
|
||||
Some(now_since_unix_epoch_ms())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -1086,7 +1087,7 @@ pub fn create_virtual_branch(
|
||||
(!all_virtual_branches
|
||||
.iter()
|
||||
.any(|b| b.selected_for_changes.is_some()))
|
||||
.then_some(chrono::Utc::now().timestamp_millis())
|
||||
.then_some(now_since_unix_epoch_ms())
|
||||
};
|
||||
|
||||
// make space for the new branch
|
||||
@ -1435,7 +1436,7 @@ pub fn update_branch(
|
||||
other_branch.selected_for_changes = None;
|
||||
vb_state.set_branch(other_branch.clone())?;
|
||||
}
|
||||
Some(chrono::Utc::now().timestamp_millis())
|
||||
Some(now_since_unix_epoch_ms())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
@ -1500,7 +1501,7 @@ fn ensure_selected_for_changes(vb_state: &VirtualBranchesHandle) -> Result<()> {
|
||||
|
||||
applied_branches.sort_by_key(|branch| branch.order);
|
||||
|
||||
applied_branches[0].selected_for_changes = Some(chrono::Utc::now().timestamp_millis());
|
||||
applied_branches[0].selected_for_changes = Some(now_since_unix_epoch_ms());
|
||||
vb_state.set_branch(applied_branches[0].clone())?;
|
||||
Ok(())
|
||||
}
|
||||
@ -4071,7 +4072,7 @@ pub fn create_virtual_branch_from_branch(
|
||||
let selected_for_changes = (!all_virtual_branches
|
||||
.iter()
|
||||
.any(|b| b.selected_for_changes.is_some()))
|
||||
.then_some(chrono::Utc::now().timestamp_millis());
|
||||
.then_some(now_since_unix_epoch_ms());
|
||||
|
||||
let now = crate::time::now_ms();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user