1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-12-27 02:16:12 +01:00

add "osc triggerreason", show detailed reason of a build trigger

This commit is contained in:
Adrian Schröter 2009-12-09 07:53:33 +01:00
parent 35a3a07c62
commit 3949066104
3 changed files with 67 additions and 0 deletions

1
NEWS
View File

@ -22,6 +22,7 @@
- added new commands "dependson" and "whatdependson" to find out which packages get - added new commands "dependson" and "whatdependson" to find out which packages get
triggered before checkin/request accept. triggered before checkin/request accept.
- add new "osc build --linksource" option, speeds up esp. image building a lot - add new "osc build --linksource" option, speeds up esp. image building a lot
- add "osc triggerreason" command to show detail reason, why a package got triggered for build
- Incompatible changes: - Incompatible changes:
* osc se now prints Project Package, instead of Package Project * osc se now prints Project Package, instead of Package Project
for easier copy&paste. for easier copy&paste.

View File

@ -2737,6 +2737,62 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print_buildlog(conf.config['apiurl'], *args) print_buildlog(conf.config['apiurl'], *args)
@cmdln.alias('tr')
def do_triggerreason(self, subcmd, opts, *args):
"""${cmd_name}: Show reason why a package got triggered to build
The server decides when a package needs to get rebuild, this command
shows the detailed reason for a package. A brief reason is also stored
in the jobhistory, which can be accessed via "osc jobhistory".
Trigger reasons might be:
- new build (never build yet or rebuild manually forced)
- source change (eg. on updating sources)
- meta change (packages which are used for building have changed)
- rebuild count sync (In case that it is configured to sync release numbers)
usage in package or project directory:
osc reason REPOSITORY ARCH
osc reason PROJECT PACKAGE REPOSITORY ARCH
${cmd_option_list}
"""
wd = os.curdir
args = slash_split(args)
project = package = repository = arch = None
if ( args is None or len(args) < 2):
self.print_repos()
if len(args) == 2: # 2
if is_package_dir('.'):
package = store_read_package(wd)
else:
raise oscerr.WrongArgs('package is not specified.')
project = store_read_project(wd)
apiurl = store_read_apiurl(wd)
repository = args[0]
arch = args[1]
elif len(args) == 4:
apiurl = conf.config['apiurl']
project = args[0]
package = args[1]
repository = args[2]
arch = args[3]
else:
raise oscerr.WrongArgs('Too many arguments.')
print apiurl, project, package, repository, arch
xml = show_package_trigger_reason(apiurl, project, package, repository, arch)
tree = ET.fromstring(xml)
reason = tree.find('explain').text
print reason
if reason == "meta change":
print "changed keys:"
for package in tree.findall('packagechange'):
print " ", package.get('change'), package.get('key')
# FIXME: the new osc syntax should allow to specify multiple packages # FIXME: the new osc syntax should allow to specify multiple packages
# FIXME: the command should optionally use buildinfo data to show all dependencies # FIXME: the command should optionally use buildinfo data to show all dependencies
@cmdln.alias('whatdependson') @cmdln.alias('whatdependson')

View File

@ -2039,6 +2039,16 @@ def show_project_conf(apiurl, prj):
return f.readlines() return f.readlines()
def show_package_trigger_reason(apiurl, prj, pac, repo, arch):
url = makeurl(apiurl, ['build', prj, repo, arch, pac, '_reason'])
try:
f = http_GET(url)
return f.read()
except urllib2.HTTPError, e:
e.osc_msg = 'Error getting trigger reason for project \'%s\' package \'%s\'' % (prj, pac)
raise
def show_package_meta(apiurl, prj, pac): def show_package_meta(apiurl, prj, pac):
url = makeurl(apiurl, ['source', prj, pac, '_meta']) url = makeurl(apiurl, ['source', prj, pac, '_meta'])
try: try: