step fourty seven: merge, create command

This commit is contained in:
Gonçalo Valério 2020-11-23 23:20:18 +00:00
parent 84bb97e1a2
commit 89287d3f00
2 changed files with 15 additions and 0 deletions

View File

@ -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

View File

@ -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<String, Vec<String>>) {
let ref_str = if refs.contains_key(&oid) {
refs.get_mut(&oid).unwrap().join(", ")