checkupdates: let Tags detect subdir changes

Up until now, this was done only if no overall version could be found. But in
tags, we would get stuck with an old version from an old tag and not see
subdir changes in new tags.
This commit is contained in:
Daniel Martí 2015-10-25 12:00:02 +01:00
parent fa55ec0e87
commit af947809b5

View file

@ -117,11 +117,8 @@ def check_tags(app, pattern):
vcs.gotorevision(None) vcs.gotorevision(None)
root_dir = build_dir
flavours = [] flavours = []
if len(app['builds']) > 0: if len(app['builds']) > 0:
if app['builds'][-1]['subdir']:
root_dir = os.path.join(build_dir, app['builds'][-1]['subdir'])
if app['builds'][-1]['gradle']: if app['builds'][-1]['gradle']:
flavours = app['builds'][-1]['gradle'] flavours = app['builds'][-1]['gradle']
@ -145,20 +142,19 @@ def check_tags(app, pattern):
logging.debug("Check tag: '{0}'".format(tag)) logging.debug("Check tag: '{0}'".format(tag))
vcs.gotorevision(tag) vcs.gotorevision(tag)
# Only process tags where the manifest exists... for subdir in possible_subdirs(app):
paths = common.manifest_paths(root_dir, flavours) root_dir = os.path.join(build_dir, subdir)
version, vercode, package = \ paths = common.manifest_paths(root_dir, flavours)
common.parse_androidmanifests(paths, app['Update Check Ignore']) version, vercode, package = \
if not app_matches_packagename(app, package) or not version or not vercode: common.parse_androidmanifests(paths, app['Update Check Ignore'])
continue if app_matches_packagename(app, package) and version and vercode:
logging.debug("Manifest exists in subdir '{0}'. Found version {1} ({2})"
logging.debug("Manifest exists. Found version {0} ({1})" .format(subdir, version, vercode))
.format(version, vercode)) if int(vercode) > int(hcode):
if int(vercode) > int(hcode): hpak = package
hpak = package htag = tag
htag = tag hcode = str(int(vercode))
hcode = str(int(vercode)) hver = version
hver = version
if not hpak: if not hpak:
return (None, "Couldn't find package ID", None) return (None, "Couldn't find package ID", None)
@ -315,29 +311,32 @@ def dirs_with_manifest(startdir):
# Tries to find a new subdir starting from the root build_dir. Returns said # Tries to find a new subdir starting from the root build_dir. Returns said
# subdir relative to the build dir if found, None otherwise. # subdir relative to the build dir if found, None otherwise.
def check_changed_subdir(app): def possible_subdirs(app):
if app['Repo Type'] == 'srclib': if app['Repo Type'] == 'srclib':
build_dir = os.path.join('build', 'srclib', app['Repo']) build_dir = os.path.join('build', 'srclib', app['Repo'])
else: else:
build_dir = os.path.join('build', app['id']) build_dir = os.path.join('build', app['id'])
if not os.path.isdir(build_dir):
return None
flavours = [] flavours = []
if len(app['builds']) > 0 and app['builds'][-1]['gradle']: if len(app['builds']) > 0:
flavours = app['builds'][-1]['gradle'] build = app['builds'][-1]
if build['gradle']:
flavours = build['gradle']
subdir = build['subdir']
if subdir and os.path.isdir(os.path.join(build_dir, subdir)):
logging.debug("Adding possible subdir %s" % subdir)
yield subdir
for d in dirs_with_manifest(build_dir): for d in dirs_with_manifest(build_dir):
logging.debug("Trying possible dir %s." % d)
m_paths = common.manifest_paths(d, flavours) m_paths = common.manifest_paths(d, flavours)
package = common.parse_androidmanifests(m_paths, app['Update Check Ignore'])[2] package = common.parse_androidmanifests(m_paths, app['Update Check Ignore'])[2]
if app_matches_packagename(app, package): if app_matches_packagename(app, package):
logging.debug("Manifest exists in possible dir %s." % d) subdir = os.path.relpath(d, build_dir)
return os.path.relpath(d, build_dir) if subdir == '.':
continue
return None logging.debug("Adding possible subdir %s" % subdir)
yield subdir
def fetch_autoname(app, tag): def fetch_autoname(app, tag):
@ -414,21 +413,6 @@ def checkupdates_app(app, first=True):
version = None version = None
msg = 'Invalid update check method' msg = 'Invalid update check method'
if first and version is None and vercode == "Couldn't find package ID":
logging.warn("Couldn't find any version information. Looking for a subdir change...")
new_subdir = check_changed_subdir(app)
if new_subdir is None:
logging.warn("Couldn't find any new subdir.")
else:
logging.warn("Trying a new subdir: %s" % new_subdir)
new_build = {}
metadata.fill_build_defaults(new_build)
new_build['version'] = "Ignore"
new_build['vercode'] = "-1"
new_build['subdir'] = new_subdir
app['builds'].append(new_build)
return checkupdates_app(app, first=False)
if version and vercode and app['Vercode Operation']: if version and vercode and app['Vercode Operation']:
oldvercode = str(int(vercode)) oldvercode = str(int(vercode))
op = app['Vercode Operation'].replace("%c", oldvercode) op = app['Vercode Operation'].replace("%c", oldvercode)