#674 store git commit hash to build.source
Merged 2 years ago by mikem. Opened 2 years ago by tkopecek.
tkopecek/koji issue550  into  master

file modified

@@ -868,6 +868,10 @@ 

          h = self.readSRPMHeader(srpm)

          data = koji.get_header_fields(h,['name','version','release','epoch'])

          data['task_id'] = self.id

+         if getattr(self, 'source', False):

+             data['source'] = self.source['source']

+             data['extra'] = { 'source': {'url': self.source['url']}}


          extra_arches = None

          self.logger.info("Reading package config for %(name)s" % data)

          pkg_cfg = self.session.getPackageConfig(dest_tag,data['name'],event=self.event_id)

@@ -933,6 +937,7 @@ 


          # wait for subtask to finish

          result = self.wait(task_id)[task_id]

+         self.source = result['source']

          srpm = result['srpm']

          return srpm


@@ -4559,12 +4564,14 @@ 

          brootid = broot.id

          log_files = glob.glob('%s/*.log' % broot.resultdir())


+         source = scm.get_source()



          return {'srpm': "%s/%s" % (uploadpath, srpm_name),

                  'logs': ["%s/%s" % (uploadpath, os.path.basename(f))

                                          for f in log_files],

                  'brootid': brootid,

+                 'source': source,



  class TagNotificationTask(BaseTaskHandler):

file modified

@@ -32,6 +32,7 @@ 

  from fnmatch import fnmatch

  import base64

  import time

+ import subprocess

  import sys

  import traceback

  import errno

@@ -501,9 +502,23 @@ 

                  rel_path = '../' * len(path_comps.split('/'))

                  os.symlink(rel_path + 'common', '%s/../common' % sourcedir)


+         self.sourcedir = sourcedir

          return sourcedir


  ## END kojikamid dup

+     def get_source(self):

+         r = {

+             'url': self.url,

+             'source': self.url,

+         }

+         if self.scmtype.startswith('GIT'):

+             cmd = ['git', 'rev-parse', 'HEAD']

+             commit = subprocess.check_output(cmd, cwd=self.sourcedir).strip()

+             if '#' in self.url:

+                 r['source'] = '%s#%s' % (self.url[self.url.find('#')], commit)

+             else:

+                 r['source'] = '%s#%s' % (self.url, commit)

+         return r



  class TaskManager(object):

Git HEAD commit hash is now stored in build.info field. this field is
currently used by content generators, but not by other builds. Also
original checked out url is stored in build.extra.url field.

Fixes: https://pagure.io/koji/issue/550

Let's discuss this solution proposal.

/me finds out there is no subscribe button on PR :(

/me finds out there is no subscribe button on PR :(


In the meantime, we could discuss on the issue instead I guess.

this getattr needs a default or it will fail for many cases

This is running after broot.expire(), which I think sets up a race condition. (As soon as broot is expired, the main kojid process could clear it, and scmdir with it).

I think as long as we're here, I'd like to start populating build.source for all rpm builds, not just rpm builds from git.

rebased onto 120b73e5720597383de5edfcc5a439d35d58b918

2 years ago

Fixed and continuing discussion in #550

1 new commit added

  • store source also for CVS/SVN
2 years ago

1 new commit added

  • store original url for non-git scms
2 years ago

rebased onto a677e258fdec41a9ceee9316a422daf53492c022

2 years ago

rebased onto c97728c

2 years ago

@mikem looks like there is no support for non-git SCMs, are there more changes you would like to see?

@mikem looks like there is no support for non-git SCMs, are there more changes you would like to see?

With the additions above, we will set the source field for any scm, however it is only normalized to include a commit hash with git.

I'm open to doing something similar for other scms, but it is unclear to me quite how that should look. For this PR, git is the main concern.

changes here:

I'm unfamiliar with koji's source code, but these changes looks fine to me :)

@tkopecek, do those changes look ok to you?

@mikem your proposed changes look good to me.

Commit cedd6ee fixes this pull-request

Pull-Request has been merged by mikem

2 years ago