mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-04 22:40:12 +01:00
Merge branch 'tag_UpdateCheckData' into 'master'
[checkupdates] UpdateCheckData use tag as default version See merge request fdroid/fdroidserver!949
This commit is contained in:
commit
14cfa11b68
@ -161,19 +161,22 @@ def check_tags(app, pattern):
|
||||
|
||||
if app.UpdateCheckData:
|
||||
filecode, codeex, filever, verex = app.UpdateCheckData.split('|')
|
||||
vercode = None
|
||||
filecode = build_dir / filecode
|
||||
if not filecode.is_file():
|
||||
logging.debug("UpdateCheckData file {0} not found in tag {1}".format(filecode, tag))
|
||||
continue
|
||||
|
||||
filecontent = filecode.read_text()
|
||||
if filecode:
|
||||
filecode = build_dir / filecode
|
||||
if not filecode.is_file():
|
||||
logging.debug("UpdateCheckData file {0} not found in tag {1}".format(filecode, tag))
|
||||
continue
|
||||
filecontent = filecode.read_text()
|
||||
else:
|
||||
filecontent = tag
|
||||
|
||||
m = re.search(codeex, filecontent)
|
||||
if m:
|
||||
vercode = m.group(1).strip()
|
||||
if not m:
|
||||
continue
|
||||
|
||||
vercode = m.group(1).strip()
|
||||
|
||||
version = "??"
|
||||
if filever:
|
||||
if filever != '.':
|
||||
filever = build_dir / filever
|
||||
@ -181,19 +184,22 @@ def check_tags(app, pattern):
|
||||
filecontent = filever.read_text()
|
||||
else:
|
||||
logging.debug("UpdateCheckData file {0} not found in tag {1}".format(filever, tag))
|
||||
else:
|
||||
filecontent = tag
|
||||
|
||||
version = tag
|
||||
if verex:
|
||||
m = re.search(verex, filecontent)
|
||||
if m:
|
||||
version = m.group(1)
|
||||
|
||||
if vercode:
|
||||
logging.debug("UpdateCheckData found version {0} ({1})"
|
||||
.format(version, vercode))
|
||||
i_vercode = common.version_code_string_to_int(vercode)
|
||||
if i_vercode > common.version_code_string_to_int(hcode):
|
||||
htag = tag
|
||||
hcode = str(i_vercode)
|
||||
hver = version
|
||||
logging.debug("UpdateCheckData found version {0} ({1})"
|
||||
.format(version, vercode))
|
||||
i_vercode = common.version_code_string_to_int(vercode)
|
||||
if i_vercode > common.version_code_string_to_int(hcode):
|
||||
htag = tag
|
||||
hcode = str(i_vercode)
|
||||
hver = version
|
||||
else:
|
||||
for subdir in possible_subdirs(app):
|
||||
root_dir = build_dir / subdir
|
||||
|
@ -158,7 +158,7 @@ class CheckupdatesTest(unittest.TestCase):
|
||||
app.metadatapath = 'metadata/' + app.id + '.yml'
|
||||
app.CurrentVersionCode = 10108
|
||||
app.UpdateCheckMode = 'HTTP'
|
||||
app.UpdateCheckData = 'https://a.net/b.txt|c(.*)|https://d.net/e.txt|v(.*)'
|
||||
app.UpdateCheckData = r'https://a.net/b.txt|c(.*)|https://d.net/e.txt|v(.*)'
|
||||
app.UpdateCheckIgnore = 'beta'
|
||||
|
||||
respmock = mock.Mock()
|
||||
@ -187,7 +187,7 @@ class CheckupdatesTest(unittest.TestCase):
|
||||
app.metadatapath = 'metadata/' + app.id + '.yml'
|
||||
app.CurrentVersionCode = 10108
|
||||
app.UpdateCheckMode = 'HTTP'
|
||||
app.UpdateCheckData = 'https://a.net/b.txt|c(.*)|https://d.net/e.txt|v(.*)'
|
||||
app.UpdateCheckData = r'https://a.net/b.txt|c(.*)|https://d.net/e.txt|v(.*)'
|
||||
app.UpdateCheckIgnore = 'beta'
|
||||
|
||||
respmock = mock.Mock()
|
||||
@ -206,10 +206,10 @@ class CheckupdatesTest(unittest.TestCase):
|
||||
app.RepoType = 'git'
|
||||
app.CurrentVersionCode = 10108
|
||||
app.UpdateCheckMode = 'Tags'
|
||||
app.UpdateCheckData = 'b.txt|c(.*)|e.txt|v(.*)'
|
||||
app.UpdateCheckData = r'b.txt|c(.*)|e.txt|v(.*)'
|
||||
|
||||
vcs = mock.Mock()
|
||||
vcs.latesttags.return_value = ['1.1.8', '1.1.9']
|
||||
vcs.latesttags.return_value = ['1.1.9', '1.1.8']
|
||||
with mock.patch(
|
||||
'pathlib.Path.read_text', lambda a: 'v1.1.9\nc10109'
|
||||
) as _ignored, mock.patch.object(
|
||||
@ -221,6 +221,50 @@ class CheckupdatesTest(unittest.TestCase):
|
||||
self.assertEqual(vername, '1.1.9')
|
||||
self.assertEqual(vercode, '10109')
|
||||
|
||||
app.UpdateCheckData = r'b.txt|c(.*)|.|v(.*)'
|
||||
with mock.patch(
|
||||
'pathlib.Path.read_text', lambda a: 'v1.1.0\nc10109'
|
||||
) as _ignored, mock.patch.object(
|
||||
Path, 'is_file'
|
||||
) as mock_path, mock.patch('fdroidserver.common.getvcs', return_value=vcs):
|
||||
_ignored # silence the linters
|
||||
mock_path.is_file.return_falue = True
|
||||
vername, vercode, _tag = fdroidserver.checkupdates.check_tags(app, None)
|
||||
self.assertEqual(vername, '1.1.0')
|
||||
self.assertEqual(vercode, '10109')
|
||||
|
||||
app.UpdateCheckData = r'b.txt|c(.*)||'
|
||||
with mock.patch(
|
||||
'pathlib.Path.read_text', lambda a: 'v1.1.9\nc10109'
|
||||
) as _ignored, mock.patch.object(
|
||||
Path, 'is_file'
|
||||
) as mock_path, mock.patch('fdroidserver.common.getvcs', return_value=vcs):
|
||||
_ignored # silence the linters
|
||||
mock_path.is_file.return_falue = True
|
||||
vername, vercode, _tag = fdroidserver.checkupdates.check_tags(app, None)
|
||||
self.assertEqual(vername, '1.1.9')
|
||||
self.assertEqual(vercode, '10109')
|
||||
|
||||
vcs.latesttags.return_value = ['Android-1.1.0', '1.1.8']
|
||||
app.UpdateCheckData = r'b.txt|c(.*)||Android-([\d.]+)'
|
||||
with mock.patch(
|
||||
'pathlib.Path.read_text', lambda a: 'v1.1.9\nc10109'
|
||||
) as _ignored, mock.patch.object(
|
||||
Path, 'is_file'
|
||||
) as mock_path, mock.patch('fdroidserver.common.getvcs', return_value=vcs):
|
||||
_ignored # silence the linters
|
||||
mock_path.is_file.return_falue = True
|
||||
vername, vercode, _tag = fdroidserver.checkupdates.check_tags(app, None)
|
||||
self.assertEqual(vername, '1.1.0')
|
||||
self.assertEqual(vercode, '10109')
|
||||
|
||||
app.UpdateCheckData = r'|\+(\d+)||Android-([\d.]+)'
|
||||
vcs.latesttags.return_value = ['Android-1.1.0+1']
|
||||
with mock.patch('fdroidserver.common.getvcs', return_value=vcs):
|
||||
vername, vercode, _tag = fdroidserver.checkupdates.check_tags(app, None)
|
||||
self.assertEqual(vername, '1.1.0')
|
||||
self.assertEqual(vercode, '1')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = optparse.OptionParser()
|
||||
|
Loading…
Reference in New Issue
Block a user