feat: Remove branches when fetching from remote
All checks were successful
Rust / build (push) Successful in 6m9s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m30s
All checks were successful
Rust / build (push) Successful in 6m9s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m30s
This commit is contained in:
parent
3ea7f36c98
commit
048111202a
14 changed files with 32 additions and 38 deletions
|
@ -41,7 +41,7 @@ impl Handler<AdvanceMain> for RepoActor {
|
|||
} else {
|
||||
self.update_tui(RepoUpdate::MainUpdated);
|
||||
if let Some(open_repository) = &self.open_repository {
|
||||
match open_repository.fetch(&repo_details) {
|
||||
match open_repository.fetch() {
|
||||
Ok(()) => self.update_tui_log(git::graph::log(&self.repo_details)),
|
||||
Err(err) => self.alert_tui(format!("fetching: {err}")),
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ impl Handler<AdvanceNext> for RepoActor {
|
|||
) {
|
||||
Ok(message_token) => {
|
||||
self.update_tui(RepoUpdate::NextUpdated);
|
||||
match open_repository.fetch(&repo_details) {
|
||||
match open_repository.fetch() {
|
||||
Ok(()) => self.update_tui_log(git::graph::log(&self.repo_details)),
|
||||
Err(err) => self.alert_tui(format!("fetching: {err}")),
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ pub fn fetch(open_repository: &mut MockOpenRepositoryLike, result: Result<(), fe
|
|||
open_repository
|
||||
.expect_fetch()
|
||||
.times(1)
|
||||
.return_once(|_| result);
|
||||
.return_once(|| result);
|
||||
}
|
||||
|
||||
pub fn push_ok(open_repository: &mut MockOpenRepositoryLike) {
|
||||
|
|
|
@ -19,7 +19,7 @@ async fn when_repo_config_should_fetch_then_push_then_revalidate() -> TestResult
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
open_repository
|
||||
.expect_push()
|
||||
.times(1)
|
||||
|
@ -29,7 +29,7 @@ async fn when_repo_config_should_fetch_then_push_then_revalidate() -> TestResult
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
|
||||
//when
|
||||
let (addr, log) = when::start_actor_with_open_repository(
|
||||
|
@ -69,7 +69,7 @@ async fn when_app_config_should_fetch_then_push_then_revalidate() -> TestResult
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
open_repository
|
||||
.expect_push()
|
||||
.times(1)
|
||||
|
@ -79,7 +79,7 @@ async fn when_app_config_should_fetch_then_push_then_revalidate() -> TestResult
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
|
||||
//when
|
||||
let (addr, log) = when::start_actor_with_open_repository(
|
||||
|
|
|
@ -22,7 +22,7 @@ async fn should_fetch_then_push_then_revalidate() -> TestResult {
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
open_repository
|
||||
.expect_push()
|
||||
.times(1)
|
||||
|
@ -32,7 +32,7 @@ async fn should_fetch_then_push_then_revalidate() -> TestResult {
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.return_once(|_| Ok(()));
|
||||
.return_once(|| Ok(()));
|
||||
|
||||
//when
|
||||
let (addr, log) = when::start_actor_with_open_repository(
|
||||
|
|
|
@ -486,7 +486,7 @@ async fn should_send_validate_repo_when_retryable_error() -> TestResult {
|
|||
//given
|
||||
let fs = given::a_filesystem();
|
||||
let (mut open_repository, repo_details) = given::an_open_repository(&fs);
|
||||
open_repository.expect_fetch().return_once(|_| Ok(()));
|
||||
open_repository.expect_fetch().return_once(|| Ok(()));
|
||||
open_repository
|
||||
.expect_commit_log()
|
||||
.return_once(|_, _| Err(git::commit::log::Error::Lock));
|
||||
|
@ -517,7 +517,7 @@ async fn should_send_notify_user_when_non_retryable_error() -> TestResult {
|
|||
let (mut open_repository, repo_details) = given::an_open_repository(&fs);
|
||||
#[allow(clippy::unwrap_used)]
|
||||
let repo_config = repo_details.repo_config.clone().unwrap();
|
||||
open_repository.expect_fetch().return_once(|_| Ok(()));
|
||||
open_repository.expect_fetch().return_once(|| Ok(()));
|
||||
|
||||
// branches are all unrelated - non-retryable until each branch is updated
|
||||
let branches = repo_config.branches();
|
||||
|
|
|
@ -61,6 +61,6 @@ pub fn reset(
|
|||
to_commit: &git::GitRef,
|
||||
force: &git::push::Force,
|
||||
) -> Result<()> {
|
||||
open_repository.fetch(repo_details)?;
|
||||
open_repository.fetch()?;
|
||||
open_repository.push(repo_details, branch_name, to_commit, force)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ pub trait OpenRepositoryLike: std::fmt::Debug + Sync {
|
|||
///
|
||||
/// Will return an `Err` if their is no remote fetch defined in .git/config, or
|
||||
/// if there are any network connectivity issues with the remote server.
|
||||
fn fetch(&self, repo_details: &git::RepoDetails) -> Result<(), git::fetch::Error>;
|
||||
fn fetch(&self) -> Result<(), git::fetch::Error>;
|
||||
|
||||
/// Performs a `git push`
|
||||
///
|
||||
|
|
|
@ -66,23 +66,17 @@ impl super::OpenRepositoryLike for RealOpenRepository {
|
|||
|
||||
#[tracing::instrument(skip_all)]
|
||||
#[cfg(not(tarpaulin_include))] // would require writing to external service
|
||||
fn fetch(&self, repo_details: &git::RepoDetails) -> Result<(), git::fetch::Error> {
|
||||
use secrecy::ExposeSecret;
|
||||
|
||||
let origin = repo_details.origin();
|
||||
let command: secrecy::Secret<String> =
|
||||
format!("/usr/bin/git fetch {}", origin.expose_secret()).into();
|
||||
let git_dir = self
|
||||
.inner
|
||||
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
||||
gix::command::prepare("/usr/bin/git fetch --prune")
|
||||
.with_context(gix::diff::command::Context {
|
||||
git_dir: Some(
|
||||
self.inner
|
||||
.read()
|
||||
.map_err(|_| git::fetch::Error::Lock)
|
||||
.map(|r| r.git_dir().to_path_buf())?;
|
||||
let ctx = gix::diff::command::Context {
|
||||
git_dir: Some(git_dir),
|
||||
.map(|r| r.git_dir().to_path_buf())?,
|
||||
),
|
||||
..Default::default()
|
||||
};
|
||||
gix::command::prepare(command.expose_secret())
|
||||
.with_context(ctx)
|
||||
})
|
||||
.with_shell_allow_argument_splitting()
|
||||
.stdout(std::process::Stdio::null())
|
||||
.stderr(std::process::Stdio::null())
|
||||
|
|
|
@ -94,7 +94,7 @@ impl git::repository::OpenRepositoryLike for TestOpenRepository {
|
|||
self.real.find_default_remote(direction)
|
||||
}
|
||||
|
||||
fn fetch(&self, _repo_details: &git::RepoDetails) -> Result<(), git::fetch::Error> {
|
||||
fn fetch(&self) -> Result<(), git::fetch::Error> {
|
||||
let i: usize = *self
|
||||
.fetch_counter
|
||||
.read()
|
||||
|
|
|
@ -9,5 +9,5 @@ fn should_fetch_from_repo() {
|
|||
let gitdir = GitDir::new(cwd.join("../.."), StoragePathType::External);
|
||||
let repo_details = given::repo_details(&given::a_filesystem()).with_gitdir(gitdir);
|
||||
let_assert!(Ok(repo) = crate::git::repository::factory::real().open(&repo_details));
|
||||
let_assert!(Ok(()) = repo.fetch(&repo_details));
|
||||
let_assert!(Ok(()) = repo.fetch());
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ mod push {
|
|||
.expect_fetch()
|
||||
.times(1)
|
||||
.in_sequence(&mut seq)
|
||||
.returning(|_| Ok(()));
|
||||
.returning(|| Ok(()));
|
||||
open_repository
|
||||
.expect_push()
|
||||
.times(1)
|
||||
|
|
|
@ -33,7 +33,7 @@ pub fn validate(
|
|||
let next_branch = repo_config.branches().next();
|
||||
let dev_branch = repo_config.branches().dev();
|
||||
// Collect Commit Histories for `main`, `next` and `dev` branches
|
||||
open_repository.fetch(repo_details)?;
|
||||
open_repository.fetch()?;
|
||||
let git_log = git::graph::log(repo_details);
|
||||
|
||||
let commit_histories = get_commit_histories(open_repository, repo_config)?;
|
||||
|
|
|
@ -64,7 +64,7 @@ mod positions {
|
|||
let mut mock_open_repository = git::repository::open::mock();
|
||||
mock_open_repository
|
||||
.expect_fetch()
|
||||
.return_once(|_| Err(git::fetch::Error::TestFailureExpected));
|
||||
.return_once(|| Err(git::fetch::Error::TestFailureExpected));
|
||||
let mut repository_factory = git::repository::factory::mock();
|
||||
repository_factory
|
||||
.expect_open()
|
||||
|
@ -93,7 +93,7 @@ mod positions {
|
|||
let repo_config = given::a_repo_config();
|
||||
let main_branch = repo_config.branches().main();
|
||||
let mut mock_open_repository = git::repository::open::mock();
|
||||
mock_open_repository.expect_fetch().return_once(|_| Ok(()));
|
||||
mock_open_repository.expect_fetch().return_once(|| Ok(()));
|
||||
mock_open_repository
|
||||
.expect_commit_log()
|
||||
.returning(move |branch_name, _| {
|
||||
|
@ -132,7 +132,7 @@ mod positions {
|
|||
let repo_config = given::a_repo_config();
|
||||
let next_branch = repo_config.branches().next();
|
||||
let mut mock_open_repository = git::repository::open::mock();
|
||||
mock_open_repository.expect_fetch().return_once(|_| Ok(()));
|
||||
mock_open_repository.expect_fetch().return_once(|| Ok(()));
|
||||
mock_open_repository
|
||||
.expect_commit_log()
|
||||
.returning(move |branch_name, _| {
|
||||
|
@ -171,7 +171,7 @@ mod positions {
|
|||
let repo_config = given::a_repo_config();
|
||||
let dev_branch = repo_config.branches().dev();
|
||||
let mut mock_open_repository = git::repository::open::mock();
|
||||
mock_open_repository.expect_fetch().return_once(|_| Ok(()));
|
||||
mock_open_repository.expect_fetch().return_once(|| Ok(()));
|
||||
mock_open_repository
|
||||
.expect_commit_log()
|
||||
.returning(move |branch_name, _| {
|
||||
|
|
Loading…
Reference in a new issue