File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ use selection_view::SelectionView;
15
15
use std:: {
16
16
error:: Error ,
17
17
fs:: File ,
18
- io:: { Read , Write } ,
18
+ io:: { BufRead , BufReader , Write } ,
19
19
} ;
20
20
#[ cfg( unix) ]
21
21
use std:: { fs:: Permissions , os:: unix:: prelude:: PermissionsExt } ;
@@ -58,14 +58,15 @@ fn main() -> Result<(), Box<dyn Error>> {
58
58
59
59
let ( commit_file_path, commit_file_content) = if !args. hook . is_empty ( ) {
60
60
let path = & args. hook [ 0 ] ;
61
- let mut file = File :: open ( path) ?;
61
+ let file = File :: open ( path) ?;
62
+ let mut reader = BufReader :: new ( file) ;
62
63
let mut content = String :: new ( ) ;
63
- file . read_to_string ( & mut content) ?;
64
+ reader . read_line ( & mut content) ?;
64
65
let content = if !content. is_empty ( ) {
65
66
// FIXME: There has to be a faster way to detect an emoji.
66
67
for emoji in emoji:: EMOJIS {
67
- if content. starts_with ( emoji. emoji ( ) ) || content. starts_with ( emoji. code ( ) ) {
68
- // The file already contains an emoji.
68
+ if content. contains ( emoji. emoji ( ) ) || content. contains ( emoji. code ( ) ) {
69
+ // The commit shortlog already contains an emoji.
69
70
return Ok ( ( ) ) ;
70
71
}
71
72
}
You can’t perform that action at this time.
0 commit comments