mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 15:00:30 +03:00
Merge branch 'tag_UpdateCheckData' into 'master'
Tag update check data See merge request fdroid/fdroidserver!937
This commit is contained in:
commit
023319efbb
2 changed files with 69 additions and 21 deletions
|
|
@ -130,7 +130,6 @@ def check_tags(app, pattern):
|
|||
|
||||
try_init_submodules(app, last_build, vcs)
|
||||
|
||||
hpak = None
|
||||
htag = None
|
||||
hver = None
|
||||
hcode = "0"
|
||||
|
|
@ -159,6 +158,36 @@ def check_tags(app, pattern):
|
|||
logging.debug("Check tag: '{0}'".format(tag))
|
||||
vcs.gotorevision(tag)
|
||||
|
||||
if app.UpdateCheckData:
|
||||
filecode, codeex, filever, verex = app.UpdateCheckData.split('|')
|
||||
vercode = None
|
||||
if len(filecode) > 0:
|
||||
filecontent = open(os.path.join(build_dir, filecode)).read()
|
||||
|
||||
m = re.search(codeex, filecontent)
|
||||
if not m:
|
||||
raise FDroidException("No RE match for version code")
|
||||
vercode = m.group(1).strip()
|
||||
|
||||
version = "??"
|
||||
if len(filever) > 0:
|
||||
if filever != '.':
|
||||
filecontent = open(os.path.join(build_dir, filever)).read()
|
||||
|
||||
m = re.search(verex, filecontent)
|
||||
if not m:
|
||||
raise FDroidException("No RE match for version")
|
||||
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
|
||||
else:
|
||||
for subdir in possible_subdirs(app):
|
||||
if subdir == '.':
|
||||
root_dir = build_dir
|
||||
|
|
@ -171,13 +200,10 @@ def check_tags(app, pattern):
|
|||
.format(subdir, version, vercode))
|
||||
i_vercode = common.version_code_string_to_int(vercode)
|
||||
if i_vercode > common.version_code_string_to_int(hcode):
|
||||
hpak = package
|
||||
htag = tag
|
||||
hcode = str(i_vercode)
|
||||
hver = version
|
||||
|
||||
if not hpak:
|
||||
return (None, "Couldn't find package ID", None)
|
||||
if hver:
|
||||
return (hver, hcode, htag)
|
||||
return (None, "Couldn't find any version information", None)
|
||||
|
|
@ -240,9 +266,10 @@ def check_repomanifest(app, branch=None):
|
|||
if vercode:
|
||||
logging.debug("Manifest exists in subdir '{0}'. Found version {1} ({2})"
|
||||
.format(subdir, version, vercode))
|
||||
if int(vercode) > int(hcode):
|
||||
i_vercode = common.version_code_string_to_int(vercode)
|
||||
if i_vercode > common.version_code_string_to_int(hcode):
|
||||
hpak = package
|
||||
hcode = str(int(vercode))
|
||||
hcode = str(i_vercode)
|
||||
hver = version
|
||||
|
||||
if not hpak:
|
||||
|
|
|
|||
|
|
@ -186,6 +186,27 @@ class CheckupdatesTest(unittest.TestCase):
|
|||
self.assertEqual(vername, None)
|
||||
self.assertEqual(vercode, 'Version 1.1.9-beta is ignored')
|
||||
|
||||
def test_check_tags_data(self):
|
||||
fdroidserver.checkupdates.options = mock.Mock()
|
||||
|
||||
app = fdroidserver.metadata.App()
|
||||
app.id = 'loop.starts.shooting'
|
||||
app.metadatapath = 'metadata/' + app.id + '.yml'
|
||||
app.RepoType = 'git'
|
||||
app.CurrentVersionCode = 10108
|
||||
app.UpdateCheckMode = 'Tags'
|
||||
app.UpdateCheckData = 'b.txt|c(.*)|e.txt|v(.*)'
|
||||
|
||||
vcs = mock.Mock()
|
||||
vcs.latesttags.return_value = ['1.1.8', '1.1.9']
|
||||
with mock.patch(
|
||||
'builtins.open', mock.mock_open(read_data='v1.1.9\nc10109')
|
||||
) as _ignored, mock.patch('fdroidserver.common.getvcs', return_value=vcs):
|
||||
_ignored # silence the linters
|
||||
vername, vercode, tag = fdroidserver.checkupdates.check_tags(app, None)
|
||||
self.assertEqual(vername, '1.1.9')
|
||||
self.assertEqual(vercode, '10109')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.chdir(os.path.dirname(__file__))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue