File tree Expand file tree Collapse file tree 5 files changed +37
-11
lines changed Expand file tree Collapse file tree 5 files changed +37
-11
lines changed Original file line number Diff line number Diff line change 1
1
## 更新日志
2
2
3
+ ### 1.0.4
4
+
5
+ - feat: 新增 ` lg ` 命令
6
+
7
+ - fix: 修复 ` p ` 、` pr ` 命令
8
+
3
9
### 1.0.3
4
10
5
11
- fix: 修复 ` r ` 命令
6
12
7
13
### 1.0.2
8
14
9
- - ` l ` 命令变更为 ` b `
15
+ - ` l ` 命令变更为 ` b `
10
16
11
17
### 1.0.1
12
18
13
19
新增 ` a cm r p pr pl co cb ` 命令
14
20
15
21
### 1.0.0
16
22
17
- 发布正式版本
23
+ 发布正式版本
Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ $ npm i -g @lxfu/gm
22
22
- ` gm cm commitInfo ` : 相当于 ` git commit -m commitInfo `
23
23
- ` gm r commitId ` : 相当于 ` git reset commitId `
24
24
- ` gm p ` : 相当于 ` git push `
25
+ - ` gm p -f ` : 相当于 ` git push -f `
25
26
- ` gm pr ` : 用于没有远程分支的提交
26
- - ` gm pr ` : 相当于 ` git push origin HEAD `
27
- - ` gm pr branch ` : 相当于 ` git push --set-upstream origin branch `
27
+ - ` gm pr [-f] ` : 相当于 ` git push origin HEAD `
28
+ - ` gm pr branch [-f] ` : 相当于 ` git push --set-upstream origin branch `
28
29
- ` gm pl ` : 相当于 ` git pull `
29
30
- ` gm co branch ` : 相当于 ` git checkout branch `
30
31
- ` gm cb branch ` : 相当于 ` git checkout -b branch `
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " @lxfu/gm" ,
3
- "version" : " 1.0.3 " ,
3
+ "version" : " 1.0.4 " ,
4
4
"description" : " Git branch manger" ,
5
5
"bin" : " ./bin/index.js" ,
6
6
"scripts" : {},
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const {
12
12
onPushRemote,
13
13
onPull,
14
14
onCheckoutB,
15
+ onLog,
15
16
} = require ( "./module" ) ;
16
17
17
18
const program = new commander . Command ( "gm" ) ;
@@ -42,10 +43,15 @@ program
42
43
43
44
program . command ( "r <commit-id>" ) . description ( "Git reset" ) . action ( onReset ) ;
44
45
45
- program . command ( "p" ) . description ( "Git push" ) . action ( onPush ) ;
46
+ program
47
+ . command ( "p" )
48
+ . description ( "Git push" )
49
+ . option ( "-f" , "force push" )
50
+ . action ( onPush ) ;
46
51
program
47
52
. command ( "pr [branch]" )
48
53
. description ( "Git push origin" )
54
+ . option ( "-f" , "force push" )
49
55
. action ( onPushRemote ) ;
50
56
program . command ( "pl" ) . description ( "Git pull" ) . action ( onPull ) ;
51
57
@@ -55,4 +61,9 @@ program
55
61
. description ( "Git checkout -b" )
56
62
. action ( onCheckoutB ) ;
57
63
64
+ program
65
+ . command ( "lg [depth]" )
66
+ . description ( "Git log oneline -depth" )
67
+ . action ( onLog ) ;
68
+
58
69
program . parse ( process . argv ) ;
Original file line number Diff line number Diff line change @@ -74,8 +74,9 @@ const onCheckoutB = (branch) => {
74
74
exit ( 1 ) ;
75
75
} ;
76
76
77
- const onPush = ( ) => {
78
- exec ( `git push` ) ;
77
+ const onPush = ( option ) => {
78
+ const { f } = option ;
79
+ exec ( `git push ${ f ? "-f" : "" } ` ) ;
79
80
exit ( 1 ) ;
80
81
} ;
81
82
@@ -84,11 +85,12 @@ const onPull = () => {
84
85
exit ( 1 ) ;
85
86
} ;
86
87
87
- const onPushRemote = ( branch ) => {
88
+ const onPushRemote = ( branch , option ) => {
89
+ const { f } = option ;
88
90
if ( branch ) {
89
- exec ( `git push --set-upstream origin ${ branch } ` ) ;
91
+ exec ( `git push --set-upstream origin ${ branch } ${ f ? "-f" : "" } ` ) ;
90
92
} else {
91
- exec ( `git push origin HEAD` ) ;
93
+ exec ( `git push origin HEAD ${ f ? "-f" : "" } ` ) ;
92
94
}
93
95
exit ( 1 ) ;
94
96
} ;
@@ -98,6 +100,11 @@ const onReset = (commitId) => {
98
100
exit ( 1 ) ;
99
101
} ;
100
102
103
+ const onLog = ( depth = 50 ) => {
104
+ exec ( `git log --oneline -${ depth } ` ) ;
105
+ exit ( 1 ) ;
106
+ } ;
107
+
101
108
module . exports = {
102
109
onList,
103
110
onDelete,
@@ -110,4 +117,5 @@ module.exports = {
110
117
onPushRemote,
111
118
onPull,
112
119
onCheckoutB,
120
+ onLog,
113
121
} ;
You can’t perform that action at this time.
0 commit comments