@mehmetsagir/git-ai 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +365 -0
- package/bin/git-ai +4 -0
- package/dist/add.d.ts +5 -0
- package/dist/add.d.ts.map +1 -0
- package/dist/add.js +98 -0
- package/dist/add.js.map +1 -0
- package/dist/commit-processor.d.ts +6 -0
- package/dist/commit-processor.d.ts.map +1 -0
- package/dist/commit-processor.js +138 -0
- package/dist/commit-processor.js.map +1 -0
- package/dist/commit.d.ts +5 -0
- package/dist/commit.d.ts.map +1 -0
- package/dist/commit.js +245 -0
- package/dist/commit.js.map +1 -0
- package/dist/config.d.ts +44 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +185 -0
- package/dist/config.js.map +1 -0
- package/dist/git.d.ts +54 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +256 -0
- package/dist/git.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/dist/openai.d.ts +22 -0
- package/dist/openai.d.ts.map +1 -0
- package/dist/openai.js +137 -0
- package/dist/openai.js.map +1 -0
- package/dist/prompts.d.ts +17 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +117 -0
- package/dist/prompts.js.map +1 -0
- package/dist/reset.d.ts +5 -0
- package/dist/reset.d.ts.map +1 -0
- package/dist/reset.js +77 -0
- package/dist/reset.js.map +1 -0
- package/dist/setup.d.ts +5 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +234 -0
- package/dist/setup.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/user-management.d.ts +10 -0
- package/dist/user-management.d.ts.map +1 -0
- package/dist/user-management.js +225 -0
- package/dist/user-management.js.map +1 -0
- package/dist/users.d.ts +9 -0
- package/dist/users.d.ts.map +1 -0
- package/dist/users.js +129 -0
- package/dist/users.js.map +1 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
# Git AI
|
|
2
|
+
|
|
3
|
+
AI-powered git commit tool. Analyzes git diffs, groups them logically, and creates commit messages in Conventional Commits standard.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- š¤ **AI-Powered Analysis**: Analyzes git diffs with OpenAI
|
|
8
|
+
- š¦ **Smart Grouping**: Groups changes logically
|
|
9
|
+
- š **Conventional Commits**: Uses standard commit message format
|
|
10
|
+
- š¤ **Multiple Git User Support**: Manages multiple git user profiles
|
|
11
|
+
- š **Secure**: Commits are not pushed automatically, provides manual control
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
### Global Installation (via npx)
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npx git-ai setup
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Local Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g git-ai
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or install locally:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install git-ai
|
|
31
|
+
npm link
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Initial Setup
|
|
35
|
+
|
|
36
|
+
Run the setup command on first use:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git-ai setup
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This command:
|
|
43
|
+
|
|
44
|
+
- Asks for your OpenAI API key
|
|
45
|
+
- Detects your git user profiles
|
|
46
|
+
- Allows you to select a default git user
|
|
47
|
+
- Saves configuration to `~/.git-ai/config.json`
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
### Creating Commits
|
|
52
|
+
|
|
53
|
+
**With default user:**
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
git-ai commit
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**With a different user:**
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Using shortcut (easiest method - single or multi-character)
|
|
63
|
+
git-ai commit --user my
|
|
64
|
+
git-ai commit --user g
|
|
65
|
+
git-ai commit --user work
|
|
66
|
+
git-ai commit -u personal
|
|
67
|
+
|
|
68
|
+
# Using email
|
|
69
|
+
git-ai commit --user user@example.com
|
|
70
|
+
|
|
71
|
+
# Using user ID (ID shown during setup)
|
|
72
|
+
git-ai commit --user global-user@example.com
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
This command:
|
|
76
|
+
|
|
77
|
+
1. Analyzes git diffs (staged + unstaged)
|
|
78
|
+
2. Groups changes with OpenAI
|
|
79
|
+
3. Creates Conventional Commits format messages for each group
|
|
80
|
+
4. Shows commit plan and asks for confirmation
|
|
81
|
+
5. Creates each group as a separate commit after approval
|
|
82
|
+
6. **Does not push** - you need to push manually
|
|
83
|
+
|
|
84
|
+
### Example Output
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
š¤ Git Commit AI
|
|
88
|
+
|
|
89
|
+
ā Changes analyzed
|
|
90
|
+
|
|
91
|
+
ā Analysis complete: 3 groups created
|
|
92
|
+
|
|
93
|
+
ā 3 groups created
|
|
94
|
+
|
|
95
|
+
š Commit Plan:
|
|
96
|
+
|
|
97
|
+
Group 1: Authentication feature
|
|
98
|
+
Files: auth.ts, auth.test.ts
|
|
99
|
+
Commit: feat(auth): add OAuth2 authentication support
|
|
100
|
+
Added OAuth2 authentication support. Implemented token refresh mechanism.
|
|
101
|
+
|
|
102
|
+
Group 2: UI component updates
|
|
103
|
+
Files: Button.tsx, Input.tsx, styles.css
|
|
104
|
+
Commit: style(ui): update design system colors
|
|
105
|
+
Updated design system colors. Improved dark mode support.
|
|
106
|
+
|
|
107
|
+
Group 3: API endpoint refactoring
|
|
108
|
+
Files: api/users.ts, api/types.ts
|
|
109
|
+
Commit: refactor(api): simplify user endpoint logic
|
|
110
|
+
Simplified user endpoint logic. Improved error handling.
|
|
111
|
+
|
|
112
|
+
Do you approve this commit plan? (Y/n)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Conventional Commits Format
|
|
116
|
+
|
|
117
|
+
The tool uses the [Conventional Commits](https://www.conventionalcommits.org/) standard:
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
<type>(<scope>): <subject>
|
|
121
|
+
|
|
122
|
+
<body>
|
|
123
|
+
|
|
124
|
+
<footer>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Commit Types
|
|
128
|
+
|
|
129
|
+
- `feat`: New feature
|
|
130
|
+
- `fix`: Bug fix
|
|
131
|
+
- `refactor`: Code refactoring
|
|
132
|
+
- `style`: Formatting, styling changes
|
|
133
|
+
- `docs`: Documentation
|
|
134
|
+
- `test`: Tests
|
|
135
|
+
- `chore`: Maintenance tasks
|
|
136
|
+
|
|
137
|
+
## Git User Management
|
|
138
|
+
|
|
139
|
+
The tool allows you to manage multiple git user profiles:
|
|
140
|
+
|
|
141
|
+
- Automatic detection from global and local git configs
|
|
142
|
+
- List active git users
|
|
143
|
+
- Default user selection (during setup)
|
|
144
|
+
- Manual profile addition
|
|
145
|
+
- Different user selection during commit with `--user` or `-u` flag
|
|
146
|
+
|
|
147
|
+
### User Management During Setup
|
|
148
|
+
|
|
149
|
+
When running the setup command:
|
|
150
|
+
|
|
151
|
+
1. **Active git user profiles are listed:**
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
š Active Git User Profiles:
|
|
155
|
+
1. John Doe <john@example.com> (Global) [shortcut: g]
|
|
156
|
+
2. Jane Smith <jane@example.com> (Local) [shortcut: t]
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
2. **Shortcuts can be added for each user:**
|
|
160
|
+
|
|
161
|
+
- "Would you like to add a shortcut?" question is asked for each user
|
|
162
|
+
- Shortcut key is entered (can be single or multi-character, e.g., `g`, `my`, `work`, `personal`)
|
|
163
|
+
- Shortcuts can be used during commit
|
|
164
|
+
|
|
165
|
+
3. **Default user is selected:**
|
|
166
|
+
|
|
167
|
+
- Automatically selected if there's only one user
|
|
168
|
+
- Selection is made if there are multiple users
|
|
169
|
+
|
|
170
|
+
4. **Optionally, more profiles can be added**
|
|
171
|
+
|
|
172
|
+
5. **Default user can be updated after adding new profiles**
|
|
173
|
+
|
|
174
|
+
### User Selection During Commit
|
|
175
|
+
|
|
176
|
+
**Default usage:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
git-ai commit
|
|
180
|
+
# Uses default user from config
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**With different user:**
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# Using shortcut (easiest - recommended, single or multi-character)
|
|
187
|
+
git-ai commit --user my
|
|
188
|
+
git-ai commit --user work
|
|
189
|
+
git-ai commit -u personal
|
|
190
|
+
|
|
191
|
+
# Using email address
|
|
192
|
+
git-ai commit --user jane@example.com
|
|
193
|
+
|
|
194
|
+
# Short form
|
|
195
|
+
git-ai commit -u jane@example.com
|
|
196
|
+
|
|
197
|
+
# Using user ID (ID shown during setup)
|
|
198
|
+
git-ai commit --user local-jane@example.com
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
**To view current users:**
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
git-ai list
|
|
205
|
+
# or
|
|
206
|
+
git-ai users
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Commands
|
|
210
|
+
|
|
211
|
+
### Setup
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
git-ai setup
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Initial setup - OpenAI API key and git user configuration.
|
|
218
|
+
|
|
219
|
+
### Commit
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
git-ai commit [--user <user>]
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Analyze git diffs and create commits. Use `--user` or `-u` to specify a different git user.
|
|
226
|
+
|
|
227
|
+
### Add User
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
git-ai add
|
|
231
|
+
# or
|
|
232
|
+
git-ai add-user
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Add a new git user profile.
|
|
236
|
+
|
|
237
|
+
### List Users
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
git-ai list
|
|
241
|
+
# or
|
|
242
|
+
git-ai users
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
List all configured git user profiles.
|
|
246
|
+
|
|
247
|
+
### Remove User
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
git-ai remove
|
|
251
|
+
# or
|
|
252
|
+
git-ai delete
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Remove a git user profile interactively.
|
|
256
|
+
|
|
257
|
+
### Reset
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
git-ai reset
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Reset all configuration (deletes OpenAI key and all git users).
|
|
264
|
+
|
|
265
|
+
## Example Scenario
|
|
266
|
+
|
|
267
|
+
1. **Run setup:**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
git-ai setup
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
- 3 user profiles detected
|
|
274
|
+
- Shortcuts added for each user:
|
|
275
|
+
- `work@company.com` ā shortcut: `w`
|
|
276
|
+
- `personal@gmail.com` ā shortcut: `p`
|
|
277
|
+
- `other@example.com` ā shortcut: `o`
|
|
278
|
+
- `work@company.com` selected as default
|
|
279
|
+
|
|
280
|
+
2. **For work commit (default user):**
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
git-ai commit
|
|
284
|
+
# Uses work@company.com
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
3. **For personal project (using shortcut):**
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
git-ai commit --user p
|
|
291
|
+
# or
|
|
292
|
+
git-ai commit -u p
|
|
293
|
+
# Uses personal@gmail.com
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
4. **For other project (using shortcut):**
|
|
297
|
+
```bash
|
|
298
|
+
git-ai commit --user o
|
|
299
|
+
# Uses other@example.com
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Configuration
|
|
303
|
+
|
|
304
|
+
Configuration file: `~/.git-ai/config.json`
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"openaiKey": "sk-...",
|
|
309
|
+
"gitUsers": [
|
|
310
|
+
{
|
|
311
|
+
"id": "global-user@example.com",
|
|
312
|
+
"name": "John Doe",
|
|
313
|
+
"email": "user@example.com",
|
|
314
|
+
"scope": "global",
|
|
315
|
+
"label": "John Doe <user@example.com> (Global)",
|
|
316
|
+
"shortcut": "g"
|
|
317
|
+
}
|
|
318
|
+
],
|
|
319
|
+
"defaultGitUser": "global-user@example.com"
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Requirements
|
|
324
|
+
|
|
325
|
+
- Node.js >= 14.0.0
|
|
326
|
+
- OpenAI API key
|
|
327
|
+
- Git repository
|
|
328
|
+
|
|
329
|
+
## Security
|
|
330
|
+
|
|
331
|
+
- Your OpenAI API key is stored locally in `~/.git-ai/config.json`
|
|
332
|
+
- Commits are not automatically pushed
|
|
333
|
+
- Git user information is stored locally
|
|
334
|
+
|
|
335
|
+
## Troubleshooting
|
|
336
|
+
|
|
337
|
+
### "OpenAI API key not found" error
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
git-ai setup
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### "This directory is not a git repository" error
|
|
344
|
+
|
|
345
|
+
Make sure you're in a git repository:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
git init # If it doesn't exist
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
### "No changes found to commit" error
|
|
352
|
+
|
|
353
|
+
Make sure you have changes:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
git status
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
## License
|
|
360
|
+
|
|
361
|
+
MIT
|
|
362
|
+
|
|
363
|
+
## Contributing
|
|
364
|
+
|
|
365
|
+
Contributions are welcome! Please open an issue or submit a pull request.
|
package/bin/git-ai
ADDED
package/dist/add.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CA2D7C"}
|
package/dist/add.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.addUser = addUser;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
42
|
+
const config = __importStar(require("./config"));
|
|
43
|
+
const userManagement = __importStar(require("./user-management"));
|
|
44
|
+
/**
|
|
45
|
+
* Add a new git user
|
|
46
|
+
*/
|
|
47
|
+
async function addUser() {
|
|
48
|
+
console.log(chalk_1.default.blue.bold('\nā Add Git User\n'));
|
|
49
|
+
if (!config.configExists()) {
|
|
50
|
+
console.log(chalk_1.default.yellow('ā Configuration not found. Please run setup first.\n'));
|
|
51
|
+
console.log(chalk_1.default.blue('Run: git-ai setup\n'));
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const existingProfiles = config.getGitUsers();
|
|
55
|
+
if (existingProfiles.length > 0) {
|
|
56
|
+
console.log(chalk_1.default.blue('Current git user profiles:\n'));
|
|
57
|
+
existingProfiles.forEach((profile, index) => {
|
|
58
|
+
const shortcutInfo = profile.shortcut
|
|
59
|
+
? chalk_1.default.yellow(` [shortcut: ${profile.shortcut}]`)
|
|
60
|
+
: '';
|
|
61
|
+
console.log(chalk_1.default.cyan(` ${index + 1}. ${profile.label}${shortcutInfo}`));
|
|
62
|
+
});
|
|
63
|
+
console.log('\n');
|
|
64
|
+
}
|
|
65
|
+
console.log(chalk_1.default.blue('š” Tip: Type "q" and press Enter at any input to cancel.\n'));
|
|
66
|
+
await userManagement.addMoreGitUsers(existingProfiles);
|
|
67
|
+
const updatedProfiles = config.getGitUsers();
|
|
68
|
+
if (updatedProfiles.length > 1) {
|
|
69
|
+
const { updateDefault } = await inquirer_1.default.prompt([
|
|
70
|
+
{
|
|
71
|
+
type: 'confirm',
|
|
72
|
+
name: 'updateDefault',
|
|
73
|
+
message: 'Would you like to update the default git user?',
|
|
74
|
+
default: false
|
|
75
|
+
}
|
|
76
|
+
]);
|
|
77
|
+
if (updateDefault) {
|
|
78
|
+
const { defaultUser } = await inquirer_1.default.prompt([
|
|
79
|
+
{
|
|
80
|
+
type: 'list',
|
|
81
|
+
name: 'defaultUser',
|
|
82
|
+
message: 'Select default git user:',
|
|
83
|
+
choices: updatedProfiles.map(p => ({
|
|
84
|
+
name: p.label,
|
|
85
|
+
value: p.id
|
|
86
|
+
}))
|
|
87
|
+
}
|
|
88
|
+
]);
|
|
89
|
+
config.setDefaultGitUser(defaultUser);
|
|
90
|
+
const selectedProfile = updatedProfiles.find(p => p.id === defaultUser);
|
|
91
|
+
if (selectedProfile) {
|
|
92
|
+
console.log(chalk_1.default.green(`ā Default git user updated: ${selectedProfile.label}\n`));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
console.log(chalk_1.default.green('ā User addition completed!\n'));
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=add.js.map
|
package/dist/add.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../src/add.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,0BA2DC;AAnED,kDAA0B;AAC1B,wDAAgC;AAChC,iDAAmC;AACnC,kEAAoD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MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAA6B;YAC1E;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,gDAAgD;gBACzD,OAAO,EAAE,KAAK;aACf;SACF,CAAC,CAAC;QAEH,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,kBAAQ,CAAC,MAAM,CAA0B;gBACrE;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,aAAa;oBACnB,OAAO,EAAE,0BAA0B;oBACnC,OAAO,EAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;wBACjC,IAAI,EAAE,CAAC,CAAC,KAAK;wBACb,KAAK,EAAE,CAAC,CAAC,EAAE;qBACZ,CAAC,CAAC;iBACJ;aACF,CAAC,CAAC;YAEH,MAAM,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;YACtC,MAAM,eAAe,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,CAAC,CAAC;YACxE,IAAI,eAAe,EAAE,CAAC;gBACpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,+BAA+B,eAAe,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;YACrF,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommitGroup, CommitResult, GitUserInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Process all commit groups
|
|
4
|
+
*/
|
|
5
|
+
export declare function processAllCommitGroups(groups: CommitGroup[], selectedUser: GitUserInfo | null): Promise<CommitResult[]>;
|
|
6
|
+
//# sourceMappingURL=commit-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-processor.d.ts","sourceRoot":"","sources":["../src/commit-processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA+EjE;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,WAAW,EAAE,EACrB,YAAY,EAAE,WAAW,GAAG,IAAI,GAC/B,OAAO,CAAC,YAAY,EAAE,CAAC,CAqCzB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.processAllCommitGroups = processAllCommitGroups;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const ora_1 = __importDefault(require("ora"));
|
|
42
|
+
const git = __importStar(require("./git"));
|
|
43
|
+
/**
|
|
44
|
+
* Process and commit a single group
|
|
45
|
+
*/
|
|
46
|
+
async function processCommitGroup(group, selectedUser, remainingFiles, processedFiles) {
|
|
47
|
+
if (remainingFiles.length === 0) {
|
|
48
|
+
console.log(chalk_1.default.yellow(`ā Group ${group.number}: No files left to process, skipping.\n`));
|
|
49
|
+
return { success: false, filesProcessed: [] };
|
|
50
|
+
}
|
|
51
|
+
const groupFiles = group.files
|
|
52
|
+
.map(file => {
|
|
53
|
+
const normalizedFile = file.replace(/^\.\//, '').replace(/^\//, '');
|
|
54
|
+
return remainingFiles.find(changed => {
|
|
55
|
+
const normalizedChanged = changed.replace(/^\.\//, '').replace(/^\//, '');
|
|
56
|
+
return normalizedChanged === normalizedFile ||
|
|
57
|
+
normalizedChanged.endsWith(normalizedFile) ||
|
|
58
|
+
normalizedFile.endsWith(normalizedChanged);
|
|
59
|
+
});
|
|
60
|
+
})
|
|
61
|
+
.filter((file) => Boolean(file));
|
|
62
|
+
const filesToStage = groupFiles.length > 0 ? groupFiles : [remainingFiles[0]];
|
|
63
|
+
if (filesToStage.length === 0) {
|
|
64
|
+
console.log(chalk_1.default.yellow(`ā Group ${group.number}: No files to stage, skipping.\n`));
|
|
65
|
+
return { success: false, filesProcessed: [] };
|
|
66
|
+
}
|
|
67
|
+
filesToStage.forEach(file => processedFiles.add(file));
|
|
68
|
+
const stageSpinner = (0, ora_1.default)(`Group ${group.number}: Staging files...`).start();
|
|
69
|
+
try {
|
|
70
|
+
await git.stageFiles(filesToStage);
|
|
71
|
+
stageSpinner.succeed(`Group ${group.number}: Files staged`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const err = error;
|
|
75
|
+
stageSpinner.fail(`Group ${group.number}: Error staging files: ${err.message}`);
|
|
76
|
+
return { success: false, filesProcessed: filesToStage };
|
|
77
|
+
}
|
|
78
|
+
const fullMessage = group.commitBody
|
|
79
|
+
? `${group.commitMessage}\n\n${group.commitBody}`
|
|
80
|
+
: group.commitMessage;
|
|
81
|
+
const commitSpinner = (0, ora_1.default)(`Group ${group.number}: Creating commit "${group.commitMessage}"...`).start();
|
|
82
|
+
try {
|
|
83
|
+
await git.createCommit(fullMessage, selectedUser?.name || null, selectedUser?.email || null);
|
|
84
|
+
commitSpinner.succeed(`Group ${group.number}: Committed - ${group.commitMessage}`);
|
|
85
|
+
return {
|
|
86
|
+
success: true,
|
|
87
|
+
filesProcessed: filesToStage,
|
|
88
|
+
message: group.commitMessage
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const err = error;
|
|
93
|
+
commitSpinner.fail(`Group ${group.number}: Commit error - ${err.message}`);
|
|
94
|
+
return {
|
|
95
|
+
success: false,
|
|
96
|
+
filesProcessed: filesToStage,
|
|
97
|
+
message: group.commitMessage,
|
|
98
|
+
error: err.message
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Process all commit groups
|
|
104
|
+
*/
|
|
105
|
+
async function processAllCommitGroups(groups, selectedUser) {
|
|
106
|
+
const prepareSpinner = (0, ora_1.default)('Preparing files...').start();
|
|
107
|
+
try {
|
|
108
|
+
await git.unstageAll();
|
|
109
|
+
prepareSpinner.succeed('Files prepared');
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const err = error;
|
|
113
|
+
prepareSpinner.fail(`Unstage error: ${err.message}`);
|
|
114
|
+
}
|
|
115
|
+
const commitResults = [];
|
|
116
|
+
let remainingFiles = await git.getAllChangedFiles();
|
|
117
|
+
const processedFiles = new Set();
|
|
118
|
+
console.log(chalk_1.default.blue(`\nš¦ Creating ${groups.length} commits...\n`));
|
|
119
|
+
for (const group of groups) {
|
|
120
|
+
const result = await processCommitGroup(group, selectedUser, remainingFiles, processedFiles);
|
|
121
|
+
commitResults.push({
|
|
122
|
+
group: group.number,
|
|
123
|
+
message: result.message || group.commitMessage,
|
|
124
|
+
files: result.filesProcessed?.length || 0,
|
|
125
|
+
success: result.success,
|
|
126
|
+
error: result.error
|
|
127
|
+
});
|
|
128
|
+
remainingFiles = remainingFiles.filter(file => !processedFiles.has(file));
|
|
129
|
+
try {
|
|
130
|
+
await git.unstageAll();
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
// Continue even if error
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return commitResults;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=commit-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commit-processor.js","sourceRoot":"","sources":["../src/commit-processor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,wDAwCC;AA7HD,kDAA0B;AAC1B,8CAAsB;AACtB,2CAA6B;AAU7B;;GAEG;AACH,KAAK,UAAU,kBAAkB,CAC/B,KAAkB,EAClB,YAAgC,EAChC,cAAwB,EACxB,cAA2B;IAE3B,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,CA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