summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortummychow <tummychow@users.noreply.github.com>2018-03-11 19:14:51 -0700
committertummychow <tummychow@users.noreply.github.com>2018-03-11 19:14:51 -0700
commit1fd549a3c08fc5c887aa1c0085d19a421ee7c190 (patch)
tree32c24381fc4b83ab619da7003be6808842783f0c
parent6a28144fc141e44acef05ada3d30249573d04ae2 (diff)
actually do dry run
-rw-r--r--README.md2
-rw-r--r--src/lib.rs34
-rw-r--r--src/main.rs2
3 files changed, 27 insertions, 11 deletions
diff --git a/README.md b/README.md
index c0e2699..cecba6f 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/src/lib.rs b/src/lib.rs
index 9a332ef..f29dc14 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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!());