本文将介绍如何使用SVN的hook来严格控制向SVN提交代码,让SVN控制没有有效的问题不能提交代码,不是问题的owner不能提交代码等等,让SVN实现一些收费的代码管理系统才有的功能。
安装工具软件
首先我们需要安装必须的工具软件JQ和RedmineCLI。
JQ是一个轻量级JSON数据流命令行处理器,具体请参见JQ网站。
RedmineCLI是基于NodeJS的Redmine命令行客户端,具体请参见RedmineCLI网站。
安装JSON命令行处理器(jq)
root@scm:/var/svn/repos# apt install jq
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libjq1 libonig4
The following NEW packages will be installed:
jq libjq1 libonig4
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 276 kB of archives.
After this operation, 930 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libonig4 amd64 6.7.0-1 [119 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 libjq1 amd64 1.5+dfsg-2 [111 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 jq amd64 1.5+dfsg-2 [45.6 kB]
Fetched 276 kB in 1s (325 kB/s)
Selecting previously unselected package libonig4:amd64.
......
......
......
Setting up libjq1:amd64 (1.5+dfsg-2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up jq (1.5+dfsg-2) ...
root@scm:/var/svn/repos#
安装Redmine命令行客户端(redmine)
首先安装NPM
root@scm:/var/svn/repos# apt install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
gyp libjs-async libjs-inherits libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi node-ansi-color-table
node-archy node-async node-balanced-match node-block-stream node-brace-expansion node-builtin-modules node-combined-stream
node-concat-map node-cookie-jar node-delayed-stream node-forever-agent node-form-data node-fs.realpath node-fstream
node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs node-gyp node-hosted-git-info node-inflight
node-inherits node-ini node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile node-lru-cache node-mime
node-minimatch node-mkdirp node-mute-stream node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once
node-osenv node-path-is-absolute node-pseudomap node-qs node-read node-read-package-json node-request node-retry node-rimraf
node-semver node-sha node-slide node-spdx-correct node-spdx-expression-parse node-spdx-license-ids node-tar node-tunnel-agent
node-underscore node-validate-npm-package-license node-which node-wrappy node-yallist nodejs-dev python-pkg-resources
Suggested packages:
......
......
......
Setting up node-fstream-ignore (0.0.6-2) ...
Setting up node-tar (2.2.1-1) ...
Setting up node-gyp (3.6.2-1ubuntu1) ...
Setting up npm (3.5.2-0ubuntu4) ...
root@scm:/var/svn/repos#
使用NPM安装客户端redmine
root@scm:/var/svn/repos# npm install -g redmine-cli
npm WARN deprecated swig@1.4.2: This package is no longer maintained
/usr/local/bin/redmine -> /usr/local/lib/node_modules/redmine-cli/bin/redmine
> spawn-sync@1.0.15 postinstall /usr/local/lib/node_modules/redmine-cli/node_modules/spawn-sync
> node postinstall
/usr/local/lib
└─┬ redmine-cli@0.8.1
├─┬ cli-table@0.3.1
......
......
......
├── http-basic@2.5.1
├─┬ promise