forked from kemitix/git-next
feat(server): Implement advancing main branch to the next commit
Closes kemitix/git-next#19
This commit is contained in:
parent
98a94ea855
commit
3a761b5b21
2 changed files with 35 additions and 7 deletions
|
@ -135,15 +135,40 @@ fn find_next_commit_on_dev(
|
||||||
// advance main branch to the commit 'next'
|
// advance main branch to the commit 'next'
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub async fn advance_main(
|
pub async fn advance_main(
|
||||||
_next: forge::Commit,
|
next: forge::Commit,
|
||||||
_repo_details: config::RepoDetails,
|
repo_details: config::RepoDetails,
|
||||||
|
repo_config: config::RepoConfig,
|
||||||
addr: Addr<RepoActor>,
|
addr: Addr<RepoActor>,
|
||||||
_net: network::Network,
|
|
||||||
) {
|
) {
|
||||||
// TODO: (#19) advance main to next
|
|
||||||
info!("Advance Main");
|
info!("Advance Main");
|
||||||
|
let user = repo_details.forge.user;
|
||||||
|
let token = repo_details.forge.token;
|
||||||
|
let hostname = repo_details.forge.hostname;
|
||||||
|
let path = repo_details.repo;
|
||||||
|
let main = repo_config.branches().main();
|
||||||
|
let command =
|
||||||
|
format!("/usr/bin/git push https://{user}:{token}@{hostname}/{path}.git {next}:{main}");
|
||||||
|
info!("Running command: {}", command);
|
||||||
|
match gix::command::prepare(command)
|
||||||
|
.with_shell_allow_argument_splitting()
|
||||||
|
.spawn()
|
||||||
|
{
|
||||||
|
Ok(mut child) => {
|
||||||
|
match child.wait() {
|
||||||
|
Ok(exit_status) => {
|
||||||
|
info!(%exit_status, "Advance Next Success");
|
||||||
addr.do_send(StartRepo);
|
addr.do_send(StartRepo);
|
||||||
}
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!(?err, "Advance Next Failed (wait)")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
warn!(?err, "Advance Next Failed (spawn)")
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -143,9 +143,12 @@ impl Handler<AdvanceMainTo> for RepoActor {
|
||||||
type Result = ();
|
type Result = ();
|
||||||
fn handle(&mut self, msg: AdvanceMainTo, ctx: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: AdvanceMainTo, ctx: &mut Self::Context) -> Self::Result {
|
||||||
let repo_details = self.details.clone();
|
let repo_details = self.details.clone();
|
||||||
|
let Some(repo_config) = self.config.clone() else {
|
||||||
|
warn!("No config loaded");
|
||||||
|
return;
|
||||||
|
};
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let net = self.net.clone();
|
branch::advance_main(msg.0, repo_details, repo_config, addr)
|
||||||
branch::advance_main(msg.0, repo_details, addr, net)
|
|
||||||
.into_actor(self)
|
.into_actor(self)
|
||||||
.wait(ctx);
|
.wait(ctx);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue