Skip to content

Commit b4adc6e

Browse files
committed
✨ feat: optional gitmojis
1 parent f63b4fd commit b4adc6e

File tree

2 files changed

+48
-21
lines changed

2 files changed

+48
-21
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ chrono = { version = "0.4", default-features = false, features = ["clock"] }
7777
maintenance = { status = "actively-developed" }
7878

7979
[features]
80-
default = ["ghemoji", "regex-fancy", "trace-libgit", "vendor-openssl"]
80+
default = ["ghemoji", "regex-fancy", "trace-libgit", "vendor-openssl", "gitmoji"]
8181
ghemoji = ["gh-emoji"]
82+
gitmoji = []
8283
# regex-* features are mutually exclusive.
8384
regex-fancy = ["syntect/regex-fancy", "two-face/syntect-fancy"]
8485
regex-onig = ["syntect/regex-onig", "two-face/syntect-onig"]

src/popups/conventional_commit.rs

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -576,18 +576,36 @@ impl ConventionalCommitPopup {
576576
}
577577

578578
fn validate_escape(&mut self, commit_type: CommitType) {
579-
let (emoji, short_msg, _) = self.query_results_more_info
580-
[self.selected_index]
581-
.strings();
582-
self.queue.push(crate::queue::InternalEvent::OpenCommit);
583-
self.queue.push(
584-
crate::queue::InternalEvent::AddCommitMessage(format!(
585-
"{emoji} {commit_type}{}{} {short_msg}",
586-
if self.is_breaking { "!" } else { "" },
587-
if short_msg.is_empty() { "" } else { ":" },
588-
)),
589-
);
590-
self.hide();
579+
#[cfg(not(feature = "gitmoji"))]
580+
{
581+
self.queue.push(crate::queue::InternalEvent::OpenCommit);
582+
self.queue.push(
583+
crate::queue::InternalEvent::AddCommitMessage(
584+
format!(
585+
"{commit_type}{}:",
586+
if self.is_breaking { "!" } else { "" },
587+
),
588+
),
589+
);
590+
self.hide();
591+
}
592+
#[cfg(feature = "gitmoji")]
593+
{
594+
let (emoji, short_msg, _) = self.query_results_more_info
595+
[self.selected_index]
596+
.strings();
597+
self.queue.push(crate::queue::InternalEvent::OpenCommit);
598+
self.queue.push(
599+
crate::queue::InternalEvent::AddCommitMessage(
600+
format!(
601+
"{emoji} {commit_type}{}{} {short_msg}",
602+
if self.is_breaking { "!" } else { "" },
603+
if short_msg.is_empty() { "" } else { ":" },
604+
),
605+
),
606+
);
607+
self.hide();
608+
}
591609
}
592610

593611
fn next_step(&mut self) {
@@ -725,14 +743,22 @@ impl Component for ConventionalCommitPopup {
725743
self.seleted_commit_type
726744
{
727745
self.validate_escape(commit_type);
728-
} else if let Some(&commit) = self
729-
.query_results_type
730-
.get(self.selected_index)
731-
{
732-
self.seleted_commit_type = Some(commit);
733-
self.next_step();
734-
735-
if commit.more_info().len() == 1 {
746+
} else {
747+
if let Some(&commit) = self
748+
.query_results_type
749+
.get(self.selected_index)
750+
{
751+
self.seleted_commit_type = Some(commit);
752+
753+
#[cfg(feature = "gitmoji")]
754+
{
755+
self.next_step();
756+
757+
if commit.more_info().len() == 1 {
758+
self.validate_escape(commit);
759+
}
760+
}
761+
#[cfg(not(feature = "gitmoji"))]
736762
self.validate_escape(commit);
737763
}
738764
}

0 commit comments

Comments
 (0)