Last active
August 29, 2015 14:08
-
-
Save ebc-2in2crc/535638e772ef396c11e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # force-merge | |
| # add the following to <repository>/.hg/hgrc: | |
| # [hooks] | |
| # pretxnchangegroup.forcemerge = /path/to/force-merge.sh | |
| PATH=$PATH:~/bin | |
| exclude='"re:(T_9999999|V[0-9]\.0[a-z]-line)"' | |
| branches=`hg log --template "{branch}\n" --rev "head() and !ancestors(branch('re:default')) and !branch($exclude)"` | |
| if [ -n "$branches" ]; then | |
| echo "There are not merged branches." | |
| echo "Please 'hg update default' and 'hg merge <branch>' first." | |
| echo "$branches" | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # force-one-head | |
| # add the following to <repository>/.hg/hgrc: | |
| # [hooks] | |
| # pretxnchangegroup.forceonehead = /path/to/force-one-head.sh | |
| PATH=$PATH:~/bin | |
| branches=`hg heads --template "{branch}\n" | wc -l` | |
| unified=`hg heads --template "{branch}\n" | sort | uniq | wc -l` | |
| if [ $branches != $unified ]; then | |
| echo "There are multiple heads." | |
| echo "Please 'hg pull' and get your repository up to date first." | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [hooks] | |
| pretxnchangegroup.forceonehead = .hg/hooks/force-one-head.sh | |
| pretxnchangegroup.forcemerge = .hg/hooks/force-merge.sh | |
| pretxnchangegroup.validatebranchname = .hg/hooks/validate-branchname.sh | |
| pretxnchangegroup.validatecommitmessage = .hg/hooks/validate-commitmessage.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # validate-branchname | |
| # add the following to <repository>/.hg/hgrc: | |
| # [hooks] | |
| # pretxnchangegroup.validatebranchname = /path/to/validate-branchname.sh | |
| PATH=$PATH:~/bin | |
| branches=('default' 'T_[0-9]{7}' 'V[0-9]\.0[a-z]-line') | |
| validate() | |
| { | |
| branchname=$1 | |
| for ((i = 0; i < ${#branches[@]}; i++)) { | |
| if [ -z `echo $branchname | sed -r -e "s/${branches[i]}//"` ]; then | |
| return 0 | |
| fi | |
| } | |
| echo "'$branch' is incorrect branch name." | |
| echo "Please correct." | |
| return 1 | |
| } | |
| for branch in `hg branches | gawk '{print $1}'` | |
| do | |
| validate $branch | |
| if [ $? -ne 0 ]; then | |
| exit 1 | |
| fi | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # validate-commitmessage | |
| # add the following to <repository>/.hg/hgrc: | |
| # [hooks] | |
| # pretxnchangegroup.validatecommitmessage = /path/to/validate-commitmessage.sh | |
| PATH=$PATH:~/bin | |
| log=.hg/validate-commitmessage.log | |
| echo > $log | |
| hg log --rev $HG_NODE:tip --template '{node|short}\n' | | |
| while read revision | |
| do | |
| echo >> $log | |
| echo "*******************" >> $log | |
| echo "**** $revision" >> $log | |
| echo "*******************" >> $log | |
| orig=`hg log --rev $revision --template '{desc}'` | |
| echo "$orig" >> $log | |
| # コミットメッセージの行数 | |
| revisioncount=`echo "$orig" | wc -l` | |
| echo --行数: $revisioncount >> $log | |
| # 1行が68文字に収まっていること | |
| fill68=`hg log --rev $revision --template '{desc|fill68}'` | |
| [ "$orig" = "$fill68" ] && issame="収まっている" || issame="収まっていない" | |
| echo "--全ての行が68文字に収まっているかどうか: $issame" >> $log | |
| if [ "$orig" != "$fill68" ]; then | |
| echo "Revision: $revision" | |
| echo "Please enter message in 68 characters or less per line." | |
| exit 1 | |
| fi | |
| # 2行以上ある場合は2行目が空行であること | |
| if [ $revisioncount -eq 1 ]; then | |
| echo "--2行以上ある場合は2行目が空行か: 2行未満なので次のリビジョンへ" >> $log | |
| continue | |
| fi | |
| secondrevision=`echo "$orig" | sed -n -r -e '2p'` | |
| [ -z $secondrevision ] && isempty="空行である" || isempty="空行ではない" | |
| echo "--2行以上ある場合は2行目が空行か: $isempty" >> $log | |
| if [ $secondrevision ]; then | |
| echo "Revision: $revision" | |
| echo "Please second line is blank." | |
| exit 1 | |
| fi | |
| done | |
| if [ $? -ne 0 ]; then | |
| exit 1 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment