Skip to content

Prevent unsigned tagging #1915

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

Merged
merged 7 commits into from
Oct 17, 2023
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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
* `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

### Fixes
Expand Down
21 changes: 16 additions & 5 deletions src/components/tag_commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -199,5 +208,7 @@ impl TagCommitComponent {
}
}
}

Ok(())
}
}