Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions crates/but-rebase/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use anyhow::{Context as _, Ok, Result, anyhow, bail};
use bstr::BString;
use gix::{objs::Exists, prelude::ObjectIdExt};
use gix::prelude::ObjectIdExt;
use tracing::instrument;

use crate::commit::DateMode;
Expand Down Expand Up @@ -91,8 +91,10 @@ impl<'repo> Rebase<'repo> {
base_substitute: Option<gix::ObjectId>,
) -> Result<Self> {
let base = base.into();
if base.is_some() && base.filter(|base| repo.exists(base)).is_none() {
bail!("Base commit must exist if provided: {}", base.unwrap());
if let Some(base) = base
&& !repo.has_object(base)
{
bail!("Base commit must exist if provided: {}", base);
}
Ok(Self {
repo,
Expand Down
1 change: 1 addition & 0 deletions crates/but/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ minus = { version = "5.6.1", default-features = false, features = [
] }
unicode-width = "0.2"
cfg-if = "1.0.4"
tempfile.workspace = true

[dev-dependencies]
but-core = { workspace = true, features = ["testing"] }
Expand Down
5 changes: 3 additions & 2 deletions crates/but/src/command/legacy/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,9 @@ fn get_commit_message_from_editor(
template.push_str("#\n");

// Read the result from the editor and strip comments
let message = tui::get_text::from_editor_no_comments("but_commit_msg", &template)?;
Ok(message)
let lossy_message =
tui::get_text::from_editor_no_comments("commit_msg", &template)?.to_string();
Ok(lossy_message)
}

fn get_status_char(path: &BString, changes: &[TreeChange]) -> &'static str {
Expand Down
14 changes: 8 additions & 6 deletions crates/but/src/command/legacy/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,14 @@ fn get_commit_message_from_editor(
template.push_str("#\n");

// Read the result and strip comments
let message = tui::get_text::from_editor_no_comments("but_commit_msg", &template)?;
let lossy_message =
tui::get_text::from_editor_no_comments("commit_msg", &template)?.to_string();

if message.is_empty() {
if lossy_message.is_empty() {
bail!("Aborting due to empty commit message");
}

Ok(message)
Ok(lossy_message)
}

fn get_branch_name_from_editor(current_name: &str) -> Result<String> {
Expand All @@ -255,13 +256,14 @@ fn get_branch_name_from_editor(current_name: &str) -> Result<String> {
template.push_str("# with '#' will be ignored, and an empty name aborts the operation.\n");
template.push_str("#\n");

let branch_name = tui::get_text::from_editor_no_comments("but_branch_name", &template)?;
let branch_name_lossy =
tui::get_text::from_editor_no_comments("branch_name", &template)?.to_string();

if branch_name.is_empty() {
if branch_name_lossy.is_empty() {
bail!("Aborting due to empty branch name");
}

Ok(branch_name)
Ok(branch_name_lossy)
}

#[cfg(test)]
Expand Down
10 changes: 5 additions & 5 deletions crates/but/src/command/legacy/forge/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ fn get_review_body_from_editor(
template.push_str("# with '#' will be ignored, and an empty body is allowed.\n");
template.push_str("#\n");

let body = get_text::from_editor_no_comments("but_review_body", &template)?;
Ok(body)
let lossy_body = get_text::from_editor_no_comments("review_body", &template)?.to_string();
Ok(lossy_body)
}

/// Extract the commit description (body) from the commit message, skipping the first line (title).
Expand Down Expand Up @@ -606,13 +606,13 @@ fn get_review_title_from_editor(
template.push_str("# with '#' will be ignored, and an empty title aborts the operation.\n");
template.push_str("#\n");

let title = get_text::from_editor_no_comments("but_review_title", &template)?;
let lossy_title = get_text::from_editor_no_comments("review_title", &template)?.to_string();

if title.is_empty() {
if lossy_title.is_empty() {
anyhow::bail!("Aborting due to empty review title");
}

Ok(title)
Ok(lossy_title)
}

/// Extract the commit title from the commit message (first line).
Expand Down
Loading
Loading