From 89287d3f009f2b7e65c82e23ad24e82930a7b35c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Val=C3=A9rio?= Date: Mon, 23 Nov 2020 23:20:18 +0000 Subject: [PATCH] step fourty seven: merge, create command --- src/base.rs | 2 ++ src/main.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/base.rs b/src/base.rs index 2638790..070037d 100644 --- a/src/base.rs +++ b/src/base.rs @@ -259,6 +259,8 @@ pub fn reset(oid: String) { ) } +pub fn merge(_oid: String) {} + fn is_ignored(path: &String) -> bool { if path.contains(".rgit") { true diff --git a/src/main.rs b/src/main.rs index 6e90e52..7eef1fb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,6 +81,11 @@ fn main() { .about("Compare the working tree with the given commit") .arg(Arg::with_name("commit").index(1).default_value("@")), ) + .subcommand( + SubCommand::with_name("merge") + .about("Merge changes of a different commit/branch") + .arg(Arg::with_name("commit").index(1).required(true)), + ) .get_matches(); match matches.subcommand_name() { @@ -99,6 +104,7 @@ fn main() { Some("reset") => reset(matches), Some("show") => show(matches), Some("diff") => difference(matches), + Some("merge") => merge(matches), _ => println!("unknown sub command"), } } @@ -308,6 +314,13 @@ fn difference(matches: ArgMatches) { } } +fn merge(matches: ArgMatches) { + if let Some(cmd_matches) = matches.subcommand_matches("reset") { + let oid = base::get_oid(cmd_matches.value_of("commit").unwrap().to_owned()); + base::merge(oid); + } +} + fn print_commit(oid: String, commit: &base::Commit, mut refs: HashMap>) { let ref_str = if refs.contains_key(&oid) { refs.get_mut(&oid).unwrap().join(", ")