Initial add of defaria.com
[clearscm.git] / defaria.com / Computers / code / bin / releasetools / lockbugs
1 #!/bin/bash
2 ################################################################################
3 #
4 # File:         lockbugs
5 # Description:  Locks all bugs in the current release (Must be run by $ccadmin)
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 [ ! -z "$locked"           -o \
90          "$state" = "Closed"    -o \
91          "$state" = "Verified" ]; then
92     let already_locked_bugs=already_locked_bugs+1
93   fi
94
95   # Process only Resolved bugs
96   if [ "$state" = "Resolved" ]; then
97     let resolved_bugs=resolved_bugs+1
98
99     if [ -z "$locked" ]; then
100       # If not already locked then lock it
101       echo "Found unlocked, resolved bug $bugid - attempting to lock it..."
102       lockbug $bugid
103
104       status=$?
105
106       if [ $status -eq 0 ]; then
107         let locked_bugs=locked_bugs+1
108       fi
109
110       # Total up errors
111       let errors=errors+status
112     fi
113   fi
114 done
115
116 # Report results
117 declare -i not_resolved=bugs-resolved_bugs
118
119 echo -e "Bugs processed:\t\t$bugs"
120 echo -e "Resolved:\t\t$resolved_bugs"
121 echo -e "Not resolved:\t\t$not_resolved"
122 echo -e "Currently locked:\t$already_locked_bugs"
123 echo -e "Newly locked:\t\t$locked_bugs"
124 echo -e "Errors:\t\t\t$errors"