diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2022-10-15 21:44:40 +0200 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2022-10-15 21:44:40 +0200 |
commit | b7aa78ba05d3882436145b672c0493fba0083c80 (patch) | |
tree | aa9427ef9eed2dc5f860ea6f6f9a4a102fccf5d9 | |
parent | Makefile: add venv-update command (diff) | |
download | cgitize-b7aa78ba05d3882436145b672c0493fba0083c80.tar.gz cgitize-b7aa78ba05d3882436145b672c0493fba0083c80.zip |
bump dependencies
Unfortunately, atlassian-python-api doesn't follow the "same major
version = no breakage" principle, and happily broke a number of things
between 3.25.0 and 3.28.1. Oh well, let's fix the version at 3.28.X, I
guess.
-rw-r--r-- | cgitize/bitbucket.py | 16 | ||||
-rw-r--r-- | cgitize/repo.py | 12 | ||||
-rw-r--r-- | requirements.txt | 22 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | test/unit/test_bitbucket.py | 18 |
5 files changed, 34 insertions, 36 deletions
diff --git a/cgitize/bitbucket.py b/cgitize/bitbucket.py index 052d2c1..f2a449f 100644 --- a/cgitize/bitbucket.py +++ b/cgitize/bitbucket.py @@ -17,21 +17,19 @@ class Bitbucket: def get_repo(self, repo): try: - return self._impl.repositories.get(repo.id) + parts = repo.id.split('/') + if len(parts) != 2: + raise ValueError(f'repository ID must be in the USER/NAME format: {repo.id}') + user, name = parts + return self._impl.repositories.get(user, name) except HTTPError: logging.error("Couldn't fetch repository: %s", repo.id) raise def get_user_repos(self, user): try: - page = 1 - while True: - params = {'page': page} - response = self._impl.repositories.get(user.name, params=params) - yield from iter(response['values']) - if 'next' not in response: - break - page += 1 + workspace = self._impl.workspaces.get(user.name) + yield from workspace.repositories.each() except HTTPError: logging.error("Couldn't fetch user repositories: %s", user.name) raise diff --git a/cgitize/repo.py b/cgitize/repo.py index dd55b17..2c9398e 100644 --- a/cgitize/repo.py +++ b/cgitize/repo.py @@ -41,18 +41,18 @@ class Repo: @staticmethod def from_bitbucket(src, config, subdir=None): - name = src['name'] - desc = src['description'] - homepage = src['links']['html']['href'] - owner = src['owner']['display_name'] + name = src.name + desc = src.description + homepage = src.get_link('html') + owner = src.data['owner']['display_name'] - https_urls = [link for link in src['links']['clone'] if link['name'] == 'https'] + https_urls = [link for link in src.data['links']['clone'] if link['name'] == 'https'] if len(https_urls) != 1: raise RuntimeError(f"no https:// clone URL for repository '{name}'?!") # Bitbucket leaves the username in the URL... Sigh. https_url = url_remove_auth(https_urls[0]['href']) - ssh_urls = [link for link in src['links']['clone'] if link ['name'] == 'ssh'] + ssh_urls = [link for link in src.data['links']['clone'] if link ['name'] == 'ssh'] if len(ssh_urls) != 1: raise RuntimeError(f"no ssh:// clone URL for repository '{name}'?!") ssh_url = ssh_urls[0]['href'] diff --git a/requirements.txt b/requirements.txt index d191b5c..f3bdadf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,19 +1,19 @@ -atlassian-python-api==3.25.0 -certifi==2022.5.18.1 -cffi==1.15.0 -charset-normalizer==2.0.12 +atlassian-python-api==3.28.1 +certifi==2022.9.24 +cffi==1.15.1 +charset-normalizer==2.1.1 Deprecated==1.2.13 -idna==3.3 -oauthlib==3.2.0 +idna==3.4 +oauthlib==3.2.1 pycparser==2.21 -PyGithub==1.55 -PyJWT==2.4.0 +PyGithub==1.56 +PyJWT==2.5.0 PyNaCl==1.5.0 python-gitlab==2.10.1 -requests==2.27.1 +requests==2.28.1 requests-oauthlib==1.3.1 -requests-toolbelt==0.9.1 +requests-toolbelt==0.10.0 six==1.16.0 tomli==1.2.3 -urllib3==1.26.9 +urllib3==1.26.12 wrapt==1.14.1 @@ -20,7 +20,7 @@ classifiers = [options] install_requires = - atlassian-python-api ~= 3.0 + atlassian-python-api ~= 3.28.0 PyGithub ~= 1.0 python-gitlab ~= 2.0 tomli ~= 1.0 diff --git a/test/unit/test_bitbucket.py b/test/unit/test_bitbucket.py index 7a070ce..fdf55ea 100644 --- a/test/unit/test_bitbucket.py +++ b/test/unit/test_bitbucket.py @@ -15,22 +15,22 @@ class BitbucketTests(unittest.TestCase): def test_nonexistent_repo(self): with self.assertRaises(HTTPError): - self.bitbucket.repositories.get('doesnot/exist') + self.bitbucket.repositories.get('doesnot', 'exist') def test_existing_repo(self): - r = self.bitbucket.repositories.get('egor-tensin/cgitize-test-repository') - self.assertEqual(r['name'], 'cgitize-test-repository') - self.assertEqual(r['description'], 'Test cgitize repository') + r = self.bitbucket.repositories.get('egor-tensin', 'cgitize-test-repository') + self.assertEqual(r.name, 'cgitize-test-repository') + self.assertEqual(r.description, 'Test cgitize repository') - self.assertEqual(r['owner']['display_name'], 'Egor Tensin') - self.assertEqual(r['owner']['nickname'], 'egor-tensin') + self.assertEqual(r.data['owner']['display_name'], 'Egor Tensin') + self.assertEqual(r.data['owner']['nickname'], 'egor-tensin') - self.assertEqual(r['links']['html']['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository') + self.assertEqual(r.get_link('html'), 'https://bitbucket.org/egor-tensin/cgitize-test-repository') - clone_urls = [link for link in r['links']['clone'] if link['name'] == 'https'] + clone_urls = [link for link in r.data['links']['clone'] if link['name'] == 'https'] self.assertEqual(len(clone_urls), 1) self.assertEqual(clone_urls[0]['href'], 'https://bitbucket.org/egor-tensin/cgitize-test-repository.git') - ssh_urls = [link for link in r['links']['clone'] if link['name'] == 'ssh'] + ssh_urls = [link for link in r.data['links']['clone'] if link['name'] == 'ssh'] self.assertEqual(len(ssh_urls), 1) self.assertEqual(ssh_urls[0]['href'], 'git@bitbucket.org:egor-tensin/cgitize-test-repository.git') |