Fix ManifestProject.partial_clone_exclude property.
Bug: b/256358360 Change-Id: Ic6e3a049aa38827123d0324c8b14157562c5986e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353574 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Joanna Wang <jojwang@google.com> Reviewed-by: Josip Sokcevic <sokcevic@google.com>
This commit is contained in:
parent
1b8714937c
commit
ea5239ddd9
3 changed files with 90 additions and 5 deletions
|
@ -22,6 +22,7 @@ import re
|
|||
import ssl
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import Union
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
|
@ -117,7 +118,7 @@ class GitConfig(object):
|
|||
return self.defaults.Has(name, include_defaults=True)
|
||||
return False
|
||||
|
||||
def GetInt(self, name):
|
||||
def GetInt(self, name: str) -> Union[int, None]:
|
||||
"""Returns an integer from the configuration file.
|
||||
|
||||
This follows the git config syntax.
|
||||
|
@ -126,7 +127,7 @@ class GitConfig(object):
|
|||
name: The key to lookup.
|
||||
|
||||
Returns:
|
||||
None if the value was not defined, or is not a boolean.
|
||||
None if the value was not defined, or is not an int.
|
||||
Otherwise, the number itself.
|
||||
"""
|
||||
v = self.GetString(name)
|
||||
|
@ -152,6 +153,9 @@ class GitConfig(object):
|
|||
try:
|
||||
return int(v, base=base) * mult
|
||||
except ValueError:
|
||||
print(
|
||||
f"warning: expected {name} to represent an integer, got {v} instead",
|
||||
file=sys.stderr)
|
||||
return None
|
||||
|
||||
def DumpConfigDict(self):
|
||||
|
@ -169,7 +173,7 @@ class GitConfig(object):
|
|||
config_dict[key] = self.GetString(key)
|
||||
return config_dict
|
||||
|
||||
def GetBoolean(self, name):
|
||||
def GetBoolean(self, name: str) -> Union[str, None]:
|
||||
"""Returns a boolean from the configuration file.
|
||||
None : The value was not defined, or is not a boolean.
|
||||
True : The value was set to true or yes.
|
||||
|
@ -183,6 +187,8 @@ class GitConfig(object):
|
|||
return True
|
||||
if v in ('false', 'no'):
|
||||
return False
|
||||
print(f"warning: expected {name} to represent a boolean, got {v} instead",
|
||||
file=sys.stderr)
|
||||
return None
|
||||
|
||||
def SetBoolean(self, name, value):
|
||||
|
@ -191,7 +197,7 @@ class GitConfig(object):
|
|||
value = 'true' if value else 'false'
|
||||
self.SetString(name, value)
|
||||
|
||||
def GetString(self, name, all_keys=False):
|
||||
def GetString(self, name: str, all_keys: bool = False) -> Union[str, None]:
|
||||
"""Get the first value for a key, or None if it is not defined.
|
||||
|
||||
This configuration file is used first, if the key is not
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue