@harryisfish/gitt 1.1.0 → 1.1.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 +20 -20
- package/dist/commands/clean.js +8 -8
- package/dist/errors.js +4 -4
- package/dist/index.js +7 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
# Gitt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command-line tool to delete local branches that have been deleted on the remote repository.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Using npm:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install -g @harryisfish/gitt
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Using pnpm:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
pnpm add -g @harryisfish/gitt
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
##
|
|
19
|
+
## Usage
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
22
|
gitt
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
##
|
|
25
|
+
## Configuration
|
|
26
26
|
|
|
27
|
-
Gitt
|
|
27
|
+
Gitt automatically uses your Git global configuration. No additional setup required.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Documentation
|
|
30
30
|
|
|
31
|
-
- [
|
|
32
|
-
- [
|
|
33
|
-
- [
|
|
31
|
+
- [Development Guide](./docs/DEVELOPMENT.md)
|
|
32
|
+
- [Contributing Guide](./docs/CONTRIBUTING.md)
|
|
33
|
+
- [Architecture Documentation](./docs/ARCHITECTURE.md)
|
|
34
34
|
|
|
35
|
-
##
|
|
35
|
+
## FAQ
|
|
36
36
|
|
|
37
|
-
### Q:
|
|
38
|
-
A:
|
|
37
|
+
### Q: What should I do when encountering "insufficient permissions" error?
|
|
38
|
+
A: Please ensure you have access permissions to the repository and have properly configured SSH keys or Git credentials.
|
|
39
39
|
|
|
40
|
-
### Q:
|
|
41
|
-
A:
|
|
40
|
+
### Q: How to handle merge conflicts?
|
|
41
|
+
A: When merge conflicts occur, Gitt will prompt you to resolve them manually. After resolution, use `gitt commit` to continue and complete the merge operation.
|
|
42
42
|
|
|
43
|
-
##
|
|
43
|
+
## Development
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
For detailed development guidelines, please refer to the [Development Guide](./docs/DEVELOPMENT.md).
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## License
|
|
48
48
|
|
|
49
49
|
[MIT](./LICENSE)
|
|
50
50
|
|
|
51
51
|
---
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
If you find this project helpful, please give it a star ⭐️
|
package/dist/commands/clean.js
CHANGED
|
@@ -11,11 +11,11 @@ const git = (0, simple_git_1.simpleGit)();
|
|
|
11
11
|
*/
|
|
12
12
|
async function cleanDeletedBranches() {
|
|
13
13
|
try {
|
|
14
|
-
console.log('
|
|
14
|
+
console.log('Switching to main branch...');
|
|
15
15
|
await git.checkout('main');
|
|
16
|
-
console.log('
|
|
16
|
+
console.log('Pulling latest code...');
|
|
17
17
|
await git.pull();
|
|
18
|
-
console.log('
|
|
18
|
+
console.log('Cleaning up remotely deleted branches...');
|
|
19
19
|
// 获取最新的远程分支信息
|
|
20
20
|
await git.fetch(['--prune']);
|
|
21
21
|
// 获取所有分支信息
|
|
@@ -26,18 +26,18 @@ async function cleanDeletedBranches() {
|
|
|
26
26
|
return branchInfo.label && branchInfo.label.includes(': gone]');
|
|
27
27
|
});
|
|
28
28
|
if (deletedBranches.length === 0) {
|
|
29
|
-
console.log('
|
|
29
|
+
console.log('No branches need to be cleaned up.');
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
console.log('
|
|
32
|
+
console.log('The following branches will be deleted:', deletedBranches.join(', '));
|
|
33
33
|
// 删除这些分支
|
|
34
34
|
for (const branch of deletedBranches) {
|
|
35
35
|
await git.branch(['-D', branch]);
|
|
36
|
-
console.log(
|
|
36
|
+
console.log(`Deleted branch: ${branch}`);
|
|
37
37
|
}
|
|
38
|
-
(0, errors_2.printSuccess)('
|
|
38
|
+
(0, errors_2.printSuccess)('Branch cleanup completed');
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
|
-
throw new errors_1.GitError(error instanceof Error ? error.message : '
|
|
41
|
+
throw new errors_1.GitError(error instanceof Error ? error.message : 'Unknown error occurred while cleaning branches');
|
|
42
42
|
}
|
|
43
43
|
}
|
package/dist/errors.js
CHANGED
|
@@ -13,7 +13,7 @@ class GitError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
exports.GitError = GitError;
|
|
15
15
|
class UserCancelError extends Error {
|
|
16
|
-
constructor(message = '
|
|
16
|
+
constructor(message = 'Operation cancelled') {
|
|
17
17
|
super(message);
|
|
18
18
|
this.name = 'UserCancelError';
|
|
19
19
|
}
|
|
@@ -30,14 +30,14 @@ function handleError(error) {
|
|
|
30
30
|
process.exit(0);
|
|
31
31
|
}
|
|
32
32
|
if (error instanceof GitError) {
|
|
33
|
-
console.error(`${ERROR_COLOR}
|
|
33
|
+
console.error(`${ERROR_COLOR}Error: ${RESET_COLOR}${error.message}`);
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
if (error instanceof Error) {
|
|
37
|
-
console.error(`${ERROR_COLOR}
|
|
37
|
+
console.error(`${ERROR_COLOR}Program error: ${RESET_COLOR}${error.message}`);
|
|
38
38
|
process.exit(1);
|
|
39
39
|
}
|
|
40
|
-
console.error(`${ERROR_COLOR}
|
|
40
|
+
console.error(`${ERROR_COLOR}Unknown error occurred${RESET_COLOR}`);
|
|
41
41
|
process.exit(1);
|
|
42
42
|
}
|
|
43
43
|
// 成功消息处理
|
package/dist/index.js
CHANGED
|
@@ -7,38 +7,38 @@ const clean_1 = require("./commands/clean");
|
|
|
7
7
|
const git = (0, simple_git_1.simpleGit)();
|
|
8
8
|
// 处理 Ctrl+C 和其他终止信号
|
|
9
9
|
process.on('SIGINT', () => {
|
|
10
|
-
throw new errors_1.UserCancelError('\
|
|
10
|
+
throw new errors_1.UserCancelError('\nOperation cancelled');
|
|
11
11
|
});
|
|
12
12
|
process.on('SIGTERM', () => {
|
|
13
|
-
throw new errors_1.UserCancelError('\
|
|
13
|
+
throw new errors_1.UserCancelError('\nProgram terminated');
|
|
14
14
|
});
|
|
15
15
|
// 初始化 Git 仓库
|
|
16
16
|
async function initGitRepo() {
|
|
17
17
|
try {
|
|
18
18
|
await git.init();
|
|
19
|
-
(0, errors_1.printSuccess)('Git
|
|
19
|
+
(0, errors_1.printSuccess)('Git repository initialized successfully');
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
throw new errors_1.GitError('Git
|
|
22
|
+
throw new errors_1.GitError('Failed to initialize Git repository');
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
// 检查当前目录是否是 Git 仓库
|
|
26
26
|
async function checkGitRepo() {
|
|
27
27
|
const isRepo = await git.checkIsRepo();
|
|
28
28
|
if (!isRepo) {
|
|
29
|
-
throw new errors_1.GitError('
|
|
29
|
+
throw new errors_1.GitError('Current directory is not a Git repository');
|
|
30
30
|
}
|
|
31
31
|
// 检查是否有远程仓库配置
|
|
32
32
|
const remotes = await git.getRemotes();
|
|
33
33
|
if (remotes.length === 0) {
|
|
34
|
-
throw new errors_1.GitError('
|
|
34
|
+
throw new errors_1.GitError('Current Git repository has no remote configured');
|
|
35
35
|
}
|
|
36
36
|
// 检查是否能访问远程仓库
|
|
37
37
|
try {
|
|
38
38
|
await git.fetch(['--dry-run']);
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
|
-
throw new errors_1.GitError('
|
|
41
|
+
throw new errors_1.GitError('Cannot access remote repository, please check network connection or repository permissions');
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
async function main() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harryisfish/gitt",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "A command-line tool to help you manage Git repositories and remote repositories, such as keeping in sync, pushing, pulling, etc.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"gitt": "./dist/index.js"
|