SVN禁止提交时不写注释

最常用的方法,就是使用SVN提供的pre-commit钩子。
具体做法是,在对应的repository下的hooks文件夹下中,新建对于的pre-commit脚本,来禁止提交。

1.windows下pre-commit.bat

@echo off
setlocal

set REPOS=%1
set TXN=%2

rem 保证输入8个字符
svnlook log %REPOS% -t %TXN% | findstr "........" > nul
if %errorlevel% gtr 0 goto :err_action

rem 过滤空格字符
svnlook log %REPOS% -t %TXN% | findstr /ic:"        " > nul
if %errorlevel% gtr 0 goto :success

:err_action
echo 备注信息验证失败。                >&2
echo 提交代码时,必须填写备注信息。    >&2
echo 备注信息不少于8个字符(或4个汉字)。>&2
goto :err_exit


:err_exit
exit 1

:success
exit 0

2.linux下pre-commit.sh

#!/bin/sh

REPOS="$1"
TXN="$2"

SVNLOOK=/usr/local/bin/svnlook
LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`

#要求注释不能少于8个字符,您可自定义
if ["$LOGMSG" -lt 8];
then
  echo -e "\n备注信息验证失败。\n提交代码时,必须填写备注信息。\n备注信息不少于8个字符(或4个汉字)。" 1>&2
  exit 1
fi 

exit 0

Git04设置代理

1、设置http代理

git config --global https.proxy "http://127.0.0.1:1080"
git config --global https.proxy "https://127.0.0.1:1080"

2、设置socket代理

git config --global http.proxy "socks5://127.0.0.1:9527"
git config --global https.proxy "socks5://127.0.0.1:9527"

3、取消代理

git config --global --unset http.proxy
git config --global --unset https.proxy

GitHub03SSH授权

用低版本的github做上传的时候,会有提示

Permission denied (publickey). 

最简单的方法,就是安装新版本的GitHub。

如果你实在不愿意升级,那可以用以下步骤来进行:

#1、测试ssh,会提示Permission denied (publickey). 
ssh -T git@github.com 
#2、生成新的授权文件,如果你没有改过配置,那文件名为github_rsa,密码保持为空即可
ssh-keygen -t rsa -C "neohope@yahoo.com"
#3、查看新的key
ssh-add -l
#4、登录GitHub网站,到管理SSH Keys的地方,上传public key
#~/.ssh/github_rsa.pub
#5、测试ssh,会提示成功
ssh -T git@github.com 

搞定!

Git02常用命令

1、设置个人信息

git config --global user.name "xxx"
git config --global user.email "xxx@xxx.xxx"

2、提交

#初始化本地git
cd hello-git
git init

#新建README文件
touch README
git add README

#提交文件到本地Git
git commit -m 'first commit'

#提交文件到远程Git
git remote add origin git@github.com:username/hello-git.git
git push -u origin master

3、取回

git clone git@github.com:username/hello-git.git

取回(包含子模块)

git clone --recursive -j6 git@github.com:username/hello-git.git

取回(包含子模块)

git clone git@github.com:username/hello-git.git
cd hello-git
git submodule update --init --recursive

4、Fork

#产生Fork后取回
git clone git@github.com:username/hello-git.git
cd hello-git

#追加上级代码信息
git remote add upstream git://github.com/SomeOne/hello-git.git
git fetch upstream
#合并上级代码
git fetch upstream
git merge upstream/master

5、创建分支

#创建分支
git checkout -b mybranch

6、合并分支

#合并分支
git checkout master
git merge mybranch
git branch -d mybranch

7、改变远程库地址

git remote set-url origin 新地址

MyEclipe中Java工程手动增加Maven支持

1修改文件.project

<buildSpec>
	<buildCommand>
		<name>org.maven.ide.eclipse.maven2Builder</name>
		<arguments>
		</arguments>
	</buildCommand>
</buildSpec>
<natures>
	<nature>org.maven.ide.eclipse.maven2Nature</nature>
</natures>

2.修改文件.classpath

<classpath>
	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
</classpath>

3.新增文件pom.xml

<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&#93;
  <modelVersion>4.0.0</modelVersion>

  <groupId>groupId</groupId>
  <artifactId>artifactId</artifactId>
  <version>1.0</version>
  <name>name</name>
 
  <dependencies>
  </dependencies>

  <build>
      <plugins>
      </plugins>
  </build>  
</project>

Maven常用参数

1.常用命令参数
进行编译

mvn compile

进行打包

#测试并打包
mvn package
#直接打包,不进行测试
mvn package -DskipTests=true
#打Jar包
mvn jar:jar
#打War包
mvn war:war
#打War包但不执行最后的压缩
mvn war:exploded

进行测试

#编译单元测试
mvn test-compile
#编译并允许单元测试
mvn test

安装到本地repository

mvn install
mvn install -DskipTests=true
mvn install -DskipTests=true --fail-at-end
#安装jar包到本地仓库
mvn install:install-file -DgroupId=groupId -DartifactId=artifactId -Dversion=1.0.0 -Dpackaging=jar -Dfile=xxx.jar

安装到远程repository

mvn deploy

进行清理

mvn clean

生成网站

#生成网站
mvn site
#生成网站并发布
mvn site-deploy

打包源码包

#打包源码
mvn source:jar
#下载项目源码
mvn dependency:sources -DdownloadSources=true -DdownloadJavadocs=true

打包测试源码包

mvn source:test-jar

拷贝依赖到target目录

#拷贝依赖
mvn dependency:copy-dependencies
#依赖分析
mvn dependency:analyze
mvn dependency:tree

生成ecplise项目

mvn eclipse:eclipse

生成ecplise项目

mvn idea:idea

生成文档

#单模块项目生成文档
mvn javadoc:javadoc
#多模块项目生成文档
mvn javadoc:aggregate

创建Jar项目

mvn archetype:create -DgroupId=gourpid -DartifactId=artifactId

创建War项目

mvn archetype:create -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-webapp -DgroupId=gourpid  -DartifactId=artifactId

2.settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"]

<localRepository>X:/Maven/repository</localRepository>

<servers>
<server>
<id>neo-public</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>neo-releases</id>
<username>username</username>
<password>password</password>
</server>
<server>
<id>neo-snapshots</id>
<username>username</username>
<password>password</password>
</server>
</servers>

<mirrors>
<mirror>
<id>neo-public</id>
<name>Neohope Nexux Public Mirror</name>
<url>http://192.168.xxx.xxx:8081/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>

<profiles>
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>neo-public</id>
<name>Neohope Nexux Public Mirror</name>
<url>http://192.168.xxx.xxx:8081/nexus/content/groups/public</url>
</repository>
</repositories>
</profile>
</profiles>

<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>

</settings>

3.pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"]
<modelVersion>4.0.0</modelVersion>

<groupId>com.neohope.xxx</groupId>
<artifactId>xxx-xxx</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>xxx-xxx</name>
<url>http://neohope.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<nexus.url>http://192.168.xxx.xxx:8081</nexus.url>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>neo-releases</id>
<name>Internal Releases</name>
<url>${nexus.url}/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>neo-snapshots</id>
<name>Internal Snapshots</name>
<url>${nexus.url}/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
</project>

Maven Lifecycles

Maven有三大生命周期
default:默认生命周期,用于软件构建
clean:用于项目清理
site:用于生成项目网站

1、default

<phases>
  <phase>validate</phase>
  <phase>initialize</phase>
  <phase>generate-sources</phase>
  <phase>process-sources</phase>
  <phase>generate-resources</phase>
  <phase>process-resources</phase>
  <phase>compile</phase>
  <phase>process-classes</phase>
  <phase>generate-test-sources</phase>
  <phase>process-test-sources</phase>
  <phase>generate-test-resources</phase>
  <phase>process-test-resources</phase>
  <phase>test-compile</phase>
  <phase>process-test-classes</phase>
  <phase>test</phase>
  <phase>prepare-package</phase>
  <phase>package</phase>
  <phase>pre-integration-test</phase>
  <phase>integration-test</phase>
  <phase>post-integration-test</phase>
  <phase>verify</phase>
  <phase>install</phase>
  <phase>deploy</phase>
</phases>

2、clean

<phases>
  <phase>pre-clean</phase>
  <phase>clean</phase>
  <phase>post-clean</phase>
</phases>
<default-phases>
  <clean>
    org.apache.maven.plugins:maven-clean-plugin:2.5:clean
  </clean>
</default-phases>

3、site

<phases>
  <phase>pre-site</phase>
  <phase>site</phase>
  <phase>post-site</phase>
  <phase>site-deploy</phase>
</phases>
<default-phases>
  <site>
    org.apache.maven.plugins:maven-site-plugin:3.3:site
  </site>
  <site-deploy>
    org.apache.maven.plugins:maven-site-plugin:3.3:deploy
  </site-deploy>
</default-phases>