···350350 text = _replace_value('hash', sri_hash, text)
351351352352 if fetcher == 'fetchFromGitHub':
353353- text = _replace_value('rev', f"{prefix}${{version}}", text)
354354- # incase there's no prefix, just rewrite without interpolation
355355- text = text.replace('"${version}";', 'version;')
353353+ # in the case of fetchFromGitHub, it's common to see `rev = version;`
354354+ # in which no string value is meant to be substituted.
355355+ # Verify that the attribute is set to a variable
356356+ regex = '(rev\s+=\s+([_a-zA-Z][_a-zA-Z0-9\.]*);)'
357357+ regex = re.compile(regex)
358358+ value = regex.findall(text)
359359+ n = len(value)
360360+361361+ if n == 0:
362362+ # value is set to a string, e.g. `rev = "v${version}";`
363363+ text = _replace_value('rev', f"{prefix}${{version}}", text)
364364+ # incase there's no prefix, just rewrite without interpolation
365365+ text = text.replace('"${version}";', 'version;')
356366357367 with open(path, 'w') as f:
358368 f.write(text)