-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrebase.rs
More file actions
66 lines (56 loc) · 1.37 KB
/
rebase.rs
File metadata and controls
66 lines (56 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use super::GitCmd;
use std::process::Command;
// FIXME: Add a derive(Builder)
pub struct Rebase {
onto: String,
interactive: bool,
autosquash: bool,
add_missing_prefix: bool,
}
pub fn rebase<T: Into<String>>(onto: T) -> Rebase {
Rebase {
onto: onto.into(),
interactive: false,
autosquash: false,
add_missing_prefix: false,
}
}
impl Rebase {
pub fn interactive(self) -> Rebase {
Rebase {
interactive: true,
..self
}
}
pub fn autosquash(self) -> Rebase {
Rebase {
autosquash: true,
..self
}
}
pub fn add_missing_prefix(self) -> Rebase {
Rebase {
add_missing_prefix: true,
..self
}
}
}
impl GitCmd for Rebase {
fn setup(self, cmd: &mut Command) {
if self.interactive {
cmd.arg("-c").arg("sequence.editor=true");
}
if self.add_missing_prefix {
cmd.arg("-c").arg("core.editor=sed -i '1{/^gccrs: /!s/^/gccrs: /}'");
cmd.arg("-c").arg("sequence.editor=sed -i -e 's/pick/reword/g'");
}
cmd.arg("rebase");
if self.interactive || self.add_missing_prefix {
cmd.arg("--interactive");
}
if self.autosquash {
cmd.arg("--autosquash");
}
cmd.arg(self.onto);
}
}