How to use stashy - 10 common examples

To help you get started, we’ve selected a few stashy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cosmin / stashy / tests / test_client.py View on Github external
def test_url_with_slash_prefix(self):
        client = StashClient("http://example.com/stash")
        self.assertEqual("http://example.com/stash/rest/api/1.0/admin/groups", client.url("/api/1.0/admin/groups"))
github cosmin / stashy / tests / test_client.py View on Github external
def test_url_without_slash_prefix(self):
        client = StashClient("http://example.com/stash")
        self.assertEqual("http://example.com/stash/rest/api/1.0/admin/groups", client.url("api/1.0/admin/groups"))
github StackStorm-Exchange / stackstorm-bitbucket / sensors / repository_sensor.py View on Github external
if not all(['repository' in x and 'branches' in x for x in self.targets]):
            raise ValueError('"repository" and "branches" are mandatory in "sensor.target"')

        if not all([len(x['repository'].split('/')) == 2 for x in self.targets]):
            raise ValueError('Invalid repository name is specified in the "targets" parameter')

        self.TIMEOUT_SECONDS = sensor_config.get('timeout', self.TIMEOUT_SECONDS)

        # initialize global parameter
        self.commits = {}

        self.service_type = sensor_config.get('bitbucket_type')
        if self.service_type == 'server':
            # initialization for BitBucket Server
            self.client = stashy.connect(sensor_config.get('bitbucket_server_url'),
                                         self._config.get('username'),
                                         self._config.get('password'))

            self._init_server_last_commit()
        elif self.service_type == 'cloud':
            # initialization for BitBucket Cloud
            self.client = Client(BasicAuthenticator(
                self._config.get('username'),
                self._config.get('password'),
                self._config.get('email'),
            ))
            self._init_cloud_last_commit()
        else:
            raise ValueError('specified bitbucket type (%s) is not supported' % self.service_type)
        self._increment_event_id()
github StackStorm-Exchange / stackstorm-bitbucket / sensors / repository_sensor.py View on Github external
last_commit = commits.next()

            if last_commit:
                return datetime.fromtimestamp(last_commit['authorTimestamp'] / 1000)
            else:
                return datetime.strptime('1900-01-01 00:00:00', self.DATE_FORMAT)

        for target in self.targets:
            (proj, repo) = target['repository'].split('/')

            for branch in target['branches']:
                try:
                    self._set_last_commit_time(target['repository'],
                                               branch,
                                               _last_ctime(proj, repo, branch))
                except stashy.errors.NotFoundException as e:
                    self._logger.warning("branch(%s) doesn't exist in the repository(%s) [%s]" %
                                         (branch, target['repository'], e))
github cosmin / stashy / stashy / repos.py View on Github external
def browse(self, path='', at=None, type=False, blame='', noContent=''):
        """
        Retrieve a page of content for a file path at a specified revision.
        """
        params = {}
        if at is not None:
            params['at'] = at
        if type:
            params['type'] = type
            return response_or_error(lambda: self._client.get(self.url('/browse/' + path), params=params))()
        else:
            if blame:
                params['blame'] = blame
            if noContent:
                params['noContent'] = noContent

            return self.paginate("/browse/" + path, params=params, values_key='lines')
github cosmin / stashy / stashy / repos.py View on Github external
    @response_or_error
    def get(self):
        """
        Retrieve the repository
        """
        return self._client.get(self.url())
github cosmin / stashy / stashy / pullrequests.py View on Github external
    @response_or_error
    def approve(self):
        """
        Approve a pull request as the current user. Implicitly adds the user as a participant if they are not already.
        """
        data = dict(approved=True, status="approved")
        return self._client.put(self.url("/participants/%s/" % self._client._session.auth[0]), data=data)
github cosmin / stashy / stashy / pullrequests.py View on Github external
    @response_or_error
    def create(self, title, fromRef, toRef, description='', state='OPEN', reviewers=None):
        """
        Create a new pull request between two branches.
        """
        data = dict(title=title,
                    description=description,
                    fromRef=self._make_ref(fromRef, "fromRef"),
                    toRef=self._make_ref(toRef, "toRef"),
                    state=state)

        if reviewers is not None:
            data['reviewers'] = []
            for reviewer in reviewers:
                data['reviewers'].append({"user": dict(name=reviewer)})

        return self._client.post(self.url(""), data=data)
github cosmin / stashy / stashy / ssh.py View on Github external
    @response_or_error
    def get(self, user):
        """
        Retrieve the keys matching the supplied user.
        """
        params = dict(user=user)
        return self._client.get(self.url(""), params=params)
github cosmin / stashy / stashy / repos.py View on Github external
    @response_or_error
    def _get_forkable(self):
        """
        Args:
            N/A
        Returns:
            (bool): True if repo is forkable, False if it is not forkable
        """
        return self._client.get(self.url())