|
| 1 | +# git-merged-branches CLI |
| 2 | + |
| 3 | +`git-merged-branches` is a simple command-line utility that allows you to view all branches that have been merged into a selected base branch, such as master. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +To install `git-merged-branches` globally, use the following command: |
| 8 | + |
| 9 | +```bash |
| 10 | +npm install --global git-merged-branches |
| 11 | +``` |
| 12 | + |
| 13 | +## Usage |
| 14 | + |
| 15 | +After installation, you can use the `git-merged-branches` command in your terminal. By default, it will show a list of branches that have been merged into the base branch (e.g., master or main). |
| 16 | + |
| 17 | +The utility checks for the default base branch (**master** or **main**), and if neither exists, it will notify you. |
| 18 | + |
| 19 | +When you run the `git-merged-branches` command, it will show a list of branches that have been merged into the base branch: |
| 20 | + |
| 21 | +```bash |
| 22 | +$ git-merged-branches |
| 23 | +Branches merged into 'master': |
| 24 | +feature/add-new-feature |
| 25 | +bugfix/fix-crash-on-start |
| 26 | +hotfix/urgent-fix |
| 27 | +``` |
| 28 | + |
| 29 | +Also, you may use `gmb` as an alias for `git-merged-branches`. |
| 30 | + |
| 31 | +## Configuration |
| 32 | + |
| 33 | +You can configure the behavior of the `git-merged-branches` command by adding a `git-merged-branches` object to your `package.json`. |
| 34 | +The configuration allows you to specify: |
| 35 | + |
| 36 | +- **issueUrlFormat**: The base URL for your issue tracker. Must be a valid URL. If it's not, the utility will warn you. |
| 37 | +- **issueUrlPrefix**: The prefix used to identify issues in branch names. Must consist of letters. If it's not, the utility will warn you. |
| 38 | + |
| 39 | +Here is an example of how to add the configuration: |
| 40 | + |
| 41 | +```json |
| 42 | +"git-merged-branches": { |
| 43 | + "issueUrlFormat": "https://your-jira-instance.net", |
| 44 | + "issueUrlPrefix": "TOKEN-" |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +With this configuration, `git-merged-branches` will detect branches with the prefix **TOKEN** and generate links to the issue tracker: |
| 49 | + |
| 50 | +```bash |
| 51 | +$ git-merged-branches |
| 52 | +Branches merged into 'master': |
| 53 | +TOKEN-800_new-feature <https://your-jira-instance.net/TOKEN-800> |
| 54 | +fix/TOKEN-123_some-fix <https://your-jira-instance.net/TOKEN-123> |
| 55 | +fix/EXTERNAL-391 |
| 56 | +hotfix |
| 57 | +``` |
| 58 | + |
| 59 | +If the configuration is invalid, `git-merged-branches` will display warnings and skip formatting the issue URLs. |
| 60 | + |
| 61 | +## Development |
| 62 | + |
| 63 | +- Clone the repository: |
| 64 | + |
| 65 | + ```bash |
| 66 | + git clone https://github.com/VChet/git-merged-branches.git |
| 67 | + cd git-merged-branches |
| 68 | + ``` |
| 69 | + |
| 70 | +- Install dependencies: |
| 71 | + |
| 72 | + ```bash |
| 73 | + npm install |
| 74 | + ``` |
| 75 | + |
| 76 | +- Build: |
| 77 | + |
| 78 | + ```bash |
| 79 | + npm run build |
| 80 | + ``` |
| 81 | + |
| 82 | +- Link it locally for testing: |
| 83 | + |
| 84 | + ```bash |
| 85 | + npm link |
| 86 | + ``` |
| 87 | + |
| 88 | +Now you can run `git-merged-branches` on your local machine. |
0 commit comments