diff options
author | Mike Frysinger <vapier@google.com> | 2021-02-09 23:14:41 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-02-11 01:48:12 +0000 |
commit | 38867fb6d38d45a11271d6ef492e4d40066b078f (patch) | |
tree | 99778a43a5007322414ecd8b7c290842a4bc3fc6 /git_config.py | |
parent | ce64e3d47b97e54cc7fac3d7577cd53f1857de26 (diff) | |
download | git-repo-38867fb6d38d45a11271d6ef492e4d40066b078f.tar.gz |
git_config: add SetBoolean helper
A little sugar simplifies the code a bit.
Change-Id: Ie2b8a965faa9f9ca05c7be479d03e8e073cd816d
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/296522
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/git_config.py b/git_config.py index 2fa43a1e..282c0802 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -161,6 +161,12 @@ class GitConfig(object): | |||
161 | return False | 161 | return False |
162 | return None | 162 | return None |
163 | 163 | ||
164 | def SetBoolean(self, name, value): | ||
165 | """Set the truthy value for a key.""" | ||
166 | if value is not None: | ||
167 | value = 'true' if value else 'false' | ||
168 | self.SetString(name, value) | ||
169 | |||
164 | def GetString(self, name, all_keys=False): | 170 | def GetString(self, name, all_keys=False): |
165 | """Get the first value for a key, or None if it is not defined. | 171 | """Get the first value for a key, or None if it is not defined. |
166 | 172 | ||