diff options
Diffstat (limited to 'community/gitui/make-gh-emoji-optional.patch')
-rw-r--r-- | community/gitui/make-gh-emoji-optional.patch | 140 |
1 files changed, 0 insertions, 140 deletions
diff --git a/community/gitui/make-gh-emoji-optional.patch b/community/gitui/make-gh-emoji-optional.patch deleted file mode 100644 index 735a70f5289..00000000000 --- a/community/gitui/make-gh-emoji-optional.patch +++ /dev/null @@ -1,140 +0,0 @@ -Patch-Source: https://github.com/extrawurst/gitui/pull/954 (modified) -From 9f580bfa507ad1b5a3c749776d9b6b0cf440a6c5 Mon Sep 17 00:00:00 2001 -From: Jakub Jirutka <jakub@jirutka.cz> -Date: Thu, 21 Oct 2021 02:34:13 +0200 -Subject: [PATCH] Make gh-emoji optional - -gh-emoji crate includes *images* of GitHub's emoji - this is quite a big -dependency. It increases the binary size by 1 MiB; that's +25 % when -building v0.18.0 on Alpine Linux with build flags to optimize size. -I consider it an unnecessary bloat that should be optional. ---- - Cargo.toml | 5 +++-- - src/components/utils/emoji.rs | 17 +++++++++++++++++ - src/components/utils/logitems.rs | 10 ++++++++-- - src/components/utils/mod.rs | 19 ++----------------- - 5 files changed, 31 insertions(+), 21 deletions(-) - create mode 100644 src/components/utils/emoji.rs - -diff --git a/Cargo.toml b/Cargo.toml -index c075a43..8f9f200 100644 ---- a/Cargo.toml -+++ b/Cargo.toml -@@ -47,7 +47,7 @@ - bugreport = "0.4" - lazy_static = "1.4" - syntect = { version = "4.5", default-features = false, features = ["metadata", "default-onig"]} --gh-emoji = "1.0.6" -+gh-emoji = { version = "1.0.6", optional = true } - fuzzy-matcher = "0.3" - - [target.'cfg(all(target_family="unix",not(target_os="macos")))'.dependencies] -@@ -64,7 +64,8 @@ - maintenance = { status = "actively-developed" } - - [features] --default=[] -+default=["emoji"] -+emoji=["gh-emoji"] - timing=["scopetime/enabled"] - - [workspace] -diff --git a/src/components/utils/emoji.rs b/src/components/utils/emoji.rs -new file mode 100644 -index 0000000..4d158cb ---- /dev/null -+++ b/src/components/utils/emoji.rs -@@ -0,0 +1,17 @@ -+use lazy_static::lazy_static; -+use std::borrow::Cow; -+ -+lazy_static! { -+ static ref EMOJI_REPLACER: gh_emoji::Replacer = -+ gh_emoji::Replacer::new(); -+} -+ -+// Replace markdown emojis with Unicode equivalent -+// :hammer: --> 🔨 -+#[inline] -+pub fn emojifi_string(s: &mut String) { -+ let resulting_cow = EMOJI_REPLACER.replace_all(s); -+ if let Cow::Owned(altered_s) = resulting_cow { -+ *s = altered_s; -+ } -+} -diff --git a/src/components/utils/logitems.rs b/src/components/utils/logitems.rs -index 67b83a9..4cf4c3f 100644 ---- a/src/components/utils/logitems.rs -+++ b/src/components/utils/logitems.rs -@@ -2,7 +2,8 @@ - use chrono::{DateTime, Duration, Local, NaiveDateTime, Utc}; - use std::slice::Iter; - --use crate::components::utils::emojifi_string; -+#[cfg(feature = "emoji")] -+use super::emoji::*; - - static SLICE_OFFSET_RELOAD_THRESHOLD: usize = 100; - -@@ -27,9 +28,12 @@ - Utc, - )); - -- // Replace markdown emojis with Unicode equivalent - let author = c.author; -+ #[allow(unused_mut)] - let mut msg = c.message; -+ -+ // Replace markdown emojis with Unicode equivalent -+ #[cfg(feature = "emoji")] - emojifi_string(&mut msg); - - Self { -@@ -113,6 +117,7 @@ - } - - #[cfg(test)] -+#[cfg(feature = "emoji")] - mod tests { - use super::*; - -diff --git a/src/components/utils/mod.rs b/src/components/utils/mod.rs -index da2208a..f9103fe 100644 ---- a/src/components/utils/mod.rs -+++ b/src/components/utils/mod.rs -@@ -1,8 +1,8 @@ - use chrono::{DateTime, Local, NaiveDateTime, Utc}; --use lazy_static::lazy_static; --use std::borrow::Cow; - use unicode_width::UnicodeWidthStr; - -+#[cfg(feature = "emoji")] -+pub mod emoji; - pub mod filetree; - pub mod logitems; - pub mod scroll_vertical; -@@ -55,21 +55,6 @@ pub fn string_width_align(s: &str, width: usize) -> String { - } - } - --lazy_static! { -- static ref EMOJI_REPLACER: gh_emoji::Replacer = -- gh_emoji::Replacer::new(); --} -- --// Replace markdown emojis with Unicode equivalent --// :hammer: --> 🔨 --#[inline] --pub fn emojifi_string(s: &mut String) { -- let resulting_cow = EMOJI_REPLACER.replace_all(s); -- if let Cow::Owned(altered_s) = resulting_cow { -- *s = altered_s; -- } --} -- - #[inline] - fn find_truncate_point(s: &str, chars: usize) -> usize { - s.chars().take(chars).map(char::len_utf8).sum() --- -2.16.4 - |