update-python-libraries: skip replacing 'rev' when set to variable
It's common for fetchFromGitHub to have `rev = version;`, in which it will inherit the version. So no replacement is required.
This commit is contained in:
parent
ce0a907730
commit
b316efff4b
1 changed files with 13 additions and 3 deletions
|
@ -350,9 +350,19 @@ def _update_package(path, target):
|
||||||
text = _replace_value('hash', sri_hash, text)
|
text = _replace_value('hash', sri_hash, text)
|
||||||
|
|
||||||
if fetcher == 'fetchFromGitHub':
|
if fetcher == 'fetchFromGitHub':
|
||||||
text = _replace_value('rev', f"{prefix}${{version}}", text)
|
# in the case of fetchFromGitHub, it's common to see `rev = version;`
|
||||||
# incase there's no prefix, just rewrite without interpolation
|
# in which no string value is meant to be substituted.
|
||||||
text = text.replace('"${version}";', 'version;')
|
# Verify that the attribute is set to a variable
|
||||||
|
regex = '(rev\s+=\s+([_a-zA-Z][_a-zA-Z0-9\.]*);)'
|
||||||
|
regex = re.compile(regex)
|
||||||
|
value = regex.findall(text)
|
||||||
|
n = len(value)
|
||||||
|
|
||||||
|
if n == 0:
|
||||||
|
# value is set to a string, e.g. `rev = "v${version}";`
|
||||||
|
text = _replace_value('rev', f"{prefix}${{version}}", text)
|
||||||
|
# incase there's no prefix, just rewrite without interpolation
|
||||||
|
text = text.replace('"${version}";', 'version;')
|
||||||
|
|
||||||
with open(path, 'w') as f:
|
with open(path, 'w') as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
|
Loading…
Reference in a new issue