File tree Expand file tree Collapse file tree 2 files changed +25
-6
lines changed Expand file tree Collapse file tree 2 files changed +25
-6
lines changed 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