Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / bin / releasetools / unlockedbugs
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         unlockedbugs
5 # Description:  Displays all remaining unlocked bugs
6 # Author:       Andrew@DeFaria.com
7 # Created:      Mon Jun  2 11:19:46 PDT 2003
8 # Language:     bash
9 #
10 # (c) Copyright 2001-2003, Andrew@DeFaria.com, all rights reserved.
11 #
12 ################################################################################
13 # Set me to command name
14 me=$(basename $0)
15
16 # Source /etc/site_parms
17 if [ -f /etc/site_parms ]; then
18   . /etc/site_parms
19 else
20   echo "$me: WARNING: /etc/site_parms does not exist!"
21 fi
22
23 # Set adm_base
24 adm_base="$SITE_TOOLS_PATH/adm"
25
26 # Set adm_fpath
27 adm_fpath=${adm_fpath:-$adm_base/functions}
28
29 # Source functions
30 . $adm_fpath/common
31
32 # Admin user
33 ccadmin="ccadmin"
34
35 if [[ $USER != $ccadmin ]]; then
36   error "This command must be executed by $ccadmin" 1
37 fi
38
39 # Set release_web_area
40 release_web_area=~adefaria/www/Internal/Release
41
42 # Set view area
43 view="$SITE_SNAPSHOT_VIEW_PATH/$SITE_OFFICIAL_VIEW/salira"
44
45 # Commands used
46 cqc="$SITE_TOOLS_PATH/bin/cqc"
47
48 # Cd there to operate on files
49 cd $release_web_area
50
51 if [ $? -ne 0 ]; then
52   echo "$me: Error: Unable to cd to release web area"
53   exit 1
54 fi
55
56 # Current release is now stored in a file
57 current_release="$(cat addbug/current_release).bugs"
58
59 # Declare some counters
60 declare -i bugs=0
61 declare -i resolved_bugs=0
62 declare -i already_locked_bugs=0
63 declare -i locked_bugs=0
64 declare -i errors=0
65
66 declare -i status=0
67
68 # Get and process a list of bugs
69 buglist=$(grep -ve ^# -e ^* "$current_release" | cut -f1)
70
71 # Must be in a view/vob context
72 cd "$view"
73
74 if [ $? -ne 0 ]; then
75   echo "$me: Error: Unable cd to official view ($view)"
76   exit 1
77 fi
78
79 for bugid in $buglist; do
80   # Count the bug
81   let bugs=bugs+1
82
83   # Get state of bug
84   state=$($cqc $bugid state)
85
86   # Check to see if bug is already locked
87   locked=$(cleartool lslock -short lbtype:$bugid 2> /dev/null)
88
89   if [  "$locked" != "" ]; then
90     let locked_bugs=locked_bugs+1
91   elif [ "$state" = "Closed" -o "$state" = "Verified" ]; then
92     let locked_bugs=locked_bugs+1
93   else
94     let unlocked_bugs=unlocked_bugs+1
95     owner=$(cqc $bugid owner)
96     headline=$(cqc $bugid headline)
97     echo "Bug ID $bugid $state \"$headline\" <$owner@salira.com> is still unlocked"
98   fi
99 done
100
101 # Report results
102 echo -e "Bugs processed:\t\t$bugs"
103 echo -e "Locked bugs:\t\t$locked_bugs"
104 echo -e "Unlocked bugs:\t\t$unlocked_bugs"