Skip to content

Commit 35e68dd

Browse files
committed
refactor: remove dead RemoteChange::CreatePr variant
Sync no longer auto-creates PRs (users create them explicitly with `git stack pr`), so the CreatePr variant and its handler/printer were unreachable. Drops the now-unused CreatePrRequest import and prunes apply_remote_change parameters that only CreatePr needed.
1 parent 46555ab commit 35e68dd

File tree

1 file changed

+4
-69
lines changed

1 file changed

+4
-69
lines changed

src/sync.rs

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use crate::{
2222
git::{git_trunk, run_git},
2323
git2_ops::{DEFAULT_REMOTE, GitRepo},
2424
github::{
25-
CreatePrRequest,
2625
GitHubClient,
2726
PrState,
2827
PullRequest,
@@ -160,12 +159,6 @@ pub enum LocalChange {
160159
/// Changes to apply to remote state (GitHub)
161160
#[derive(Debug, Clone)]
162161
pub enum RemoteChange {
163-
/// Create a new PR
164-
CreatePr {
165-
branch: String,
166-
base: String,
167-
title: String,
168-
},
169162
/// Retarget a PR to a different base
170163
RetargetPr {
171164
number: u64,
@@ -986,11 +979,8 @@ fn compute_sync_plan(
986979
new_base: expected_base.clone(),
987980
});
988981
}
989-
// No open PR but branch is pushed - don't auto-create PRs
990-
// Users should create PRs explicitly with `git stack pr`
991-
(None, Some(_expected_base)) => {
992-
continue;
993-
}
982+
// No open PR: don't auto-create PRs during sync.
983+
// Users create PRs explicitly with `git stack pr`.
994984
_ => {}
995985
}
996986
}
@@ -1236,9 +1226,9 @@ fn apply_plan(
12361226
// Save state after local changes
12371227
state.save_state()?;
12381228

1239-
// Apply remote changes (create PRs, retarget)
1229+
// Apply remote changes (retarget PRs, push intermediate branches)
12401230
for change in &plan.remote_changes {
1241-
apply_remote_change(git_repo, state, repo, client, repo_id, change)?;
1231+
apply_remote_change(client, repo_id, change)?;
12421232
}
12431233

12441234
// Save state again if PR numbers were updated
@@ -1385,59 +1375,11 @@ fn apply_local_change(
13851375

13861376
/// Apply a single remote change
13871377
fn apply_remote_change(
1388-
git_repo: &GitRepo,
1389-
state: &mut State,
1390-
repo: &str,
13911378
client: &GitHubClient,
13921379
repo_id: &RepoIdentifier,
13931380
change: &RemoteChange,
13941381
) -> Result<()> {
13951382
match change {
1396-
RemoteChange::CreatePr {
1397-
branch,
1398-
base,
1399-
title,
1400-
} => {
1401-
println!(
1402-
" Creating PR for '{}' (base: '{}')",
1403-
branch.yellow(),
1404-
base.green()
1405-
);
1406-
1407-
// Get a better title from the first commit
1408-
// Use --no-show-signature to avoid GPG signature output polluting the title
1409-
let commit_title =
1410-
run_git(&["log", "--no-show-signature", "--format=%s", "-1", branch])
1411-
.ok()
1412-
.and_then(|r| r.output())
1413-
.unwrap_or_else(|| title.clone());
1414-
1415-
let pr = client
1416-
.create_pr(
1417-
repo_id,
1418-
CreatePrRequest {
1419-
title: &commit_title,
1420-
body: "",
1421-
head: branch,
1422-
base,
1423-
draft: Some(true),
1424-
},
1425-
)
1426-
.map_err(|e| anyhow!("{}", e))?;
1427-
1428-
println!(
1429-
" Created PR #{}: {}",
1430-
pr.number.to_string().green(),
1431-
pr.html_url.blue()
1432-
);
1433-
1434-
// Update the cached PR number
1435-
if let Some(tree) = state.get_tree_mut(repo)
1436-
&& let Some(b) = find_branch_by_name_mut(tree, branch)
1437-
{
1438-
b.pr_number = Some(pr.number);
1439-
}
1440-
}
14411383
RemoteChange::RetargetPr {
14421384
number,
14431385
branch,
@@ -1538,13 +1480,6 @@ fn print_plan(plan: &SyncPlan, dry_run: bool) {
15381480
println!(" Remote changes:");
15391481
for change in &plan.remote_changes {
15401482
match change {
1541-
RemoteChange::CreatePr { branch, base, .. } => {
1542-
println!(
1543-
" - Create PR for '{}' (base: '{}')",
1544-
branch.yellow(),
1545-
base.green()
1546-
);
1547-
}
15481483
RemoteChange::RetargetPr {
15491484
number,
15501485
branch,

0 commit comments

Comments
 (0)