Skip to content

Commit 3ad1911

Browse files
author
Stephan Dilly
committed
do not fetch commit.template on every update
1 parent fa60610 commit 3ad1911

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/components/commit.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ impl Component for CommitComponent {
131131
self.input
132132
.set_title(strings::commit_title(&self.key_config));
133133

134+
self.commit_template =
135+
get_config_string(CWD, "commit.template")
136+
.ok()
137+
.flatten()
138+
.and_then(|path| read_to_string(path).ok());
139+
134140
if self.is_empty() {
135141
if let Some(s) = &self.commit_template {
136142
self.input.set_text(s.clone());
@@ -170,14 +176,6 @@ impl CommitComponent {
170176
pub fn update(&mut self) -> Result<()> {
171177
self.git_branch_name.lookup().map(Some).unwrap_or(None);
172178

173-
self.commit_template.get_or_insert_with(|| {
174-
get_config_string(CWD, "commit.template")
175-
.ok()
176-
.unwrap_or(None)
177-
.and_then(|path| read_to_string(path).ok())
178-
.unwrap_or_else(String::new)
179-
});
180-
181179
Ok(())
182180
}
183181

0 commit comments

Comments
 (0)