mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-22 02:12:58 +03:00
parent
3d06b54d2c
commit
b15c8643c8
@ -1,9 +1,12 @@
|
|||||||
|
//! Git Api for Commits
|
||||||
use super::{CommitId, RepoPath};
|
use super::{CommitId, RepoPath};
|
||||||
use crate::{
|
use crate::{
|
||||||
error::Result,
|
error::Result,
|
||||||
sync::{repository::repo, utils::get_head_repo},
|
sync::{repository::repo, utils::get_head_repo},
|
||||||
};
|
};
|
||||||
use git2::{ErrorCode, ObjectType, Repository, Signature};
|
use git2::{
|
||||||
|
message_prettify, ErrorCode, ObjectType, Repository, Signature,
|
||||||
|
};
|
||||||
use scopetime::scope_time;
|
use scopetime::scope_time;
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -119,6 +122,20 @@ pub fn tag_commit(
|
|||||||
Ok(c)
|
Ok(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads the comment prefix from config & uses it to prettify commit messages
|
||||||
|
pub fn commit_message_prettify(
|
||||||
|
repo_path: &RepoPath,
|
||||||
|
message: String,
|
||||||
|
) -> Result<String> {
|
||||||
|
let comment_char = repo(repo_path)?
|
||||||
|
.config()?
|
||||||
|
.get_string("core.commentChar")
|
||||||
|
.map(|char_string| char_string.chars().next())?
|
||||||
|
.unwrap_or('#') as u8;
|
||||||
|
|
||||||
|
Ok(message_prettify(message, Some(comment_char))?)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
pub mod blame;
|
pub mod blame;
|
||||||
pub mod branch;
|
pub mod branch;
|
||||||
mod commit;
|
pub mod commit;
|
||||||
mod commit_details;
|
mod commit_details;
|
||||||
pub mod commit_files;
|
pub mod commit_files;
|
||||||
mod commit_filter;
|
mod commit_filter;
|
||||||
|
@ -11,8 +11,9 @@ use crate::{
|
|||||||
ui::style::SharedTheme,
|
ui::style::SharedTheme,
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Ok, Result};
|
use anyhow::{bail, Ok, Result};
|
||||||
|
use asyncgit::sync::commit::commit_message_prettify;
|
||||||
use asyncgit::{
|
use asyncgit::{
|
||||||
cached, message_prettify,
|
cached,
|
||||||
sync::{
|
sync::{
|
||||||
self, get_config_string, CommitId, HookResult,
|
self, get_config_string, CommitId, HookResult,
|
||||||
PrepareCommitMsgSource, RepoPathRef, RepoState,
|
PrepareCommitMsgSource, RepoPathRef, RepoState,
|
||||||
@ -195,7 +196,8 @@ impl CommitPopup {
|
|||||||
drop(file);
|
drop(file);
|
||||||
std::fs::remove_file(&file_path)?;
|
std::fs::remove_file(&file_path)?;
|
||||||
|
|
||||||
message = message_prettify(message, Some(b'#'))?;
|
message =
|
||||||
|
commit_message_prettify(&self.repo.borrow(), message)?;
|
||||||
self.input.set_text(message);
|
self.input.set_text(message);
|
||||||
self.input.show()?;
|
self.input.show()?;
|
||||||
|
|
||||||
@ -254,8 +256,8 @@ impl CommitPopup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: honor `core.commentChar`
|
let mut msg =
|
||||||
let mut msg = message_prettify(msg, Some(b'#'))?;
|
commit_message_prettify(&self.repo.borrow(), msg)?;
|
||||||
|
|
||||||
if verify {
|
if verify {
|
||||||
// run commit message check hook - can reject commit
|
// run commit message check hook - can reject commit
|
||||||
|
Loading…
Reference in New Issue
Block a user