fix(builders): prefer unwrap_or to pattern matching

This commit is contained in:
Gabriele Musco 2024-05-13 14:35:53 +02:00
commit c140d191c9
No known key found for this signature in database
GPG key ID: 1068D795C80E51DE
6 changed files with 72 additions and 48 deletions

View file

@ -13,15 +13,21 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.features.basalt.repo.as_ref() { repo: profile
Some(r) => r.clone(), .features
None => "https://gitlab.freedesktop.org/mateosss/basalt.git".into(), .basalt
}, .repo
.as_ref()
.unwrap_or(&"https://gitlab.freedesktop.org/mateosss/basalt.git".into())
.clone(),
dir: profile.features.basalt.path.as_ref().unwrap().clone(), dir: profile.features.basalt.path.as_ref().unwrap().clone(),
branch: match profile.features.basalt.branch.as_ref() { branch: profile
Some(r) => r.clone(), .features
None => "main".into(), .basalt
}, .branch
.as_ref()
.unwrap_or(&"main".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -13,15 +13,21 @@ pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeq
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.features.libsurvive.repo.as_ref() { repo: profile
Some(r) => r.clone(), .features
None => "https://github.com/cntools/libsurvive".into(), .libsurvive
}, .repo
.as_ref()
.unwrap_or(&"https://github.com/cntools/libsurvive".into())
.clone(),
dir: profile.features.libsurvive.path.as_ref().unwrap().clone(), dir: profile.features.libsurvive.path.as_ref().unwrap().clone(),
branch: match profile.features.libsurvive.branch.as_ref() { branch: profile
Some(r) => r.clone(), .features
None => "master".into(), .libsurvive
}, .branch
.as_ref()
.unwrap_or(&"master".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -13,15 +13,17 @@ pub fn get_build_monado_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.xrservice_repo.as_ref() { repo: profile
Some(r) => r.clone(), .xrservice_repo
None => "https://gitlab.freedesktop.org/monado/monado".into(), .as_ref()
}, .unwrap_or(&"https://gitlab.freedesktop.org/monado/monado".into())
.clone(),
dir: profile.xrservice_path.clone(), dir: profile.xrservice_path.clone(),
branch: match profile.xrservice_branch.as_ref() { branch: profile
Some(r) => r.clone(), .xrservice_branch
None => "main".into(), .as_ref()
}, .unwrap_or(&"main".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -13,15 +13,17 @@ pub fn get_build_opencomposite_jobs(profile: &Profile, clean_build: bool) -> Vec
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.opencomposite_repo.as_ref() { repo: profile
Some(r) => r.clone(), .opencomposite_repo
None => "https://gitlab.com/znixian/OpenOVR.git".into(), .as_ref()
}, .unwrap_or(&"https://gitlab.com/znixian/OpenOVR.git".into())
.clone(),
dir: profile.opencomposite_path.clone(), dir: profile.opencomposite_path.clone(),
branch: match profile.opencomposite_branch.as_ref() { branch: profile
Some(r) => r.clone(), .opencomposite_branch
None => "openxr".into(), .as_ref()
}, .unwrap_or(&"openxr".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -13,15 +13,21 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque<
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.features.openhmd.repo.as_ref() { repo: profile
Some(r) => r.clone(), .features
None => "https://github.com/OpenHMD/OpenHMD".into(), .openhmd
}, .repo
.as_ref()
.unwrap_or(&"https://github.com/OpenHMD/OpenHMD".into())
.clone(),
dir: profile.features.openhmd.path.as_ref().unwrap().clone(), dir: profile.features.openhmd.path.as_ref().unwrap().clone(),
branch: match profile.features.openhmd.branch.as_ref() { branch: profile
Some(r) => r.clone(), .features
None => "master".into(), .openhmd
}, .branch
.as_ref()
.unwrap_or(&"master".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));

View file

@ -13,15 +13,17 @@ pub fn get_build_wivrn_jobs(profile: &Profile, clean_build: bool) -> VecDeque<Wo
let mut jobs = VecDeque::<WorkerJob>::new(); let mut jobs = VecDeque::<WorkerJob>::new();
let git = Git { let git = Git {
repo: match profile.xrservice_repo.as_ref() { repo: profile
Some(r) => r.clone(), .xrservice_repo
None => "https://github.com/Meumeu/WiVRn".into(), .as_ref()
}, .unwrap_or(&"https://github.com/Meumeu/WiVRn".into())
.clone(),
dir: profile.xrservice_path.clone(), dir: profile.xrservice_path.clone(),
branch: match profile.xrservice_branch.as_ref() { branch: profile
Some(r) => r.clone(), .xrservice_branch
None => "master".into(), .as_ref()
}, .unwrap_or(&"master".into())
.clone(),
}; };
jobs.extend(git.get_pre_build_jobs(profile.pull_on_build)); jobs.extend(git.get_pre_build_jobs(profile.pull_on_build));