Skip to content

Commit

Permalink
do not fetch commit.template on every update
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Apr 26, 2021
1 parent fa60610 commit 3ad1911
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/components/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ impl Component for CommitComponent {
self.input
.set_title(strings::commit_title(&self.key_config));

self.commit_template =
get_config_string(CWD, "commit.template")
.ok()
.flatten()
.and_then(|path| read_to_string(path).ok());

if self.is_empty() {
if let Some(s) = &self.commit_template {
self.input.set_text(s.clone());
Expand Down Expand Up @@ -170,14 +176,6 @@ impl CommitComponent {
pub fn update(&mut self) -> Result<()> {
self.git_branch_name.lookup().map(Some).unwrap_or(None);

self.commit_template.get_or_insert_with(|| {
get_config_string(CWD, "commit.template")
.ok()
.unwrap_or(None)
.and_then(|path| read_to_string(path).ok())
.unwrap_or_else(String::new)
});

Ok(())
}

Expand Down

0 comments on commit 3ad1911

Please sign in to comment.