diff options
author | Adrian Wannenmacher <tfld@tfld.dev> | 2023-10-17 08:40:20 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-17 08:40:20 +0200 |
commit | 2be0e73d5b4468c83fd409e335bcaaa6329e80b0 (patch) | |
tree | b527cc77da856162f59619b6f7b2df002e097cbb /src | |
parent | 0e2b3db1d936fe3371473c5ce64e28f0e454ae9b (diff) |
Prevent unsigned tagging (#1915)
* prevent creation of tags when tag-signing is configured
Co-authored-by: extrawurst <776816+extrawurst@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/tag_commit.rs | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/components/tag_commit.rs b/src/components/tag_commit.rs index e3f6e435..3919141f 100644 --- a/src/components/tag_commit.rs +++ b/src/components/tag_commit.rs @@ -6,11 +6,13 @@ use super::{ use crate::{ keys::{key_match, SharedKeyConfig}, queue::{InternalEvent, NeedsUpdate, Queue}, - strings, + strings, try_or_popup, ui::style::SharedTheme, }; use anyhow::Result; -use asyncgit::sync::{self, CommitId, RepoPathRef}; +use asyncgit::sync::{ + self, get_config_string, CommitId, RepoPathRef, +}; use crossterm::event::Event; use ratatui::{backend::Backend, layout::Rect, Frame}; @@ -77,7 +79,7 @@ impl Component for TagCommitComponent { if key_match(e, self.key_config.keys.enter) && self.is_valid_tag() { - self.tag(); + try_or_popup!(self, "tag error:", self.tag()); } else if key_match( e, self.key_config.keys.tag_annotate, @@ -167,8 +169,15 @@ impl TagCommitComponent { } } - /// - pub fn tag(&mut self) { + pub fn tag(&mut self) -> Result<()> { + 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(); if let Some(commit_id) = self.commit_id { @@ -199,5 +208,7 @@ impl TagCommitComponent { } } } + + Ok(()) } } |