Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Timmmm committed May 24, 2021
1 parent 40deb00 commit da94769
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,28 @@
use std::path::{Path, PathBuf};
use std::{
path::{Path, PathBuf},
env,
time::{SystemTime, UNIX_EPOCH},
};
use anyhow::{anyhow, bail, Result};
use git_commands::*;
use colored::*;
use std::time::{SystemTime, UNIX_EPOCH};

mod conflicts;
use conflicts::*;
mod trim;
use trim::*;

// Set GIT_COMMITTER_DATE to now to prevent getting inconsistent hashes when
// rebasing the same commit multiple times.
fn set_committer_date_to_now() {
let time_since_epoch = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default();
// Only set it if it isn't already set, otherwise it breaks test and also
// the user might want to set it.
if env::var_os("GIT_COMMITTER_DATE").is_some() {
return;
}

std::env::set_var("GIT_COMMITTER_DATE", format!("@{} +0000", time_since_epoch.as_secs()));
let time_since_epoch = SystemTime::now().duration_since(UNIX_EPOCH).unwrap_or_default();
env::set_var("GIT_COMMITTER_DATE", format!("@{} +0000", time_since_epoch.as_secs()));
}

pub fn autorebase(repo_path: &Path, onto_branch: &str, slow_conflict_detection: bool) -> Result<()> {
Expand Down

0 comments on commit da94769

Please sign in to comment.