In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to achieve Shell script SVN-based code submission statistics tool", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "how to achieve Shell script SVN-based code submission statistics tool"!
#! / bin/bash-# "" # FILE: lines.sh # # USAGE:. / lines.sh [dir] # AUTHOR: william # # DESCRIPTION: SVN-based code submission statistics tool # OPTIONS:-- # CREATED: 06ap05Accord 12:49:20 PM CST # " "set-o nounset # Treat unset variables as an error # File types followed by FILES_TYPE=" * .cpp * .h * .lua "# people who need statistics Write down the people who need statistics here, separated by a space. Declare-r CODER_LIST= "coder1 coder2" declare-I coder1 declare-I coder2 declare-r USAGE= "Usage: $0 [dir]. Default dir is current dir.\ n "# ERROR CODES; declare-r E_BAD_PATH=1 declare-r E_INVAILED_ARGU=2 declare-r E_NOT_SVN_DIR=3 # TODO blocks some dir not written yet # TODO other way getpath not with / end getpath () {# debug # echo dir_name: ${dir_name} # echo base_name: ${base_name} if [$dir_name = =" / "] | [$base_name = =" / "] Then work_path= "/" else work_path=$ {dir_name} / ${base_name} fi} statistic_codelines () {if [- z "$1"]; then echo "ERROR statistic_codelines not argument" return fi local pwd_length=$ {# PWD} echo "-" echo "${PWD}" for coder in $CODER_LIST Do local num=$ (echo "$1" | grep ${coder} | wc-l) ((${coder} + = num) if [$num-ne 0]; then printf "s |%-7d\ n" ${coder} $num fi done echo "-"} # init check argument set work_path init_work_path () {if [$#-eq 1] Then if [$1 = = "- h"]; then # is help echo-e "$USAGE" elif [- d $1]; then dir_name=$ (dirname ${1}) base_name=$ (basename ${1}) getpath; else echo-e "An invailed argument" echo-e "Use-h get help." Exit $E_INVAILED_ARGU fi fi} # check work_path check_work_path () {if [- z $work_path] | | [!-d $work_path]; then exit $updated BADPATH; fi} # enter work_path enter_work_path () {cd ${work_path} if [! $?] Then echo "Can not enter ${work_path}" fi} # check work_pat is asvn dir is_svn_dir () {(# check if current dir is asvn dir svn info & > / dev/null exit $?) Return $?} action () {local dir_name=. Local base_name= local work_path=$dir_name init_work_path $1 check_work_path enter_work_path # todo can't enter # echo "NOW DIR: $PWD, OLD DIR $OLDPWD" is_svn_dir # todo to next dir local ret=$? If [$ret-ne 0] then echo-e "Current dir\" ${work_path}\ "not a svn dir." Exit $E_NOT_SVN_DIR fi # get source files local files=$ (ls ${FILES_TYPE} 2 > / dev/null) if [- n "$files"] Then local namelist=$ (echo-n ${files} | xargs-n 1 svn blame | awk'{print $2}') # svn blame $files # | grep $1 | wc-l statistic_codelines "$namelist" fi local sub_dirs=$ (find-maxdepth 1-type d-name "[^.] *" 2 > / dev/null) if [- n "$sub_dirs"]; then for dir in $sub_dirs; do action "$dir" done fi cd. } total () {echo "- TOTOAL -" echo "NAME | lines" echo "- -" for coder in $CODER_LIST; do if [${! coder}-ne 0] Then printf "s |%-7d\ n" ${coder} ${! coder} fi done echo "- -"} # main echo "- start counting, please be patient. :) "action $1 total exit 0 Thank you for reading, the above is the content of" how to implement Shell script SVN-based code submission statistics tool ". After the study of this article, I believe you have a deeper understanding of how to implement Shell script SVN-based code submission statistics tool, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.