feat: add ability to specify ref in repo urls

This commit is contained in:
Gabriele Musco 2023-08-15 14:19:53 +00:00
parent 625602a6cf
commit 5420a2e975
7 changed files with 86 additions and 5 deletions

View file

@ -9,6 +9,23 @@ pub struct Git {
}
impl Git {
fn get_repo(&self) -> String {
self.repo
.split('#')
.next()
.expect("Could not get repo url")
.into()
}
fn get_ref(&self) -> Option<String> {
let mut split = self.repo.split('#');
split.next().expect("Could not get repo url");
match split.next() {
None => None,
Some(s) => Some(s.into()),
}
}
pub fn get_reset_runner(&self) -> Runner {
Runner::new(
None,
@ -34,10 +51,26 @@ impl Git {
Runner::new(
None,
"git".into(),
vec!["clone".into(), self.repo.clone(), self.dir.clone(), "--recurse-submodules".into()],
vec![
"clone".into(),
self.get_repo(),
self.dir.clone(),
"--recurse-submodules".into(),
],
)
}
pub fn get_checkout_ref_runner(&self) -> Option<Runner> {
match self.get_ref() {
Some(r) => Some(Runner::new(
None,
"git".into(),
vec!["-C".into(), self.dir.clone(), "checkout".into(), r],
)),
None => None,
}
}
pub fn get_clone_or_not_runner(&self) -> Option<Runner> {
let path_s = format!("{}/.git", self.dir.clone());
let path = Path::new(&path_s);

View file

@ -19,6 +19,15 @@ pub fn get_build_basalt_runners(profile: &Profile, clean_build: bool) -> Vec<Run
Some(r) => runners.push(r),
None => {}
};
match git.get_checkout_ref_runner() {
Some(r) => {
runners.push(r);
if profile.pull_on_build {
runners.push(git.get_pull_runner());
}
}
None => {}
}
let build_dir = format!("{}/build", profile.features.basalt.path.as_ref().unwrap());
let mut cmake_vars: HashMap<String, String> = HashMap::new();

View file

@ -19,6 +19,15 @@ pub fn get_build_libsurvive_runners(profile: &Profile, clean_build: bool) -> Vec
Some(r) => runners.push(r),
None => {}
};
match git.get_checkout_ref_runner() {
Some(r) => {
runners.push(r);
if profile.pull_on_build {
runners.push(git.get_pull_runner());
}
}
None => {}
}
let build_dir = format!(
"{}/build",

View file

@ -19,6 +19,15 @@ pub fn get_build_monado_runners(profile: &Profile, clean_build: bool) -> Vec<Run
Some(r) => runners.push(r),
None => {}
};
match git.get_checkout_ref_runner() {
Some(r) => {
runners.push(r);
if profile.pull_on_build {
runners.push(git.get_pull_runner());
}
}
None => {}
}
let build_dir = format!("{}/build", profile.xrservice_path);
let mut env: HashMap<String, String> = HashMap::new();

View file

@ -19,6 +19,15 @@ pub fn get_build_opencomposite_runners(profile: &Profile, clean_build: bool) ->
Some(r) => runners.push(r),
None => {}
};
match git.get_checkout_ref_runner() {
Some(r) => {
runners.push(r);
if profile.pull_on_build {
runners.push(git.get_pull_runner());
}
}
None => {}
}
let build_dir = format!("{}/build", profile.opencomposite_path);
let mut cmake_vars: HashMap<String, String> = HashMap::new();

View file

@ -19,6 +19,15 @@ pub fn get_build_wivrn_runners(profile: &Profile, clean_build: bool) -> Vec<Runn
Some(r) => runners.push(r),
None => {}
};
match git.get_checkout_ref_runner() {
Some(r) => {
runners.push(r);
if profile.pull_on_build {
runners.push(git.get_pull_runner());
}
}
None => {}
}
let build_dir = format!("{}/build", profile.xrservice_path);
let mut cmake_vars: HashMap<String, String> = HashMap::new();

View file

@ -90,6 +90,7 @@ impl SimpleComponent for ProfileEditor {
},
add: xrservicegrp = &adw::PreferencesGroup {
set_title: "XR Service",
set_description: Some("When specifying a repository, you can set a specific git ref (branch, tag, commit...) by appending a '#' followed by the ref"),
add: {
withclones![prof];
&combo_row(
@ -151,7 +152,7 @@ impl SimpleComponent for ProfileEditor {
},
add: opencompgrp = &adw::PreferencesGroup {
set_title: "OpenComposite",
set_description: Some("OpenVR driver built on top of OpenXR"),
set_description: Some("OpenVR driver built on top of OpenXR\n\nWhen specifying a repository, you can set a specific git ref (branch, tag, commit...) by appending a '#' followed by the ref"),
add: {
withclones![prof];
&path_row(
@ -177,7 +178,7 @@ impl SimpleComponent for ProfileEditor {
},
add: libsurvivegrp = &adw::PreferencesGroup {
set_title: "Libsurvive",
set_description: Some("Lighthouse tracking driver"),
set_description: Some("Lighthouse tracking driver\n\nWhen specifying a repository, you can set a specific git ref (branch, tag, commit...) by appending a '#' followed by the ref"),
add: {
withclones![prof];
&switch_row(
@ -214,7 +215,7 @@ impl SimpleComponent for ProfileEditor {
},
add: basaltgrp = &adw::PreferencesGroup {
set_title: "Basalt",
set_description: Some("Camera based SLAM tracking driver"),
set_description: Some("Camera based SLAM tracking driver\n\nWhen specifying a repository, you can set a specific git ref (branch, tag, commit...) by appending a '#' followed by the ref"),
add: {
withclones![prof];
&switch_row(
@ -294,7 +295,9 @@ impl SimpleComponent for ProfileEditor {
Self::Input::SaveProfile => {
let prof = self.profile.borrow();
if prof.validate() {
sender.output(ProfileEditorOutMsg::SaveProfile(prof.clone())).expect("Sender output failed");
sender
.output(ProfileEditorOutMsg::SaveProfile(prof.clone()))
.expect("Sender output failed");
self.win.as_ref().unwrap().close();
} else {
self.win.as_ref().unwrap().add_toast(