Skip to content

Commit 0109d90

Browse files
committed
Initial commit
0 parents  commit 0109d90

File tree

15 files changed

+7837
-0
lines changed

15 files changed

+7837
-0
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: / # Location of package manifests
5+
schedule:
6+
interval: monthly

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branch: master
6+
pull_request:
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v4
14+
15+
- name: Install pnpm
16+
uses: pnpm/action-setup@v4
17+
with:
18+
version: 9
19+
run_install: true
20+
21+
- name: Install Node.js
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: "22"
25+
cache: pnpm
26+
27+
- name: Run linters
28+
run: pnpm run lint:all
29+
30+
- name: Run build
31+
run: pnpm run build
32+
33+
- name: Run tests
34+
run: pnpm run test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

LICENSE.MD

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
The MIT License (MIT)
2+
=====================
3+
4+
Copyright © `2025` VChet <https://github.com/VChet>
5+
6+
Permission is hereby granted, free of charge, to any person
7+
obtaining a copy of this software and associated documentation
8+
files (the “Software”), to deal in the Software without
9+
restriction, including without limitation the rights to use,
10+
copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the
12+
Software is furnished to do so, subject to the following
13+
conditions:
14+
15+
The above copyright notice and this permission notice shall be
16+
included in all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25+
OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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.

build.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { build } from "esbuild";
2+
3+
build({
4+
entryPoints: ["./src/index.ts"],
5+
outfile: "dist/index.js",
6+
banner: { js: "#!/usr/bin/env node" },
7+
bundle: true,
8+
platform: "node",
9+
format: "esm"
10+
})
11+
.then(() => {
12+
console.info("Build complete.");
13+
process.exit(0);
14+
})
15+
.catch(() => process.exit(1));

eslint.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig, globalIgnores } from "eslint/config";
2+
import neostandard from "neostandard";
3+
4+
export default defineConfig([
5+
globalIgnores(["dist"]),
6+
...neostandard(),
7+
{
8+
rules: {
9+
"@stylistic/comma-dangle": ["error", "never"],
10+
"@stylistic/quotes": ["error", "double"],
11+
"@stylistic/semi": ["error", "always"],
12+
"@stylistic/space-before-function-paren": ["error", "never"]
13+
}
14+
}
15+
]);

package.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "git-merged-branches",
3+
"description": "CLI tool to list all Git branches merged into a base branch with issue link formatting",
4+
"type": "module",
5+
"version": "0.1.0",
6+
"license": "MIT",
7+
"author": {
8+
"name": "VChet",
9+
"url": "https://github.com/VChet"
10+
},
11+
"repository": {
12+
"type": "git",
13+
"url": "git+https://github.com/VChet/git-merged-branches.git"
14+
},
15+
"bugs": {
16+
"url": "https://github.com/VChet/git-merged-branches/issues"
17+
},
18+
"homepage": "https://github.com/твой-аккаунт/git-merged-branches#readme",
19+
"bin": {
20+
"git-merged-branches": "./dist/index.js",
21+
"gmb": "./dist/index.js"
22+
},
23+
"scripts": {
24+
"clean": "rimraf dist",
25+
"build": "npm run clean && node build.js",
26+
"lint:ts": "tsc --noEmit",
27+
"lint:js": "eslint .",
28+
"lint:js:fix": "npm run lint:js -- --fix",
29+
"lint:all": "npm run lint:ts && npm run lint:js",
30+
"test": "vitest"
31+
},
32+
"devDependencies": {
33+
"@types/node": "^22.14.1",
34+
"esbuild": "^0.25.2",
35+
"eslint": "^9.24.0",
36+
"jest": "^29.7.0",
37+
"neostandard": "^0.12.1",
38+
"release-it": "^18.1.2",
39+
"rimraf": "^6.0.1",
40+
"typescript": "^5.8.3",
41+
"vitest": "^3.1.1"
42+
}
43+
}

0 commit comments

Comments
 (0)