All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
getStatistics.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 # Usage function
4 function usage() {
5  echo "$(basename $0) [-h] -t <modules|authors|code|this_year> <directory list>"
6  echo " search the listed directories for information"
7 }
8 
9 # Determine command options (just -h for help)
10 while getopts "h:t:" OPTION
11 do
12  case $OPTION in
13  h ) usage ; exit 0 ;;
14  t ) type=$OPTARG ;;
15  * ) echo "ERROR: Unknown option" ; usage ; exit 1 ;;
16  esac
17 done
18 shift $((OPTIND - 1))
19 
20 
21 if [ -z "${type}" ]
22 then
23  echo 'ERROR: no type specified'
24  usage
25  exit 1
26 fi
27 
28 # can we find the code?
29 if [ $# -lt 1 ]; then
30  echo "ERROR: Please specify a list of directories"
31  usage
32  exit 1
33 fi
34 directory_list=$@
35 for REP in ${directory_list}
36 do
37  if [ ! -d ${REP} ]; then
38  echo "ERROR: ${REP} is not a directory"
39  exit 1
40  fi
41  if [ ! -d ${REP}/.git ]; then
42  echo "ERROR: cannot find ${REP}/.git"
43  echo "ERROR: ${REP} must be the top of a git repository"
44  exit 1
45  fi
46  ##echo "will search ${REP} for ${type}"
47 done
48 
49 # now get the info
50 thisdir=`pwd`
51 ##echo "we are here: ${thisdir}"
52 if [ "${type}" = "modules" ]; then
53  for REP in ${directory_list}; do
54  listm=`find ${REP} -name "*_*.cc" | grep -v test`
55  module_list=`echo ${module_list} ${listm}`
56  done
57  num_mod=`echo ${module_list} | wc -w`
58  ##echo ${module_list}
59  echo "found ${num_mod} modules"
60 elif [ "${type}" = "authors" ]; then
61  for REP in ${directory_list}; do
62  cd ${REP}
63  lista=`git log --all --format='"%cN"' | sort -u`
64  author_list=`echo ${author_list} ${lista}`
65  cd ${thisdir}
66  echo "${lista}"
67  done
68  ##echo ${author_list}
69 elif [ "${type}" = "code" ]; then
70  if [[ `type cloc` ]]; then
71  echo "lines of code excluding fcl files and anything in the ups directory"
72  cloc --exclude-dir=ups ${directory_list}
73  else
74  echo "ERROR: cannot find the cloc utilitiy"
75  exit 1
76  fi
77 elif [ "${type}" = "this_year" ]; then
78  for REP in ${directory_list}; do
79  cd ${REP}
80  listy=`git log --pretty='' --numstat --since 1.year origin/master | grep -v '-' | grep -v ups | cut -f 1 | paste -sd+ - | bc`
81  cd ${thisdir}
82  echo "${REP}: ${listy} lines changed in the last year"
83  done
84 else
85  echo "ERROR: unrecognized type ${type}"
86 fi
87 
88 exit 0
process_name standard_reco_uboone fcl
process_name opflash particleana ie ie ie z
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
*usage exit esac done shift expr $OPTIND OPTIND
then echo ERROR
Definition: grid_setup.sh:42
esac done echo Signal files are
Definition: TrainMVA.sh:25
#define the
shift
Definition: fcl_checks.sh:26
usage
Definition: doGit.sh:21
while getopts
process_name gaushit a
walls no top
Definition: selectors.fcl:105
while getopts h
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo Work directory not specified exit fi echo Work directory
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
list
Definition: file_to_url.sh:28