Merge pull request #988 from DimStar77/product_versions

AcceptCommand: update version of all products found in the project
This commit is contained in:
Ludwig Nussel 2017-07-07 08:38:25 +02:00 committed by GitHub
commit f6d08182dd

View File

@ -191,21 +191,20 @@ class AcceptCommand(object):
# XXX TODO - This method have `factory` in the name. Can be # XXX TODO - This method have `factory` in the name. Can be
# missleading. # missleading.
# If thereis not product defined for this project, show the
# warning and return.
if not self.api.cproduct:
warnings.warn('There is not product defined in the configuration file.')
return
project = self.api.project project = self.api.project
url = self.api.makeurl(['source', project, '_product', self.api.cproduct])
product = http_GET(url).read()
curr_version = date.today().strftime('%Y%m%d') curr_version = date.today().strftime('%Y%m%d')
new_product = re.sub(r'<version>\d{8}</version>', '<version>%s</version>' % curr_version, product) url = self.api.makeurl(['source', project], {'view': 'productlist'})
if product != new_product: products = ET.parse(http_GET(url)).getroot()
http_PUT(url + '?comment=Update+version', data=new_product) for product in products.findall('product'):
product_name = product.get('name') + '.product'
product_pkg = product.get('originpackage')
url = self.api.makeurl(['source', project, product_pkg, product_name])
product_spec = http_GET(url).read()
new_product = re.sub(r'<version>\d{8}</version>', '<version>%s</version>' % curr_version, product_spec)
if product_spec != new_product:
http_PUT(url + '?comment=Update+version', data=new_product)
service = {'cmd': 'runservice'} service = {'cmd': 'runservice'}