Code Monkey home page Code Monkey logo

probranchinator's Introduction

probranchinator

This is a CLI tool that compares all branches in repository and displays how they can be merged to each other.

Gif

How it works

  1. It takes a remote repository URL from command line option
  2. (if necessary) Clones remote repository into temporary local repository
  3. Fetches all branches from remote and prunes deleted branches
  4. Compares selected branches with each other (either passed via CLI or most recently updated)
  5. Outputs result in terminal

Tool compares branches with each other and shows each comparison in a table. Each entry in that table represents an attempt of merging one branch into another. You can receive one of the following results:

  • โœ…โœ… No changes: already up-to-date
  • ๐Ÿš€โœ… No confilcts: fast-forward merge is possible
  • ๐Ÿคโœ… No conflicts: automatic merge is possible
  • ๐Ÿšง๐Ÿ”ง Found conflicts, have to resolve them manually
  • โŒโŒ No merge is possible (usually means your branches do not have common ancestor)
  • โŒ๐Ÿค” Unknown merge analysis result (this is not supposed to happen really)

Note that clone, fetch and prune operations currently require git CLI to be installed and available in $PATH due to compatibility with systems/protocols. Other operations work with cloned repository directly for efficiency. Tool creates temporary local repository in system temporary directory, because analysis of normal merge conflicts leaves working tree in a potentially 'dirty' state and we don't want to mess with user's repository, where unfinished work might be present.

Installation

Download a binary from latest release and put it somewhere in your $PATH.

Tool requires git CLI to be installed and available in $PATH.

Install with script

You can also use install.sh script with bash shell. It will download the latest release and put it in /usr/local/bin directory.

curl -s https://raw.githubusercontent.com/strowk/probranchinator/main/install.sh | bash

Only limited amount of platforms have prebuilt binaries at the moment: Linux (x86_64 gnu), macOS(x86_64, aarch64) and Windows (x86_64 gnu).

Install with cargo

In case if your platform/architecture is not supported, you might need to build the tool from source. You will need to have Rust toolchain installed.

Then you can install the tool with cargo:

cargo install probranchinator

Usage

probranchinator [OPTIONS] --remote <REMOTE> [BRANCHES]...

Example:

probranchinator --remote=https://github.com/strowk/probranchinator-test.git

If you want to examine your local repository, you can use file:// protocol:

probranchinator --remote=file://$PWD

By default probranchinator will analyse 10 most recently updated branches. You can override that by passing branches to analyse as CLI arguments:

probranchinator --remote=https://gitlab.com/git-compose/git-compose.git master test-branch-2

or by changing the amount of recent branches to analyse:

probranchinator --remote=https://gitlab.com/git-compose/git-compose.git --recent=2

To exit the program, press q or Ctrl+C.

Output Format

By default, probranchinator outputs result in interactive format as a terminal UI.

You can also output result in JSON format by passing --output=json like this:

$ probranchinator --remote=https://github.com/strowk/probranchinator-test.git --output=json master feature/1
[
  {
    "from_branch": "master",
    "to_branch": "feature/1",
    "status": "Normal"
  },
  {
    "from_branch": "feature/1",
    "to_branch": "master",
    "status": "Normal"
  }
]

By default output would be prettified, but you can pass --pretty=false to disable that.

Other available formats are:

  • simple - outputs each analysis result in a single line
  • table - outputs result in a table format
  • markdown - outputs result as a markdown table

Examples:

$ probranchinator --remote=https://github.com/strowk/probranchinator-test.git --output=simple master feature/1 feature/2 main
master -> feature/1 : ๐Ÿคโœ… No conflicts: automatic merge is possible.
master -> feature/2 : ๐Ÿšง๐Ÿ”ง Found conflicts, have to resolve them manually.
master -> main : โŒโŒ No merge is possible - no merge base found.
feature/1 -> master : ๐Ÿคโœ… No conflicts: automatic merge is possible.
feature/1 -> feature/2 : ๐Ÿคโœ… No conflicts: automatic merge is possible.
feature/1 -> main : โŒโŒ No merge is possible - no merge base found.
feature/2 -> master : ๐Ÿšง๐Ÿ”ง Found conflicts, have to resolve them manually.
feature/2 -> feature/1 : ๐Ÿคโœ… No conflicts: automatic merge is possible.
feature/2 -> main : โŒโŒ No merge is possible - no merge base found.
main -> master : โŒโŒ No merge is possible - no merge base found.
main -> feature/1 : โŒโŒ No merge is possible - no merge base found.
main -> feature/2 : โŒโŒ No merge is possible - no merge base found.
$ probranchinator --remote=https://github.com/strowk/probranchinator-test.git --output=table master feature/1 main
+-------------+-----------+--------------------------------------------------+
| from_branch | to_branch | status                                           |
+-------------+-----------+--------------------------------------------------+
| master      | feature/1 | ๐Ÿคโœ… No conflicts: automatic merge is possible.  |
+-------------+-----------+--------------------------------------------------+
| master      | main      | โŒโŒ No merge is possible - no merge base found. |
+-------------+-----------+--------------------------------------------------+
| feature/1   | master    | ๐Ÿคโœ… No conflicts: automatic merge is possible.  |
+-------------+-----------+--------------------------------------------------+
| feature/1   | main      | โŒโŒ No merge is possible - no merge base found. |
+-------------+-----------+--------------------------------------------------+
| main        | master    | โŒโŒ No merge is possible - no merge base found. |
+-------------+-----------+--------------------------------------------------+
| main        | feature/1 | โŒโŒ No merge is possible - no merge base found. |
+-------------+-----------+--------------------------------------------------+
$ probranchinator --remote=https://github.com/strowk/probranchinator-test.git --output=markdown master feature/1 main
| from_branch | to_branch | status                                           |
|-------------|-----------|--------------------------------------------------|
| master      | feature/1 | ๐Ÿคโœ… No conflicts: automatic merge is possible.  |
| master      | main      | โŒโŒ No merge is possible - no merge base found. |
| feature/1   | master    | ๐Ÿคโœ… No conflicts: automatic merge is possible.  |
| feature/1   | main      | โŒโŒ No merge is possible - no merge base found. |
| main        | master    | โŒโŒ No merge is possible - no merge base found. |
| main        | feature/1 | โŒโŒ No merge is possible - no merge base found. |

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.