Skip to content

Commit 2ae38b5

Browse files
committed
style: apply stable rustfmt formatting
1 parent baa8aff commit 2ae38b5

File tree

6 files changed

+55
-34
lines changed

6 files changed

+55
-34
lines changed

src/cli/clean/mod.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ pub(crate) fn format_clean_plan(plan: &CleanPlan) -> String {
7979
let mut sections = Vec::new();
8080

8181
if !deleted_candidates.is_empty() {
82-
let mut lines = vec!["Tracked branches missing locally and ready to stop tracking:".to_string()];
82+
let mut lines =
83+
vec!["Tracked branches missing locally and ready to stop tracking:".to_string()];
8384

8485
for candidate in deleted_candidates {
85-
lines.push(format!("- {} no longer exists locally", candidate.branch_name));
86+
lines.push(format!(
87+
"- {} no longer exists locally",
88+
candidate.branch_name
89+
));
8690

8791
for restack in &candidate.restack_plan {
8892
lines.push(format!(
@@ -166,8 +170,16 @@ fn format_blocked_branch(blocked: &crate::core::clean::BlockedBranch) -> String
166170
pub(crate) fn confirm_cleanup(plan: &CleanPlan) -> io::Result<bool> {
167171
let missing_count = plan.deleted_local_count();
168172
let merged_count = plan.merged_count();
169-
let merged_label = if merged_count == 1 { "branch" } else { "branches" };
170-
let missing_label = if missing_count == 1 { "branch" } else { "branches" };
173+
let merged_label = if merged_count == 1 {
174+
"branch"
175+
} else {
176+
"branches"
177+
};
178+
let missing_label = if missing_count == 1 {
179+
"branch"
180+
} else {
181+
"branches"
182+
};
171183

172184
let prompt = match (missing_count, merged_count) {
173185
(0, merged) => format!("Delete {merged} merged {merged_label}? [y/N] "),

src/cli/operation/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ pub fn render_sections(sections: &[OperationSection], final_view: bool) -> Strin
149149
fn render_section(section: &OperationSection, final_view: bool) -> String {
150150
let roots = if final_view
151151
&& section.promote_children_on_deleted_root
152-
&& matches!(section.root.status, BranchStatus::Deleted | BranchStatus::Archived)
153-
{
152+
&& matches!(
153+
section.root.status,
154+
BranchStatus::Deleted | BranchStatus::Archived
155+
) {
154156
section.root.children.as_slice()
155157
} else {
156158
std::slice::from_ref(&section.root)

src/core/clean/apply.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use crate::core::git;
55
use crate::core::graph::BranchGraph;
66
use crate::core::restack;
77
use crate::core::store::{
8-
BranchArchiveReason,
9-
PendingCleanCandidate, PendingCleanCandidateKind, PendingCleanOperation, PendingOperationKind,
10-
PendingOperationState, open_initialized, record_branch_archived,
8+
BranchArchiveReason, PendingCleanCandidate, PendingCleanCandidateKind, PendingCleanOperation,
9+
PendingOperationKind, PendingOperationState, open_initialized, record_branch_archived,
1110
};
1211
use crate::core::workflow::{self, RestackExecutionEvent};
1312

@@ -308,8 +307,8 @@ where
308307
)?,
309308
)?,
310309
PendingCleanCandidateKind::IntegratedIntoParent => {
311-
let Some(parent_branch_name) =
312-
BranchGraph::new(&session.state).parent_branch_name(&node, &session.config.trunk_branch)
310+
let Some(parent_branch_name) = BranchGraph::new(&session.state)
311+
.parent_branch_name(&node, &session.config.trunk_branch)
313312
else {
314313
return Err(io::Error::other(format!(
315314
"tracked parent for '{}' is missing from dig",
@@ -422,12 +421,16 @@ where
422421
}
423422
}
424423

425-
fn pending_clean_candidate_from_clean_candidate(candidate: &CleanCandidate) -> PendingCleanCandidate {
424+
fn pending_clean_candidate_from_clean_candidate(
425+
candidate: &CleanCandidate,
426+
) -> PendingCleanCandidate {
426427
PendingCleanCandidate {
427428
branch_name: candidate.branch_name.clone(),
428429
kind: match &candidate.reason {
429430
CleanReason::DeletedLocally => PendingCleanCandidateKind::DeletedLocally,
430-
CleanReason::IntegratedIntoParent { .. } => PendingCleanCandidateKind::IntegratedIntoParent,
431+
CleanReason::IntegratedIntoParent { .. } => {
432+
PendingCleanCandidateKind::IntegratedIntoParent
433+
}
431434
},
432435
}
433436
}

src/core/clean/plan.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@ fn plan_for_requested_branch(
6262
};
6363

6464
if !git::branch_exists(&node.branch_name)? {
65-
let candidates = deleted_local::collect_deleted_local_subtree_steps(
66-
state,
67-
trunk_branch,
68-
node.id,
69-
)?
70-
.into_iter()
71-
.map(clean_candidate_from_deleted_step)
72-
.collect();
65+
let candidates =
66+
deleted_local::collect_deleted_local_subtree_steps(state, trunk_branch, node.id)?
67+
.into_iter()
68+
.map(clean_candidate_from_deleted_step)
69+
.collect();
7370

7471
return Ok(CleanPlan {
7572
trunk_branch: trunk_branch.to_string(),
@@ -236,7 +233,9 @@ fn evaluate_integrated_branch(
236233
}))
237234
}
238235

239-
fn clean_candidate_from_deleted_step(step: deleted_local::DeletedLocalBranchStep) -> CleanCandidate {
236+
fn clean_candidate_from_deleted_step(
237+
step: deleted_local::DeletedLocalBranchStep,
238+
) -> CleanCandidate {
240239
CleanCandidate {
241240
node_id: step.node_id,
242241
branch_name: step.branch_name,

src/core/deleted_local.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use std::io;
22

33
use uuid::Uuid;
44

5+
use crate::core::git;
56
use crate::core::graph::{BranchGraph, BranchTreeNode};
67
use crate::core::restack::{self, RestackAction, RestackPreview};
78
use crate::core::store::types::DigState;
89
use crate::core::store::{BranchArchiveReason, ParentRef, StoreSession, record_branch_archived};
9-
use crate::core::git;
1010

1111
#[derive(Debug, Clone, PartialEq, Eq)]
1212
pub(crate) struct DeletedLocalBranchStep {
@@ -95,7 +95,9 @@ fn collect_deleted_local_steps_with_scope(
9595
let mut simulated_state = state.clone();
9696
let mut steps = Vec::new();
9797

98-
while let Some(step) = next_deleted_local_step_with_scope(&simulated_state, trunk_branch, scope)? {
98+
while let Some(step) =
99+
next_deleted_local_step_with_scope(&simulated_state, trunk_branch, scope)?
100+
{
99101
simulate_deleted_local_step(&mut simulated_state, &step)?;
100102
steps.push(step);
101103
}
@@ -117,7 +119,11 @@ fn next_deleted_local_step_with_scope(
117119
};
118120

119121
if !git::branch_exists(&node.branch_name)? {
120-
missing_nodes.push((graph.branch_depth(node.id), node.branch_name.clone(), node.id));
122+
missing_nodes.push((
123+
graph.branch_depth(node.id),
124+
node.branch_name.clone(),
125+
node.id,
126+
));
121127
}
122128
}
123129

@@ -154,9 +160,10 @@ fn plan_deleted_local_step(
154160
trunk_branch: &str,
155161
node_id: Uuid,
156162
) -> io::Result<DeletedLocalBranchStep> {
157-
let node = state.find_branch_by_id(node_id).cloned().ok_or_else(|| {
158-
io::Error::new(io::ErrorKind::NotFound, "tracked branch was not found")
159-
})?;
163+
let node = state
164+
.find_branch_by_id(node_id)
165+
.cloned()
166+
.ok_or_else(|| io::Error::new(io::ErrorKind::NotFound, "tracked branch was not found"))?;
160167
let graph = BranchGraph::new(state);
161168
let (new_parent_branch_name, new_parent) =
162169
resolve_replacement_parent(state, trunk_branch, &node.parent)?;

tests/clean.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ fn clean_untracks_deleted_middle_branch_and_restacks_descendants() {
2222
let stdout = strip_ansi(&String::from_utf8(output.stdout).unwrap());
2323

2424
assert!(output.status.success());
25-
assert!(stdout.contains(
26-
"Tracked branches missing locally and ready to stop tracking:"
27-
));
25+
assert!(stdout.contains("Tracked branches missing locally and ready to stop tracking:"));
2826
assert!(stdout.contains("Stop tracking 1 missing branch? [y/N]"));
2927
assert!(stdout.contains("No longer tracked by dig:"));
3028
assert!(stdout.contains("- feat/auth"));
@@ -96,9 +94,9 @@ fn clean_untracks_missing_branches_before_cleaning_newly_unblocked_merged_parent
9694
let stdout = strip_ansi(&String::from_utf8(output.stdout).unwrap());
9795

9896
assert!(output.status.success());
99-
assert!(stdout.contains(
100-
"Delete 1 merged branch and stop tracking 1 missing branch? [y/N]"
101-
));
97+
assert!(
98+
stdout.contains("Delete 1 merged branch and stop tracking 1 missing branch? [y/N]")
99+
);
102100
assert!(stdout.contains("No longer tracked by dig:"));
103101
assert!(stdout.contains("- feat/users"));
104102
assert!(stdout.contains("Deleted:"));

0 commit comments

Comments
 (0)