Giter Club home page Giter Club logo

bitbucket-cmd's Introduction

Bitbucket command line interface based on https://github.com/germanrcuriel/jira-cmd

Currently it is able to do these things from the command line:

  • Store your encrypted bitbucket credentials
  • List pull requests
  • Create pull requets

Motivation

As a command line junky, I wanted to be able to create pull requests quickly without having to use bitbucket's browser interface. I also wanted to be able to list out all pull requests so I could be a more expedient merge master.

Installation

Install node.js.

Then, in your shell type:

$ npm install -g bitbucket-cmd

Usage

First use
$ bitbucket

It will prompte you for the repositories subdirectory url. IT AUTO-SUPPLIES THE PROPER BITBUCKET API URL PREFIX You type in your repo name (for example phase2tech/bla_dev_vm) and then hit return a couple times

Repository subdir URL: https://api.bitbucket.org/2.0/repositories/

then the username/password prompt should appear

Username: xxxxxx
Password: xxxxxx

PLEASE note this password is an APP PASSword as described here: https://confluence.atlassian.com/bitbucket/app-passwords-828781300.html and NOT your account password

Once you hit enter after the password then you should get this message:

Information stored!

This saves your credentials (base64 encoded) in the ~/.bitbucket-cmd folder. Named config.json You can set a BITBUCKET_CONFIG environment variable to use a different directory (this allows for multiple sources of bitbucket repos) than the default current-working-direct/.bitbucket-cmd.

Reviewers

Please note that the "reviwers" section is added to the config.json file. I've added check to see if this section is empty and just submit PR's without reviewers if necessary. However it is sensitive. Valid default reviewer syntax is as follows:

{
  "auth": {
    "url": "https://api.bitbucket.org/2.0/repositories/blabla/myawesomerepo/",
    "user": "yourbbusername",
    "token": "yourpasswordthatistokenizedforyou"
  },
  "reviewers": [
    { "username" : "yourbestbud" }
    ]
}

Your reviewers are setup in the bitbucket settings section on the bitbucket admin page of the repo. Please note the password is tokenized and hashed for you. So when prompted for the password just paste or type it in, and the bitbucket-cmd will tokenize it for you. That means what is stored in config.json is NOT what you typed in, just fyi.

Beware-of-the-json-death-by-brackets-syntax: Nested objects are a bitch - not much I can do about that.

Help

Usage: bitbucket [options] [command]

Commands:

pr

Sub-Options:

-h, --help     output usage information
-V, --version  output the version number

Each command have individual usage help (using --help or -h), so bitbucket pr -h will give pr specific help.

For example the pr command has these options

-l, --list                  List Open Pull Requests
-r, --merged                List Merged Pull Requests
-m, --merge <pr_num>        Merge Pull Request
-c, --create <title>        Create Pull Request
-d, --description <description>   Description for PR
-s, --source <branch name>  Source Branch
-t, --to <branch name>      Destination Branch
-f, --diff <pr_num>         Diff Pull Request
-d, --decline <pr_num>      Decline Pull Request

Usage:

bitbucket pr -l

The above command will output something like this:


 ID    Author        Source                             Destination     Title                                               State  Reviewers

 3126  wdranvaud     MTIC-1038-map-alpha-sort           release/1.6.16  MTIC-1038 views exposed filter alphabetical sor...  OPEN
 3125  wdranvaud     MTIC-1038-map-alpha-sort           develop         MTIC-1038 views exposed filter alphabetical sor...  OPEN   ezeedub
 3120  wdranvaud     MTIC-925-flag-button-fix           release/1.6.16  MTIC-925 fix CSS on marketplace flag as inappro...  OPEN
 3114  wdranvaud     MTIC-1044-audition-center-sidebar  release/1.6.16  MTIC-1044 display Audition Central on sidebar       OPEN
 3107  wdranvaud     MTIC-894-question-title-reversed   release/1.6.16  MTIC-894 place title above body of question         OPEN
 3082  wdranvaud     MTIC-1067-default-publish-locale   release/1.6.16  MTIC-1067 display translated content by default...  OPEN
 2968  ryan_smylski  feature/MTIE-471--echeck           release/2.0.0   [MTIE-471] - Rounded out xpresspay for e-check ...  OPEN   dan_shumaker
 3066  ezeedub       feature/MTIE-471--echeck           ecommdevelop    [MTIE-471]  Rounded out xpresspay for e-check p...  OPEN

Usage:

To create a pull request you could do it like this:

bitbucket pr -c "test pr" -s feature/MTIE-503-Package-Content -t master

It will create a pull request and output something like this:

Create Pull Request
Created PR @ https://api.bitbucket.org/2.0/repositories/phase2tech/mti_cms/pullrequests/3127

I really hope you enjoy this tool!

bitbucket-cmd's People

Contributors

danshumaker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bitbucket-cmd's Issues

"npm install -g bitbucket-cmd" - fails

Hi there,

I have some cmdline junkies in my team who want to use this, but I tried doing an install and it fails with:

c:\dev\repo\bitbucket\afp-banklet>npm install -g bitbucket-cmd
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\dev\\node-current\\node.exe" "C:\\dev\\node-current\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bitbucket-cmd"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code EREADFILE

npm ERR! Error extracting C:\dev\npm-cache\bitbucket-cmd\0.3.0\package.tgz archive: ENOENT: no such file or directory, open 'C:\dev\npm-cache\bitbucket-cmd\0.3.0\package.tgz'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     c:\dev\repo\bitbucket\afp-banklet\npm-debug.log

c:\dev\repo\bitbucket\afp-banklet>npm uninstall -g bitbucket-cmd

c:\dev\repo\bitbucket\afp-banklet>npm install -g bitbucket-cmd
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\dev\\node-current\\node.exe" "C:\\dev\\node-current\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "bitbucket-cmd"
npm ERR! node v6.11.5
npm ERR! npm  v3.10.10
npm ERR! code EREADFILE

npm ERR! Error extracting C:\dev\npm-cache\bitbucket-cmd\0.3.0\package.tgz archive: ENOENT: no such file or directory, open 'C:\dev\npm-cache\bitbucket-cmd\0.3.0\package.tgz'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

Any idea why this is happening as I can install other npm packages fine.

Cheers,
Steve

Can't install

npm install -g bitbucket-cmd

Error extracting /Users/<User>/.npm/bitbucket-cmd/0.3.0/package.tgz archive: ENOENT: no such file or directory, open '/Users/<User>/.npm/bitbucket-cmd/0.3.0/package.tgz'

Unable to merge PR's from commandline

Great project, thanks!

I managed to successfully create a PR from the commandline, however when I try to merge that same PR (or any other PR I created) nothing happens. No error output either, it just stays open.

Is there any way I can see the debugging or output of the API response to see what goes wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.