Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term: Remove unused file
Alexis Sellier committed 3 years ago
commit 40eb6f2a6ee3ce531bf95f71cdf3882d72c101cb
parent bfea229850a382dc2f9670b59c9aa8825c87f4f2
1 file changed +0 -105
deleted radicle-term/src/patch.rs
@@ -1,105 +0,0 @@
-
use radicle::git;
-

-
use crate::terminal as term;
-
use crate::terminal::cell::Cell as _;
-

-
/// The user supplied `Patch` description.
-
#[derive(Clone, Debug, PartialEq, Eq)]
-
pub enum Message {
-
    /// Prompt user to write comment in editor.
-
    Edit,
-
    /// Don't leave a comment.
-
    Blank,
-
    /// Use the following string as comment.
-
    Text(String),
-
}
-

-
impl Message {
-
    /// Get the `Message` as a string according to the method.
-
    pub fn get(self, help: &str) -> String {
-
        let comment = match self {
-
            Message::Edit => term::Editor::new()
-
                .extension("markdown")
-
                .edit(help)
-
                .ok()
-
                .flatten(),
-
            Message::Blank => None,
-
            Message::Text(c) => Some(c),
-
        };
-
        let comment = comment.unwrap_or_default();
-
        let comment = comment.trim();
-

-
        comment.to_owned()
-
    }
-

-
    pub fn append(&mut self, arg: &str) {
-
        if let Message::Text(v) = self {
-
            v.extend(["\n\n", arg]);
-
        } else {
-
            *self = Message::Text(arg.into());
-
        };
-
    }
-
}
-

-
impl Default for Message {
-
    fn default() -> Self {
-
        Self::Edit
-
    }
-
}
-

-
/// List the given commits in a table.
-
pub fn list_commits(commits: &[git::raw::Commit]) -> anyhow::Result<()> {
-
    let mut table = term::Table::default();
-

-
    for commit in commits {
-
        let message = commit
-
            .summary_bytes()
-
            .unwrap_or_else(|| commit.message_bytes());
-
        table.push([
-
            term::format::secondary(term::format::oid(commit.id())),
-
            term::format::italic(String::from_utf8_lossy(message).to_string()),
-
        ]);
-
    }
-
    table.render();
-

-
    Ok(())
-
}
-

-
/// Print commits ahead and behind.
-
pub fn print_commits_ahead_behind(
-
    repo: &git::raw::Repository,
-
    left: git::raw::Oid,
-
    right: git::raw::Oid,
-
) -> anyhow::Result<()> {
-
    let (ahead, behind) = repo.graph_ahead_behind(left, right)?;
-

-
    term::info!(
-
        "{} commit(s) ahead, {} commit(s) behind",
-
        term::format::positive(ahead),
-
        if behind > 0 {
-
            term::format::negative(behind)
-
        } else {
-
            term::format::dim(behind)
-
        }
-
    );
-
    Ok(())
-
}
-

-
/// Print title and description in a text box.
-
pub fn print_title_desc(title: &str, description: &str) {
-
    let title_pretty = &term::format::dim(format!("╭─ {title} ───────"));
-
    term::print(title_pretty);
-
    term::blank();
-

-
    if description.is_empty() {
-
        term::print(term::format::italic("No description provided."));
-
    } else {
-
        term::markdown(description);
-
    }
-

-
    term::blank();
-
    term::print(term::format::dim(format!(
-
        "╰{}",
-
        "─".repeat(title_pretty.to_string().width() - 1)
-
    )));
-
}