Skip to content

Commit

Permalink
refactor: clean up emoji handling
Browse files Browse the repository at this point in the history
  • Loading branch information
its-danny committed May 12, 2022
1 parent 92c8bd7 commit a7aaad9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
- Create conventional commits with ease
- Use alongside [cocogitto](https://github.com/oknozor/cocogitto)
for automatic versioning, changelog generation, and more
- Use emoji 👋 (or, shortcodes)
- Use emoji 👋 (or, [shortcodes](https://github.com/ikatyang/emoji-cheat-sheet))
- Autocomplete for commit scope
- Run as a git hook
- Custom commit types
Expand Down
20 changes: 10 additions & 10 deletions src/lib/emoji.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
fn replace_emoji_shortcodes(mut string: String) -> String {
for emoji in emojis::iter() {
if let Some(shortcode) = emoji.shortcode() {
string = string.replace(&format!(":{shortcode}:"), emoji.as_str());
}
}

string
}

pub trait ReplaceEmoji {
fn replace_emoji_shortcodes(&self) -> String;
}
Expand All @@ -24,6 +14,16 @@ impl ReplaceEmoji for String {
}
}

fn replace_emoji_shortcodes(mut string: String) -> String {
for emoji in emojis::iter() {
if let Some(shortcode) = emoji.shortcode() {
string = string.replace(&format!(":{shortcode}:"), emoji.as_str());
}
}

string
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit a7aaad9

Please sign in to comment.