diff options
author | tummychow <tummychow@users.noreply.github.com> | 2018-03-11 19:14:51 -0700 |
---|---|---|
committer | tummychow <tummychow@users.noreply.github.com> | 2018-03-11 19:14:51 -0700 |
commit | 1fd549a3c08fc5c887aa1c0085d19a421ee7c190 (patch) | |
tree | 32c24381fc4b83ab619da7003be6808842783f0c | |
parent | 6a28144fc141e44acef05ada3d30249573d04ae2 (diff) |
actually do dry run
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | src/lib.rs | 34 | ||||
-rw-r--r-- | src/main.rs | 2 |
3 files changed, 27 insertions, 11 deletions
@@ -37,7 +37,7 @@ Note that `git absorb` does _not_ use the system libgit2. This means you do not ## TODO -- implement force and dry-run flags +- implement force flag - implement remote default branch check - add flag to automatically run rebase after successful absorption - add smaller force flags to disable individual safety checks @@ -147,15 +147,31 @@ pub fn run(config: &Config) -> Result<(), failure::Error> { } }; - head_tree = apply_hunk_to_tree(&repo, &head_tree, index_hunk, &index_patch.old_path)?; - head_commit = repo.find_commit(repo.commit( - Some("HEAD"), - &signature, - &signature, - &format!("fixup! {}", dest_commit.id()), - &head_tree, - &[&head_commit], - )?)?; + if !config.dry_run { + head_tree = + apply_hunk_to_tree(&repo, &head_tree, index_hunk, &index_patch.old_path)?; + head_commit = repo.find_commit(repo.commit( + Some("HEAD"), + &signature, + &signature, + &format!("fixup! {}", dest_commit.id()), + &head_tree, + &[&head_commit], + )?)?; + info!(config.logger, "committed"; + "commit" => head_commit.id().to_string(), + ); + } else { + info!(config.logger, "would have committed"; + "fixup" => dest_commit.id().to_string(), + "header" => format!("-{},{} +{},{}", + index_hunk.removed.start, + index_hunk.removed.lines.len(), + index_hunk.added.start, + index_hunk.added.lines.len(), + ), + ); + } } } diff --git a/src/main.rs b/src/main.rs index 58db592..d1ea089 100644 --- a/src/main.rs +++ b/src/main.rs @@ -49,7 +49,7 @@ fn main() { if args.is_present("verbose") { slog::Level::Debug } else { - slog::Level::Warning + slog::Level::Info }, ).fuse(); let mut logger = slog::Logger::root(drain, o!()); |