Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
G
git-hooks-test
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shangbj
git-hooks-test
Commits
0c4d9403
Commit
0c4d9403
authored
Mar 15, 2020
by
shangbj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
2
parent
718965bf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
app.js
app.js
+4
-1
commit.js
build/commit.js
+22
-0
hooks.js
build/hooks.js
+1
-1
push.js
build/push.js
+1
-1
package.json
package.json
+1
-0
No files found.
app.js
View file @
0c4d9403
console
.
log
(
'app11.js11'
);
\ No newline at end of file
console
.
log
(
'app11.js11'
);
<<<<<<<
HEAD
=====
build/commit.js
0 → 100644
View file @
0c4d9403
const
execSync
=
require
(
'child_process'
).
execSync
// git 对所有冲突的地方都会生成下面这种格式的信息,所以写个检测冲突文件的正则
const
isConflictRegular
=
"<<<<<<< HEAD
\
s"
let
results
try
{
// git grep 命令会执行 perl 的正则匹配所有满足冲突条件的文件
results
=
execSync
(
`git grep -n -P "
${
isConflictRegular
}
"`
,
{
encoding
:
'utf-8'
})
}
catch
(
e
)
{
console
.
log
(
'没有发现冲突,等待 commit'
)
process
.
exit
(
0
)
}
if
(
results
)
{
console
.
error
(
'发现冲突,请解决后再提交,冲突文件:'
)
console
.
error
(
results
.
trim
())
process
.
exit
(
1
)
}
process
.
exit
(
0
)
\ No newline at end of file
build/hooks.js
View file @
0c4d9403
...
...
@@ -28,4 +28,4 @@ var path = require('path');
// console.log(' 例如:08-28版本HELLO- frist commit.\n');
// process.exit(1);
// }
// process.exit(0);
\ No newline at end of file
// process.exit(0);
build/push.js
View file @
0c4d9403
...
...
@@ -15,7 +15,7 @@ const path = require('path')
// console.log('stdout',stdout)
// console.log('stderr',stderr)
// })
console
.
log
(
'______'
,
process
.
env
.
GIT_PUSH_OPTION_COUNT
,
process
.
env
.
GIT_PUSH_OPTION_0
)
// console.log('______', process.env
, process.env.GIT_PUSH_OPTION_COUNT, process.env.GIT_PUSH_OPTION_0)
// let stream = ''
// if (process.platform === 'win32') {
// // husky不支持配置.git/hooks/xx 中的sh脚本
...
...
package.json
View file @
0c4d9403
...
...
@@ -12,6 +12,7 @@
},
"husky"
:
{
"hooks"
:
{
"pre-commit"
:
"node ./build/commit.js"
,
"commit-msg"
:
"node ./build/hooks.js $HUSKY_GIT_PARAMS $HUSKY_GIT_STDIN $GIT_INTERNAL_GETTEXT_SH_SCHEME $GIT_AUTHOR_EMAIL"
,
"pre-push"
:
"node ./build/push.js $GIT_PUSH_OPTION_COUNT $GIT_PUSH_OPTION_0"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment