Fix 740 gpgsign warning (#741)

* error if gpgsign=true
This commit is contained in:
Stephan Dilly 2021-05-27 09:34:44 +02:00 committed by GitHub
parent 5a51fc63ad
commit 242319b1d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- smarter log timestamps ([#682](https://github.com/extrawurst/gitui/issues/682))
- create-branch popup aligned with rename-branch [[@bruceCoelho](https://github.com/bruceCoelho)] ([#679](https://github.com/extrawurst/gitui/issues/679))
- smart focus change after staging all files ([#706](https://github.com/extrawurst/gitui/issues/706))
- do not allow to commit when `gpgsign` enabled ([#740](https://github.com/extrawurst/gitui/issues/740))
## Fixed
- selected-tab color broken in light theme [[@Cottser](https://github.com/Cottser)] ([#719](https://github.com/extrawurst/gitui/issues/719))

View file

@ -6,7 +6,7 @@ use super::{
use crate::{
keys::SharedKeyConfig,
queue::{InternalEvent, NeedsUpdate, Queue},
strings,
strings, try_or_popup,
ui::style::SharedTheme,
};
use anyhow::Result;
@ -106,7 +106,11 @@ impl Component for CommitComponent {
if let Event::Key(e) = ev {
if e == self.key_config.enter && self.can_commit() {
self.commit()?;
try_or_popup!(
self,
"commit error:",
self.commit()
);
} else if e == self.key_config.commit_amend
&& self.can_amend()
{
@ -293,6 +297,16 @@ impl CommitComponent {
}
fn commit(&mut self) -> Result<()> {
let gpgsign = get_config_string(CWD, "commit.gpgsign")
.ok()
.flatten()
.and_then(|path| path.parse::<bool>().ok())
.unwrap_or_default();
if gpgsign {
anyhow::bail!("config commit.gpgsign=true detected.\ngpg signing not supported.\ndeactivate in your repo/gitconfig to be able to commit without signing.");
}
let msg = self.input.get_text().clone();
self.input.clear();
self.commit_with_msg(msg)