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
5a3e16b6
Commit
5a3e16b6
authored
Mar 15, 2020
by
shangbj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'update1'
parent
d0774287
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
12 deletions
+32
-12
hooks.js
build/hooks.js
+7
-5
push.js
build/push.js
+25
-7
No files found.
build/hooks.js
View file @
5a3e16b6
...
...
@@ -11,16 +11,18 @@
var
fs
=
require
(
'fs'
);
var
path
=
require
(
'path'
);
// console.log('______', process.env.HUSKY_GIT_STDIN, process.env.HUSKY_GIT_PARAMS, process.env.GIT_INTERNAL_GETTEXT_SH_SCHEME, process.env.GIT_AUTHOR_EMAIL)
// var gitPath = path.resolve(__dirname, `../${process.env.HUSKY_GIT_PARAMS}`);
// var gitPath = path.resolve(__dirname, `../${process.env.HUSKY_GIT_PARAMS}`);
//可以拿到commit msg
// var commitMsg = fs.readFileSync(gitPath, 'utf-8');
// var gitMerge = path.resolve(__dirname, '../.git/MERGE_MSG');
// var gitMerge = path.resolve(__dirname, '../.git/MERGE_MSG');
// 可以拿到 merge信息
// var mergeMsg = fs.readFileSync(gitMerge, 'utf-8');
var
gitHead
=
path
.
resolve
(
__dirname
,
'../.git/ORIG_HEAD'
);
var
headMsg
=
fs
.
readFileSync
(
gitHead
,
'utf-8'
);
// var gitHead = path.resolve(__dirname, '../.git/HEAD'); //可以拿到当前分之
//
var headMsg = fs.readFileSync(gitHead, 'utf-8');
console
.
log
(
'----'
,
headMsg
.
toString
())
//
console.log('----', headMsg.toString())
// var pattern = /<<< HEAD/g;
// if (pattern.test(commitMsg)) {
// console.log(' 提交代码信息不符合规范,信息中应包含字符"<<<<<<< HEAD".\n');
// console.log(' 例如:08-28版本HELLO- frist commit.\n');
...
...
build/push.js
View file @
5a3e16b6
...
...
@@ -3,14 +3,32 @@
// process.stdin.on('data', (data) => {
// console.log('++++', data)
// });
//
const fs = require('fs')
const
fs
=
require
(
'fs'
)
// const path = require('path')
// const shell = require('shelljs')
const
exec
=
require
(
'child_process'
).
exec
//
const exec = require('child_process').exec
// var commitMsg = fs.readFileSync(path.resolve(__dirname, 'git-push.sh'), 'utf-8');
exec
(
'git diff --name-only'
,
function
(
err
,
stdout
,
stderr
){
console
.
log
(
'err'
,
err
)
console
.
log
(
'stdout'
,
stdout
)
console
.
log
(
'stderr'
,
stderr
)
})
// exec('git diff --name-only', function(err, stdout,stderr){
// console.log('err',err)
// console.log('stdout',stdout)
// console.log('stderr',stderr)
// })
let
stream
=
''
if
(
process
.
platform
===
'win32'
)
{
// husky不支持配置.git/hooks/xx 中的sh脚本
// 需要手动加入 exec < /dev/tty 开启交互
stream
=
process
.
stdin
;
}
else
{
stream
=
fs
.
createReadStream
(
'/dev/tty'
);
}
stream
.
setEncoding
(
'utf-8'
);
stream
.
on
(
'error'
,
()
=>
{
// do something...
});
stream
.
on
(
'data'
,
(
data
)
=>
{
// do something...
comsole
.
log
(
data
)
});
\ No newline at end of file
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