feat: git: clone, pull and push
This commit is contained in:
parent
bfa92145a9
commit
a3e907027f
1 changed files with 36 additions and 0 deletions
36
src/git.rs
Normal file
36
src/git.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
use url::Url;
|
||||
|
||||
pub struct Git;
|
||||
|
||||
impl Git {
|
||||
pub fn clone(url: &Url, dest: &Path) {
|
||||
let dest = dest.canonicalize().unwrap();
|
||||
let mut child = Command::new("git")
|
||||
.args(["clone", url.as_str()])
|
||||
.current_dir(dest)
|
||||
.spawn()
|
||||
.expect("unable to obtain Docker version");
|
||||
child.wait().unwrap();
|
||||
}
|
||||
|
||||
pub fn pull(dest: &Path, branch: &str) {
|
||||
let dest = dest.canonicalize().unwrap();
|
||||
Command::new("git")
|
||||
.current_dir(dest)
|
||||
.args(["pull", "origin", branch])
|
||||
.spawn()
|
||||
.expect("unable to obtain Docker version");
|
||||
}
|
||||
|
||||
pub fn push(branch: &str, dest: &Path) {
|
||||
let dest = dest.canonicalize().unwrap();
|
||||
let output = Command::new("git")
|
||||
.current_dir(dest)
|
||||
.args(["push", "origin", branch])
|
||||
.spawn()
|
||||
.expect("unable to get logs");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue