step fourty seven: merge, create command
This commit is contained in:
parent
84bb97e1a2
commit
89287d3f00
|
@ -259,6 +259,8 @@ pub fn reset(oid: String) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn merge(_oid: String) {}
|
||||||
|
|
||||||
fn is_ignored(path: &String) -> bool {
|
fn is_ignored(path: &String) -> bool {
|
||||||
if path.contains(".rgit") {
|
if path.contains(".rgit") {
|
||||||
true
|
true
|
||||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -81,6 +81,11 @@ fn main() {
|
||||||
.about("Compare the working tree with the given commit")
|
.about("Compare the working tree with the given commit")
|
||||||
.arg(Arg::with_name("commit").index(1).default_value("@")),
|
.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();
|
.get_matches();
|
||||||
|
|
||||||
match matches.subcommand_name() {
|
match matches.subcommand_name() {
|
||||||
|
@ -99,6 +104,7 @@ fn main() {
|
||||||
Some("reset") => reset(matches),
|
Some("reset") => reset(matches),
|
||||||
Some("show") => show(matches),
|
Some("show") => show(matches),
|
||||||
Some("diff") => difference(matches),
|
Some("diff") => difference(matches),
|
||||||
|
Some("merge") => merge(matches),
|
||||||
_ => println!("unknown sub command"),
|
_ => 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>>) {
|
fn print_commit(oid: String, commit: &base::Commit, mut refs: HashMap<String, Vec<String>>) {
|
||||||
let ref_str = if refs.contains_key(&oid) {
|
let ref_str = if refs.contains_key(&oid) {
|
||||||
refs.get_mut(&oid).unwrap().join(", ")
|
refs.get_mut(&oid).unwrap().join(", ")
|
||||||
|
|
Loading…
Reference in New Issue