Пример #1
0
 def makeSnap(self, context):
     if IBranch.providedBy(context):
         return self.factory.makeSnap(branch=context)
     else:
         if IGitRepository.providedBy(context):
             [context] = self.factory.makeGitRefs(repository=context)
         return self.factory.makeSnap(git_ref=context)
Пример #2
0
 def initial_values(self):
     distroseries = BuildableDistroSeries.findSeries(self.user)
     series = [
         series for series in distroseries
         if series.status in (SeriesStatus.CURRENT,
                              SeriesStatus.DEVELOPMENT)
     ]
     if IBranch.providedBy(self.context):
         recipe_text = MINIMAL_RECIPE_TEXT_BZR % self.context.identity
     elif IGitRepository.providedBy(self.context):
         default_ref = None
         if self.context.default_branch is not None:
             default_ref = self.context.getRefByPath(
                 self.context.default_branch)
         if default_ref is not None:
             branch_name = default_ref.name
         else:
             branch_name = "ENTER-BRANCH-NAME"
         recipe_text = MINIMAL_RECIPE_TEXT_GIT % (self.context.identity,
                                                  branch_name)
     elif IGitRef.providedBy(self.context):
         recipe_text = MINIMAL_RECIPE_TEXT_GIT % (
             self.context.repository.identity, self.context.name)
     else:
         raise AssertionError("Unsupported context: %r" % (self.context, ))
     return {
         'name': self._find_unused_name(self.user),
         'recipe_text': recipe_text,
         'owner': self.user,
         'distroseries': series,
         'build_daily': True,
         'use_ppa': EXISTING_PPA,
     }
Пример #3
0
    def create(cls, requestor, artifacts=None, grantee=None, pillar=None,
               information_types=None):
        """See `IRemoveArtifactSubscriptionsJob`."""

        bug_ids = []
        branch_ids = []
        gitrepository_ids = []
        specification_ids = []
        if artifacts:
            for artifact in artifacts:
                if IBug.providedBy(artifact):
                    bug_ids.append(artifact.id)
                elif IBranch.providedBy(artifact):
                    branch_ids.append(artifact.id)
                elif IGitRepository.providedBy(artifact):
                    gitrepository_ids.append(artifact.id)
                elif ISpecification.providedBy(artifact):
                    specification_ids.append(artifact.id)
                else:
                    raise ValueError(
                        'Unsupported artifact: %r' % artifact)
        information_types = [
            info_type.value for info_type in information_types or []
        ]
        metadata = {
            'bug_ids': bug_ids,
            'branch_ids': branch_ids,
            'gitrepository_ids': gitrepository_ids,
            'specification_ids': specification_ids,
            'information_types': information_types,
            'requestor.id': requestor.id
        }
        return super(RemoveArtifactSubscriptionsJob, cls).create(
            pillar, grantee, metadata)
Пример #4
0
 def _recipe_names(self):
     """A generator of recipe names."""
     # +junk-daily doesn't make a very good recipe name, so use the
     # branch name in that case; similarly for personal Git repositories.
     if ((IBranch.providedBy(self.context)
          and self.context.target.allow_recipe_name_from_target)
             or ((IGitRepository.providedBy(self.context)
                  or IGitRef.providedBy(self.context))
                 and self.context.namespace.allow_recipe_name_from_target)):
         branch_target_name = self.context.target.name.split('/')[-1]
     else:
         branch_target_name = self.context.name
     yield "%s-daily" % branch_target_name
     counter = itertools.count(1)
     while True:
         yield "%s-daily-%s" % (branch_target_name, counter.next())
Пример #5
0
 def getInputValue(self):
     """See `IInputWidget`."""
     self.setUpSubWidgets()
     try:
         repository = self.repository_widget.getInputValue()
     except MissingInputError:
         if self.context.required:
             raise WidgetInputError(
                 self.name, self.label,
                 LaunchpadValidationError(
                     "Please choose a Git repository."))
         else:
             return None
     except ConversionError:
         entered_name = self.request.form_ng.getOne("%s.repository" %
                                                    self.name)
         raise WidgetInputError(
             self.name, self.label,
             LaunchpadValidationError(
                 "There is no Git repository named '%s' registered in "
                 "Launchpad." % entered_name))
     if self.path_widget.hasInput():
         path = self.path_widget.getInputValue()
     else:
         path = None
     if not path:
         if self.context.required:
             raise WidgetInputError(
                 self.name, self.label,
                 LaunchpadValidationError(
                     "Please enter a Git branch path."))
         else:
             return
     if self.allow_external and not IGitRepository.providedBy(repository):
         ref = getUtility(IGitRefRemoteSet).new(repository, path)
     else:
         ref = repository.getRefByPath(path)
         if ref is None:
             raise WidgetInputError(
                 self.name, self.label,
                 LaunchpadValidationError(
                     "The repository at %s does not contain a branch named "
                     "'%s'." % (repository.display_name, path)))
     return ref
Пример #6
0
 def checkVerificationContext(self, context, **kwargs):
     """See `MacaroonIssuerBase`."""
     if not IGitRepository.providedBy(context):
         raise BadMacaroonContext(context)
     return context