mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-27 00:14:52 +03:00
parent
cd639b29c0
commit
6249491484
@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Keep commit message when pre-commit hook fails ([#1035](https://github.com/extrawurst/gitui/issues/1035))
|
||||||
|
|
||||||
## [0.19] - 2021-12-08 - Bare Repo Support
|
## [0.19] - 2021-12-08 - Bare Repo Support
|
||||||
|
|
||||||
**finder highlighting matches**
|
**finder highlighting matches**
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
|
|
||||||
- Fast and intuitive **keyboard only** control
|
- Fast and intuitive **keyboard only** control
|
||||||
- Context based help (**no need to memorize** tons of hot-keys)
|
- Context based help (**no need to memorize** tons of hot-keys)
|
||||||
- Inspect, commit, and amend changes (incl. hooks: _commit-msg_/_post-commit_)
|
- Inspect, commit, and amend changes (incl. hooks: _pre-commit_,_commit-msg_,_post-commit_)
|
||||||
- Stage, unstage, revert and reset files, hunks and lines
|
- Stage, unstage, revert and reset files, hunks and lines
|
||||||
- Stashing (save, pop, apply, drop, and inspect)
|
- Stashing (save, pop, apply, drop, and inspect)
|
||||||
- Push/Fetch to/from remote
|
- Push/Fetch to/from remote
|
||||||
|
@ -60,7 +60,7 @@ pub(crate) fn signature_allow_undefined_name(
|
|||||||
signature
|
signature
|
||||||
}
|
}
|
||||||
|
|
||||||
/// this does not run any git hooks
|
/// this does not run any git hooks, git-hooks have to be executed manually, checkout `hooks_commit_msg` for example
|
||||||
pub fn commit(repo_path: &RepoPath, msg: &str) -> Result<CommitId> {
|
pub fn commit(repo_path: &RepoPath, msg: &str) -> Result<CommitId> {
|
||||||
scope_time!("commit");
|
scope_time!("commit");
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@ use tui::{
|
|||||||
Frame,
|
Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum CommitResult {
|
||||||
|
ComitDone,
|
||||||
|
Aborted,
|
||||||
|
}
|
||||||
|
|
||||||
enum Mode {
|
enum Mode {
|
||||||
Normal,
|
Normal,
|
||||||
Amend(CommitId),
|
Amend(CommitId),
|
||||||
@ -175,11 +180,23 @@ impl CommitComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let msg = self.input.get_text().to_string();
|
let msg = self.input.get_text().to_string();
|
||||||
|
|
||||||
|
if matches!(
|
||||||
|
self.commit_with_msg(msg)?,
|
||||||
|
CommitResult::ComitDone
|
||||||
|
) {
|
||||||
|
self.hide();
|
||||||
|
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
|
||||||
self.input.clear();
|
self.input.clear();
|
||||||
self.commit_with_msg(msg)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit_with_msg(&mut self, msg: String) -> Result<()> {
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn commit_with_msg(
|
||||||
|
&mut self,
|
||||||
|
msg: String,
|
||||||
|
) -> Result<CommitResult> {
|
||||||
if let HookResult::NotOk(e) =
|
if let HookResult::NotOk(e) =
|
||||||
sync::hooks_pre_commit(&self.repo.borrow())?
|
sync::hooks_pre_commit(&self.repo.borrow())?
|
||||||
{
|
{
|
||||||
@ -188,7 +205,7 @@ impl CommitComponent {
|
|||||||
"pre-commit hook error:\n{}",
|
"pre-commit hook error:\n{}",
|
||||||
e
|
e
|
||||||
)));
|
)));
|
||||||
return Ok(());
|
return Ok(CommitResult::Aborted);
|
||||||
}
|
}
|
||||||
let mut msg = message_prettify(msg, Some(b'#'))?;
|
let mut msg = message_prettify(msg, Some(b'#'))?;
|
||||||
if let HookResult::NotOk(e) =
|
if let HookResult::NotOk(e) =
|
||||||
@ -199,28 +216,19 @@ impl CommitComponent {
|
|||||||
"commit-msg hook error:\n{}",
|
"commit-msg hook error:\n{}",
|
||||||
e
|
e
|
||||||
)));
|
)));
|
||||||
return Ok(());
|
return Ok(CommitResult::Aborted);
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = match &self.mode {
|
match &self.mode {
|
||||||
Mode::Normal => sync::commit(&self.repo.borrow(), &msg),
|
Mode::Normal => sync::commit(&self.repo.borrow(), &msg)?,
|
||||||
Mode::Amend(amend) => {
|
Mode::Amend(amend) => {
|
||||||
sync::amend(&self.repo.borrow(), *amend, &msg)
|
sync::amend(&self.repo.borrow(), *amend, &msg)?
|
||||||
}
|
}
|
||||||
Mode::Merge(ids) => {
|
Mode::Merge(ids) => {
|
||||||
sync::merge_commit(&self.repo.borrow(), &msg, ids)
|
sync::merge_commit(&self.repo.borrow(), &msg, ids)?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Err(e) = res {
|
|
||||||
log::error!("commit error: {}", &e);
|
|
||||||
self.queue.push(InternalEvent::ShowErrorMsg(format!(
|
|
||||||
"commit failed:\n{}",
|
|
||||||
&e
|
|
||||||
)));
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let HookResult::NotOk(e) =
|
if let HookResult::NotOk(e) =
|
||||||
sync::hooks_post_commit(&self.repo.borrow())?
|
sync::hooks_post_commit(&self.repo.borrow())?
|
||||||
{
|
{
|
||||||
@ -231,11 +239,7 @@ impl CommitComponent {
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.hide();
|
Ok(CommitResult::ComitDone)
|
||||||
|
|
||||||
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn can_commit(&self) -> bool {
|
fn can_commit(&self) -> bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user