-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from psadi/feature/repos
feature/repos
- Loading branch information
Showing
24 changed files
with
434 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,20 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-docstring-first | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: fix-encoding-pragma | ||
- id: requirements-txt-fixer | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-docstring-first | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: check-merge-conflict | ||
- id: check-toml | ||
- id: check-yaml | ||
- id: fix-encoding-pragma | ||
- id: requirements-txt-fixer | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: [--profile, black, --filter-files] | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: v0.0.264 | ||
hooks: | ||
- id: ruff | ||
args: [bb, --fix, --exit-non-zero-on-fix] | ||
|
||
|
||
- repo: https://github.com/commitizen-tools/commitizen | ||
rev: 3.2.1 | ||
hooks: | ||
- id: commitizen | ||
- id: commitizen-branch | ||
stages: | ||
- post-commit | ||
- push | ||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: v0.1.11 | ||
hooks: | ||
- id: ruff | ||
args: [bb, --fix, --exit-non-zero-on-fix] | ||
- id: ruff-format | ||
args: [bb] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
bb.repo.delete - deletes a bitbucket repository | ||
""" | ||
import json | ||
|
||
from typer import Exit, confirm | ||
|
||
from bb.utils.api import delete_repo | ||
from bb.utils.ini import parse | ||
from bb.utils.request import put | ||
from bb.utils.richprint import console, live_progress | ||
|
||
|
||
def archive_repository(project: str, repo: str, archive: bool) -> None: | ||
if not confirm( | ||
f"Proceed to {'archive' if archive else 'unarchive'} '{project}/{repo}'?" | ||
): | ||
raise Exit(code=1) | ||
|
||
username, token, bitbucket_host = parse() | ||
with live_progress( | ||
f"{'Archiving' if archive else 'Unarchiving' } Repository '{project}/{repo}' ... " | ||
) as live: | ||
request = put( | ||
delete_repo(bitbucket_host, project, repo), | ||
username, | ||
token, | ||
json.dumps({"archived": archive}), # type: ignore | ||
) | ||
|
||
if request[0] == 200: | ||
live.update(console.print("DONE", style="bold green")) | ||
|
||
if request[0] == 409: | ||
live.update(console.print("CONFLICT", style="bold yellow")) | ||
console.print( | ||
f"Message: {request[1]['errors'][0]['message']}", | ||
highlight=True, | ||
style="bold yellow", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import json | ||
|
||
from bb.utils.api import create_repo | ||
from bb.utils.ini import parse | ||
from bb.utils.request import post | ||
from bb.utils.richprint import console, live_progress | ||
|
||
|
||
def create_repository( | ||
project: str, repo: str, forkable: bool, default_branch: str | ||
) -> None: | ||
username, token, bitbucket_host = parse() | ||
with live_progress(f"Creating '{project}/{repo}' Repository ... ") as live: | ||
request = post( | ||
create_repo(bitbucket_host, project, repo), | ||
username, | ||
token, | ||
json.dumps( | ||
{ | ||
"name": repo, | ||
"slug": repo, | ||
"scmId": "git", | ||
"forkable": forkable, | ||
"project": {"key": project}, | ||
"defaultBranch": f"refs/heads/{default_branch}", | ||
} | ||
), # type: ignore | ||
) | ||
|
||
if request[0] == 200: | ||
live.update(console.print("DONE", style="bold green")) | ||
|
||
if request[0] == 409: | ||
live.update(console.print("CONFLICT", style="bold yellow")) | ||
console.print( | ||
f"Message: {request[1]['errors'][0]['message']}", | ||
highlight=True, | ||
style="bold yellow", | ||
) |
Oops, something went wrong.