Skip to content

Commit

Permalink
chore(vcs): rewrite git config update to not sync on each change
Browse files Browse the repository at this point in the history
The set_value interface immediatelly writes out any change making our
batching ineffective. Sticking to native ConfigParser set interface
makes it write the file when leaving the context. This also needs we
need to manually create missing sections.
  • Loading branch information
nijel committed Jan 14, 2025
1 parent 6247d9c commit b191318
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions weblate/vcs/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ def git_config_update(
continue
if old == value:
continue
except (NoSectionError, NoOptionError):
except NoSectionError:
if value is not None:
config.add_section(section)
except NoOptionError:
pass
if value is not None:
config.set_value(section, key, value)
config.set(section, key, value)

def config_update(self, *updates: tuple[str, str, str | None]) -> None:
filename = Path(self.path) / ".git" / "config"
Expand Down

0 comments on commit b191318

Please sign in to comment.