#2058 merge_scratch: Compare SCM URLs only if built from an SCM
Merged 4 years ago by tkopecek. Opened 4 years ago by tkopecek.
tkopecek/koji issue1903  into  master

file modified
+12 -6
@@ -60,6 +60,7 @@ 

  import koji.tasks

  import koji.xmlrpcplus

  from koji.context import context

+ from koji.daemon import SCM

  from koji.util import (

      base64encode,

      decode_bytes,
@@ -6842,11 +6843,12 @@ 

          task_info = task.getInfo(request=True)

      except koji.GenericError:

          raise koji.ImportError('invalid task: %s' % task_id)

+     task_params = koji.tasks.parse_task_params(task_info['method'], task_info['request'])

      if task_info['state'] != koji.TASK_STATES['CLOSED']:

          raise koji.ImportError('task %s did not complete successfully' % task_id)

      if task_info['method'] != 'build':

          raise koji.ImportError('task %s is not a build task' % task_id)

-     if len(task_info['request']) < 3 or not task_info['request'][2].get('scratch'):

+     if not task_params.get('scratch'):

          raise koji.ImportError('task %s is not a scratch build' % task_id)

  

      # sanity check the task, and extract data required for import
@@ -6901,15 +6903,19 @@ 

          raise koji.ImportError('%s did not complete successfully' % build['nvr'])

      if not build['task_id']:

          raise koji.ImportError('no task for %s' % build['nvr'])

-     build_task_info = Task(build['task_id']).getInfo(request=True)

      # Intentionally skip checking the build task state.

      # There are cases where the build can be valid even though the task has failed,

      # e.g. tagging failures.

  

-     # compare the task and build and make sure they are compatible with importing

-     if task_info['request'][0] != build_task_info['request'][0]:

-         raise koji.ImportError('SCM URLs for the task and build do not match: %s, %s' %

-                                (task_info['request'][0], build_task_info['request'][0]))

+     # Compare SCM URLs only if build from an SCM

+     build_task_info = Task(build['task_id']).getInfo(request=True)

+     build_task_params = koji.tasks.parse_task_params(build_task_info['method'],

+                                                      build_task_info['request'])

+     if 'src' in task_params and SCM.is_scm_url(task_params['src']):

+         # compare the task and build and make sure they are compatible with importing

+         if task_params['src'] != build_task_params['src']:

+             raise koji.ImportError('SCM URLs for the task and build do not match: %s, %s' %

+                                    (task_params['src'], build_task_params['src']))

      build_arches = set()

      for rpminfo in list_rpms(buildID=build['id']):

          if rpminfo['arch'] == 'src':

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

4 years ago

2 new commits added

  • use library functions
  • Compare SCM URLs only if build from an SCM
4 years ago

the code needs to be rebased after PR #2049 was merged

rebased onto ddbb626233f6a042963d2ceb9856836fcdbbb596

4 years ago

Looks good :smile:

We should probably parse the new task parameters at the beginning and update the check for the scratch parameter.

rebased onto 076d54c

4 years ago

Commit afc8217 fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

3 years ago