mirror of
https://gitlab.com/gabmus/envision.git
synced 2025-04-22 20:44:50 +00:00
fix: better pull/checkout strategy with fetch, checkout and merge
This commit is contained in:
parent
642d23386a
commit
bfd374fe81
7 changed files with 36 additions and 44 deletions
|
@ -12,6 +12,12 @@ pub struct Git {
|
|||
}
|
||||
|
||||
impl Git {
|
||||
fn cmd(&self, args: Vec<String>) -> WorkerJob {
|
||||
let mut nargs = vec!["-C".into(), self.dir.clone()];
|
||||
nargs.extend(args);
|
||||
WorkerJob::new_cmd(None, "git".into(), Some(nargs))
|
||||
}
|
||||
|
||||
fn get_repo(&self) -> String {
|
||||
self.repo
|
||||
.split('#')
|
||||
|
@ -27,16 +33,7 @@ impl Git {
|
|||
}
|
||||
|
||||
pub fn get_reset_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
"git".into(),
|
||||
Some(vec![
|
||||
"-C".into(),
|
||||
self.dir.clone(),
|
||||
"reset".into(),
|
||||
"--hard".into(),
|
||||
]),
|
||||
)
|
||||
self.cmd(vec!["reset".into(), "--hard".into()])
|
||||
}
|
||||
|
||||
pub fn get_override_remote_url_job(&self) -> WorkerJob {
|
||||
|
@ -75,12 +72,13 @@ impl Git {
|
|||
}))
|
||||
}
|
||||
|
||||
pub fn get_pull_job(&self) -> WorkerJob {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
"git".into(),
|
||||
Some(vec!["-C".into(), self.dir.clone(), "pull".into()]),
|
||||
)
|
||||
pub fn get_pull_jobs(&self) -> Vec<WorkerJob> {
|
||||
let mut res = vec![self.cmd(vec!["fetch".into()])];
|
||||
if let Some(checkout_j) = self.get_checkout_ref_job() {
|
||||
res.push(checkout_j);
|
||||
}
|
||||
res.push(self.cmd(vec!["merge".into()]));
|
||||
res
|
||||
}
|
||||
|
||||
pub fn get_clone_job(&self) -> WorkerJob {
|
||||
|
@ -97,13 +95,7 @@ impl Git {
|
|||
}
|
||||
|
||||
pub fn get_checkout_ref_job(&self) -> Option<WorkerJob> {
|
||||
self.get_ref().map(|r| {
|
||||
WorkerJob::new_cmd(
|
||||
None,
|
||||
"git".into(),
|
||||
Some(vec!["-C".into(), self.dir.clone(), "checkout".into(), r]),
|
||||
)
|
||||
})
|
||||
self.get_ref().map(|r| self.cmd(vec!["checkout".into(), r]))
|
||||
}
|
||||
|
||||
pub fn get_clone_or_not_job(&self) -> Option<WorkerJob> {
|
||||
|
@ -115,11 +107,11 @@ impl Git {
|
|||
Some(self.get_clone_job())
|
||||
}
|
||||
|
||||
pub fn get_clone_or_pull_job(&self, profile: &Profile) -> Option<WorkerJob> {
|
||||
pub fn get_clone_or_pull_jobs(&self, profile: &Profile) -> Option<Vec<WorkerJob>> {
|
||||
match self.get_clone_or_not_job() {
|
||||
Some(j) => Some(j),
|
||||
Some(j) => Some(vec![j]),
|
||||
None => match profile.pull_on_build {
|
||||
true => Some(self.get_pull_job()),
|
||||
true => Some(self.get_pull_jobs().into()),
|
||||
false => None,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -22,14 +22,14 @@ pub fn get_build_basalt_jobs(profile: &Profile, clean_build: bool) -> VecDeque<W
|
|||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ pub fn get_build_libsurvive_jobs(profile: &Profile, clean_build: bool) -> VecDeq
|
|||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ pub fn get_build_monado_jobs(
|
|||
};
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ pub fn get_build_opencomposite_jobs(profile: &Profile, clean_build: bool) -> Vec
|
|||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ pub fn get_build_openhmd_jobs(profile: &Profile, clean_build: bool) -> VecDeque<
|
|||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -26,14 +26,14 @@ pub fn get_build_wivrn_jobs(
|
|||
|
||||
jobs.push_back(git.get_override_remote_url_job());
|
||||
|
||||
git.get_clone_or_pull_job(profile).map(|j| {
|
||||
jobs.push_back(j);
|
||||
git.get_clone_or_pull_jobs(profile).map(|j| {
|
||||
jobs.extend(j);
|
||||
});
|
||||
|
||||
git.get_checkout_ref_job().map(|j| {
|
||||
jobs.push_back(j);
|
||||
if profile.pull_on_build {
|
||||
jobs.push_back(git.get_pull_job());
|
||||
jobs.extend(git.get_pull_jobs());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue