Skip to content

Commit 9a49fa9

Browse files
committed
Initial commit
0 parents  commit 9a49fa9

File tree

14 files changed

+6166
-0
lines changed

14 files changed

+6166
-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/

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: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "git-merged-branches",
3+
"description": "CLI tool to list merged Git branches",
4+
"type": "module",
5+
"version": "0.1.0",
6+
"author": "VChet",
7+
"license": "MIT",
8+
"bin": {
9+
"git-merged-branches": "./dist/index.js",
10+
"gmb": "./dist/index.js"
11+
},
12+
"scripts": {
13+
"clean": "rimraf dist",
14+
"build": "npm run clean && node build.js",
15+
"lint:ts": "tsc --noEmit",
16+
"lint:js": "eslint .",
17+
"lint:js:fix": "npm run lint:js -- --fix",
18+
"lint:all": "npm run lint:ts && npm run lint:js",
19+
"test": "vitest"
20+
},
21+
"devDependencies": {
22+
"@types/node": "^22.14.1",
23+
"esbuild": "^0.25.2",
24+
"eslint": "^9.24.0",
25+
"jest": "^29.7.0",
26+
"neostandard": "^0.12.1",
27+
"rimraf": "^6.0.1",
28+
"typescript": "^5.8.3",
29+
"vitest": "^3.1.1"
30+
}
31+
}

0 commit comments

Comments
 (0)