Skip to content

Commit

Permalink
Merge pull request #988 from DimStar77/product_versions
Browse files Browse the repository at this point in the history
AcceptCommand: update version of all products found in the project
  • Loading branch information
lnussel committed Jul 7, 2017
2 parents 290490e + bd4e71e commit f6d0818
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions osclib/accept_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,21 +191,20 @@ def update_factory_version(self):
# XXX TODO - This method have `factory` in the name. Can be
# 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
url = self.api.makeurl(['source', project, '_product', self.api.cproduct])

product = http_GET(url).read()
curr_version = date.today().strftime('%Y%m%d')
new_product = re.sub(r'<version>\d{8}</version>', '<version>%s</version>' % curr_version, product)

if product != new_product:
http_PUT(url + '?comment=Update+version', data=new_product)
url = self.api.makeurl(['source', project], {'view': 'productlist'})

products = ET.parse(http_GET(url)).getroot()
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'}

Expand Down

0 comments on commit f6d0818

Please sign in to comment.