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
fc7250d9
Commit
fc7250d9
authored
Mar 15, 2020
by
shangbj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
99757eba
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
1 deletion
+41
-1
push.js
build/push.js
+40
-0
package.json
package.json
+1
-1
No files found.
build/push.js
0 → 100644
View file @
fc7250d9
// console.log('___', process.stdin)
// process.stdin.on('data', (data) => {
// console.log('++++', data)
// });
const
fs
=
require
(
'fs'
)
const
path
=
require
(
'path'
)
// const shell = require('shelljs')
// const exec = require('child_process').exec
// var commitMsg = fs.readFileSync(path.resolve(__dirname, '../.git/refs/heads'), 'utf-8');
// console.log(local_ref,local_sha,remote_ref,remote_sha)
// exec('git diff --name-only', function(err, stdout,stderr){
// console.log('err',err)
// console.log('stdout',stdout)
// console.log('stderr',stderr)
// })
// 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脚本
// // 需要手动加入 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...
// console.log(data)
// });
var
gitHead
=
path
.
resolve
(
__dirname
,
'../.git/refs/remotes/origin/HEAD'
);
//可以拿到当前分之
var
headMsg
=
fs
.
readFileSync
(
gitHead
,
'utf-8'
);
console
.
log
(
'----'
,
headMsg
.
toString
())
// process.exit(1)
\ No newline at end of file
package.json
View file @
fc7250d9
...
...
@@ -12,7 +12,7 @@
},
"husky"
:
{
"hooks"
:
{
"pre-push"
:
"node ./build/
hooks
.js"
"pre-push"
:
"node ./build/
push
.js"
}
},
"keywords"
:
[],
...
...
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