Metadata-Version: 2.3
Name: bucketcloner
Version: 0.3.0
Summary: Clone all repositories from a Bitbucket workspace.
Author: Philipp Lies
Author-email: Philipp Lies <phil@lies.io>
Classifier: Programming Language :: Python :: 3
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Dist: gitpython>=3.1.45
Requires-Dist: requests>=2.32.4
Requires-Python: >=3.8
Project-URL: Bug Tracker, https://github.com/phillies/bucketcloner/issues
Project-URL: Homepage, https://github.com/phillies/bucketcloner
Description-Content-Type: text/markdown

# Bucketcloner
Simple tool to list all your bitbucket workspaces and clone (all) repositories associated with these workspaces.

## Requirements
1. You need to know your Bitbucket account email. Can be found at https://bitbucket.org/account/settings/email/.
2. You need to create an API token here https://id.atlassian.com/manage-profile/security/api-tokens with read permissions for *account*, *workspace membership* and *repositories*.


| Command | Scopes |
|---|---|
| workspace | `read:user:bitbucket`, `read:workspace:bitbucket` |
| clone | `read:user:bitbucket`, `read:workspace:bitbucket`, `read:repository:bitbucket` |
| project | `read:user:bitbucket`, `read:workspace:bitbucket`, `read:project:bitbucket` |


Install bucketcloner either by cloning this repository and running `pip install .` or by installing it via `pip install bucketcloner`. Minimum required python version is 3.9.

Alternatively, you can run bucketcloner using `uvx`: `uvx bucketcloner --help`

Authentication for cloning the repository can be done via `https` and the API token or using an SSH key. IMPORTANT: When using `ssh` make sure you have added the bitbucket server ssh fingerprint to the known hosts, otherwise the command will fail. Run `git clone git@bitbucket.org:...` once manually to make sure the key is added.

You can pass your ssh key with `--ssh-key`, otherwise the users default ssh key will be used.

## List all workspaces
```bash
bucketcloner -e <email> -t <api_token> workspace
```
This lists all workspaces, including your personal workspace, where you have access.

## Clone workspace(s)
You can clone all repositories of all workspaces by simply calling
```bash
bucketcloner -e <email> -t <api_token> clone
```
This clones all repositories of all workspaces into the folders `workspace/repository` relative to the current directory.

To select specific workspace(s), add the `-w` option with workspace slug names separated by commas
```bash
bucketcloner -e <email> -t <api_token> -w workspace1,workspace2 clone
```

All existing repositories in the folders will be deleted and cloned again. To just skip existing repositories, add `--skip-existing` flag.
```bash
bucketcloner -e <email> -t <api_token> -w workspace1,workspace2 --skip-existing clone
```

Clone all repos from all workspaces with project PRO1 into /tmp with folder structure workspace/project/repo.
```bash
bucketcloner -e <email> -t <api_token> --project PRO1 --base-folder /tmp --project-folder clone
```

Clone all repos using an ssh key
```bash
bucketcloner -e <email> -t <api_token> --base-folder /tmp  --auth-mode ssh --ssh-key "/my/id_rsa" clone
```

List all projects in all workspaces
```bash
bucketcloner -e <email> -t <api_token> project
```

## Python example
The `example.ipynb` includes an example how to read the workspaces and download the repositories from within python.
