Skip to content

Commit 8a6047a

Browse files
committed
updates
1 parent c45599b commit 8a6047a

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

src/main.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -792,17 +792,30 @@ fn handle_pr_command(
792792

793793
let base_branch = &parent.name;
794794

795-
// Check if branch is pushed
796-
if !git_repo.shas_match(
797-
&format!("{DEFAULT_REMOTE}/{}", branch_name),
798-
&branch_name,
799-
) {
795+
// Check if this is the trunk branch (can't create PR for main)
796+
let trunk = crate::git::git_trunk(git_repo)?;
797+
if branch_name == trunk.main_branch {
800798
bail!(
801-
"Branch '{}' is not synced with remote. Run `git stack restack -p` first.",
799+
"Cannot create a PR for the trunk branch '{}'.",
802800
branch_name.yellow()
803801
);
804802
}
805803

804+
// Check if branch exists on remote, push if not
805+
let remote_ref = format!("{DEFAULT_REMOTE}/{}", branch_name);
806+
if !git_repo.branch_exists(&remote_ref) {
807+
println!(
808+
"Branch '{}' is not on remote. Pushing...",
809+
branch_name.yellow()
810+
);
811+
git::run_git(&[
812+
"push",
813+
"-u",
814+
DEFAULT_REMOTE,
815+
&format!("{}:{}", branch_name, branch_name),
816+
])?;
817+
}
818+
806819
// Check if PR already exists
807820
if let Some(existing_pr) = client.find_pr_for_branch(&repo_id, &branch_name)? {
808821
println!(

src/state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl State {
100100

101101
pub fn save_state(&self) -> Result<()> {
102102
let config_path = get_xdg_path()?;
103-
tracing::debug!(?self, ?config_path, "Saving state to config file");
103+
tracing::trace!(?self, ?config_path, "Saving state to config file");
104104
Ok(fs::write(config_path, serde_yaml::to_string(&self)?)?)
105105
}
106106

0 commit comments

Comments
 (0)