Prevent unsigned tagging (#1915)

* prevent creation of tags when tag-signing is configured

Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
This commit is contained in:
Adrian Wannenmacher 2023-10-17 08:40:20 +02:00 committed by GitHub
parent 0e2b3db1d9
commit 2be0e73d5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 7 deletions

View file

@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### Added
* `theme.ron` now supports customizing line break symbol ([#1894](https://github.com/extrawurst/gitui/issues/1894)) * `theme.ron` now supports customizing line break symbol ([#1894](https://github.com/extrawurst/gitui/issues/1894))
* add confirmation for dialog for undo commit ([#1912](https://github.com/extrawurst/gitui/issues/1912)) * add confirmation for dialog for undo commit [[@TeFiLeDo](https://github.com/TeFiLeDo)] ([#1912](https://github.com/extrawurst/gitui/issues/1912))
### Changed
* do not allow tag when `tag.gpgsign` enabled [[@TeFiLeDo](https://github.com/TeFiLeDo)] ([#1915](https://github.com/extrawurst/gitui/pull/1915))
## [0.24.3] - 2023-09-09 ## [0.24.3] - 2023-09-09
### Fixes ### Fixes

View file

@ -6,11 +6,13 @@ use super::{
use crate::{ use crate::{
keys::{key_match, SharedKeyConfig}, keys::{key_match, SharedKeyConfig},
queue::{InternalEvent, NeedsUpdate, Queue}, queue::{InternalEvent, NeedsUpdate, Queue},
strings, strings, try_or_popup,
ui::style::SharedTheme, ui::style::SharedTheme,
}; };
use anyhow::Result; use anyhow::Result;
use asyncgit::sync::{self, CommitId, RepoPathRef}; use asyncgit::sync::{
self, get_config_string, CommitId, RepoPathRef,
};
use crossterm::event::Event; use crossterm::event::Event;
use ratatui::{backend::Backend, layout::Rect, Frame}; use ratatui::{backend::Backend, layout::Rect, Frame};
@ -77,7 +79,7 @@ impl Component for TagCommitComponent {
if key_match(e, self.key_config.keys.enter) if key_match(e, self.key_config.keys.enter)
&& self.is_valid_tag() && self.is_valid_tag()
{ {
self.tag(); try_or_popup!(self, "tag error:", self.tag());
} else if key_match( } else if key_match(
e, e,
self.key_config.keys.tag_annotate, self.key_config.keys.tag_annotate,
@ -167,8 +169,15 @@ impl TagCommitComponent {
} }
} }
/// pub fn tag(&mut self) -> Result<()> {
pub fn tag(&mut self) { let gpgsign =
get_config_string(&self.repo.borrow(), "tag.gpgsign")
.ok()
.flatten()
.and_then(|val| val.parse::<bool>().ok())
.unwrap_or_default();
anyhow::ensure!(!gpgsign, "config tag.gpgsign=true detected.\ngpg signing not supported.\ndeactivate in your repo/gitconfig to be able to tag without signing.");
let (tag_name, tag_annotation) = self.tag_info(); let (tag_name, tag_annotation) = self.tag_info();
if let Some(commit_id) = self.commit_id { if let Some(commit_id) = self.commit_id {
@ -199,5 +208,7 @@ impl TagCommitComponent {
} }
} }
} }
Ok(())
} }
} }