项目作者: Spinus1

项目描述 :
A simple python client for Bitbucket Server
高级语言: Python
项目地址: git://github.com/Spinus1/bpc.git
创建时间: 2020-01-31T08:23:50Z
项目社区:https://github.com/Spinus1/bpc

开源协议:GNU General Public License v3.0

下载


bpc

bpc Bitbucket Python Client is simple python client for Bitbucket Server that uses REST API through Stashy library

Dependencies

bpc is Python 3 based.
To install dependencies just launch:

  • pip install -r src/requirements.txt

Or install them manually

  1. pip install stashy
  2. pip install gitpython
  3. pip install click

Note: it is take for granted that your default Python installation is Python 3 if not just explicitly run bpc with Python 3: python3 bpc

Usage

Server configuration

bpc needs configuration for at least one Bitbucket server; to add new server configuration invoke command

  1. bpc config

and provide required details:

Non interactive way:

  1. bpc config --server-base-url "https://www.example.com/mybitbucketinstance" --server-shortcut mybitbucketinstance --username myuser --token mytoken

The first server added to bpc will be used as default one; to change it invoke:

  1. bpc config --set-default-server mybitbucketinstance

Note: default server is used only when querying for Bitbucket projects/repositories; the server configuration for managing Pull Request will be guess from local git repository

Pull Request

To manage Pull Requests bpc shall be invoked in folder containing a git repository

Creating PR

Invoke command:

  1. bpc pr

and provide required details:

Non interactive way:

  1. bpc pr --title "PR title" --description "PR description"

Additional settings

  • A default target branch can be specified for each needed repository, invoke command:
    1. bpc pr --set-default-branch myBranch
  • Repository name can be added to PR title: it can be enable disabled:
    1. bpc config --pr-set-repo-title [true|false]
  • To enabled disable request for PR description, use the following command:

    1. bpc config --pr-set-empty-description [true|false]
    • To enable/disable fetch changes before opening PR, use the following command:
      1. bpc config --pr-set-auto-fetch [true|false]
  • To enable/disable pushing changes to remote server before opening PR, use the following command:

    1. bpc config --pr-set-auto-push [true|false]
  • To specify Pull Request custom reviewers (per project), use the command:
    1. bpc config --set-default-pr-reviewers=userA,userB --project=projectName --server=serverShortcut
    • Note: Bitbucket username are case sensitive

Listing PRs

To list all the PR pending for a repository, just invoke command:

  1. bpc pr --list

Listing projects and repositories

List all the projects in default Bitbucket server (projects that the current user has access to):

  1. bpc remote

Add flag --server to specify the server that will be queried

List all repositories on a specific Bitbucket project:

  1. bpc remote --project PROJECT_NAME

Select editor

bcp is using Click library to edit information, to change default editor in Linux you can edit file ~/.selected_editor

Advanced tips

  • Some command line options can be shortened when the resulting command is unambigous
  • At your own risk, you can dig in ~/.bpc/config.json to spot for features not yet officially released

bpc development

TODO

  • Pretty print servers list
  • Select editor from bpc
  • Clone repositories directly from bpc

Debug configurations

You can retrieve some debug configurations is .vscode/.launch.json

Dependency list generation

  • Install pipreqs
    • pip install pipreqs
  • just launch pipreqs to get requirements.txt list

Building executable

  1. Install pyinstaller pip install pyinstaller
  2. Launch comand pyinstaller.exe src/bpc.spec

Inspiration

lab for gitlab has given me the idea to implement this client, but is very far to have comparable features