Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 740 gpgsign warning #741

Merged
merged 3 commits into from
May 27, 2021
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
18 changes: 16 additions & 2 deletions src/components/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down Expand Up @@ -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)
Expand Down