Beispiel #1
0
    def getChange(self, event, refresh=False):
        project = self.source.getProject(event.project_name)
        if event.change_number:
            self.log.info("Getting change for %s#%s" %
                          (project, event.change_number))
            change = self._getChange(project,
                                     event.change_number,
                                     event.patch_number,
                                     refresh=refresh,
                                     event=event)
            change.is_current_patchset = (
                change.patchset == event.patch_number)
        else:
            self.log.info("Getting change for %s ref:%s" %
                          (project, event.ref))
            if event.ref and event.ref.startswith('refs/tags/'):
                change = Tag(project)
                change.tag = event.tag
                change.branch = None
            elif event.ref and event.ref.startswith('refs/heads/'):
                change = Branch(project)
                change.branch = event.branch
            else:
                change = Ref(project)
                change.branch = None
            change.ref = event.ref
            change.oldrev = event.oldrev
            change.newrev = event.newrev
            change.url = self.getGitwebUrl(project, sha=event.newrev)

            change.files = None
        return change
Beispiel #2
0
    def getChange(self, event, refresh=False):
        """Get the change representing an event."""

        project = self.source.getProject(event.project_name)
        if event.change_number:
            change = self._getChange(project,
                                     event.change_number,
                                     event.patch_number,
                                     refresh=refresh)
            change.url = event.change_url
            change.uris = [
                '%s/%s/pull/%s' % (self.server, project, change.number),
            ]
            change.source_event = event
            change.is_current_patchset = (
                change.pr.get('head').get('sha') == event.patch_number)
        else:
            if event.ref and event.ref.startswith('refs/tags/'):
                change = Tag(project)
                change.tag = event.ref[len('refs/tags/'):]
            elif event.ref and event.ref.startswith('refs/heads/'):
                change = Branch(project)
                change.branch = event.ref[len('refs/heads/'):]
            else:
                change = Ref(project)
            change.ref = event.ref
            change.oldrev = event.oldrev
            change.newrev = event.newrev
            change.url = self.getGitwebUrl(project, sha=event.newrev)
            change.source_event = event
            if hasattr(event, 'commits'):
                change.files = self.getPushedFileNames(event)
        return change
Beispiel #3
0
 def getChange(self, event, refresh=False):
     if event.ref and event.ref.startswith('refs/heads/'):
         branch = event.ref[len('refs/heads/'):]
         change = self._change_cache.get(branch, {}).get(event.newrev)
         if change:
             return change
         project = self.getProject(event.project_name)
         change = Branch(project)
         change.branch = branch
         for attr in ('ref', 'oldrev', 'newrev'):
             setattr(change, attr, getattr(event, attr))
         change.url = ""
         change.files = self.getChangeFilesUpdated(event.project_name,
                                                   change.branch,
                                                   event.oldrev)
         self._change_cache.setdefault(branch, {})[event.newrev] = change
     elif event.ref:
         # catch-all ref (ie, not a branch or head)
         project = self.getProject(event.project_name)
         change = Ref(project)
         for attr in ('ref', 'oldrev', 'newrev'):
             setattr(change, attr, getattr(event, attr))
         change.url = ""
     else:
         self.log.warning("Unable to get change for %s" % (event, ))
         change = None
     return change
Beispiel #4
0
 def getChange(self, event, refresh=False):
     if event.change_number:
         change = self._getChange(event.change_number,
                                  event.patch_number,
                                  refresh=refresh)
     elif event.ref and event.ref.startswith('refs/tags/'):
         project = self.source.getProject(event.project_name)
         change = Tag(project)
         change.tag = event.ref[len('refs/tags/'):]
         change.ref = event.ref
         change.oldrev = event.oldrev
         change.newrev = event.newrev
         change.url = self._getWebUrl(project, sha=event.newrev)
     elif event.ref and not event.ref.startswith('refs/'):
         # Pre 2.13 Gerrit ref-updated events don't have branch prefixes.
         project = self.source.getProject(event.project_name)
         change = Branch(project)
         change.branch = event.ref
         change.ref = 'refs/heads/' + event.ref
         change.oldrev = event.oldrev
         change.newrev = event.newrev
         change.url = self._getWebUrl(project, sha=event.newrev)
     elif event.ref and event.ref.startswith('refs/heads/'):
         # From the timer trigger or Post 2.13 Gerrit
         project = self.source.getProject(event.project_name)
         change = Branch(project)
         change.ref = event.ref
         change.branch = event.ref[len('refs/heads/'):]
         change.oldrev = event.oldrev
         change.newrev = event.newrev
         change.url = self._getWebUrl(project, sha=event.newrev)
     elif event.ref:
         # catch-all ref (ie, not a branch or head)
         project = self.source.getProject(event.project_name)
         change = Ref(project)
         change.ref = event.ref
         change.oldrev = event.oldrev
         change.newrev = event.newrev
         change.url = self._getWebUrl(project, sha=event.newrev)
     else:
         self.log.warning("Unable to get change for %s" % (event, ))
         change = None
     return change
Beispiel #5
0
 def getChange(self, event, refresh=False):
     if event.ref and event.ref.startswith('refs/heads/'):
         branch = event.ref[len('refs/heads/'):]
         change = self._change_cache.get(branch, {}).get(event.newrev)
         if change:
             return change
         project = self.getProject(event.project_name)
         change = Branch(project)
         change.branch = branch
         for attr in ('ref', 'oldrev', 'newrev'):
             setattr(change, attr, getattr(event, attr))
         change.url = ""
         change.files = self.getChangeFilesUpdated(
             event.project_name, change.branch, event.oldrev)
         self._change_cache.setdefault(branch, {})[event.newrev] = change
     elif event.ref:
         # catch-all ref (ie, not a branch or head)
         project = self.getProject(event.project_name)
         change = Ref(project)
         for attr in ('ref', 'oldrev', 'newrev'):
             setattr(change, attr, getattr(event, attr))
         change.url = ""
     else:
         self.log.warning("Unable to get change for %s" % (event,))
         change = None
     return change
Beispiel #6
0
    def getChange(self, event, refresh=False):
        project = self.source.getProject(event.project_name)
        if event.change_number:
            self.log.info("Getting change for %s#%s" %
                          (project, event.change_number))
            change = self._getChange(project,
                                     event.change_number,
                                     event.patch_number,
                                     refresh=refresh,
                                     event=event)
            change.source_event = event
            change.is_current_patchset = (
                change.pr.get('commit_stop') == event.patch_number)
        else:
            self.log.info("Getting change for %s ref:%s" %
                          (project, event.ref))
            if event.ref and event.ref.startswith('refs/tags/'):
                change = Tag(project)
                change.tag = event.tag
                change.branch = None
            elif event.ref and event.ref.startswith('refs/heads/'):
                change = Branch(project)
                change.branch = event.branch
            else:
                change = Ref(project)
                change.branch = None
            change.ref = event.ref
            change.oldrev = event.oldrev
            change.newrev = event.newrev
            change.url = self.getGitwebUrl(project, sha=event.newrev)

            # Pagure does not send files details in the git-receive event.
            # Explicitly set files to None and let the pipelines processor
            # call the merger asynchronuously
            change.files = None

            change.source_event = event

        return change