# Usage:
# cd /dir/in/your/workspace/containing/this/file
# source ./env.sh
export APP_HOME=$(dirname $PWD)
export TOOLS_DIR=$APP_HOME/tools
export WORKSHOP_PROJECT=perforce-software-sdp
# Set WORKSHOP_USER in your own personal shell environment
# to avoid guessing.
export WORKSHOP_USER=${WORKSHOP_USER:-Unset}
export PATH=$PATH:$TOOLS_DIR
# Alias to list open SDP jobs.
alias ojobs='$TOOLS_DIR/sdp_jobs_report.sh'
alias ajobs='$TOOLS_DIR/sdp_jobs_report.sh -a'
alias mjobs='$TOOLS_DIR/sdp_jobs_report.sh -me'
#------------------------------------------------------------------------------
# Function: guess_workshop_user ($user)
#
# Try to guess the workshop user based on the current OS user. The assumption
# is that local OS user will NOT be the same as the userid on The Workshop, due
# to intentionally differing user naming conentions. The guessing logic can be
# avoided by defining WORKSHOP_USER environment variable in your personal shell
# environment to your P4USER value for public.perforce.com:1666.
#
# This is striclty a convenience function for SDP project members.
#------------------------------------------------------------------------------
function guess_workshop_user () {
declare user="${1:-$USER}"
declare workshopUser=
if [[ "$WORKSHOP_USER" == "Unset" ]]; then
case "$user" in
(awaters) workshopUser="adrian_waters";;
(rjackson) workshopUser="russell_jackson";;
(rcowham) workshopUser="robert_cowham";;
(ttyler) workshopUser="tom_tyler";;
(*) workshopUser="$USER";;
esac
else
workshopUser="$USER"
fi
echo $workshopUser
}
#------------------------------------------------------------------------------
# Usage: njob [type] [description headline, quotes optional]
# The default for 'type' is Feature; valid values are Bug/Feature. Auto
# spelling correct logic assumes anything that starts with a 'b' is 'Bug',
# anything starting with an 'f' is Feature.
# Examples:
# njob
# njob b
# njob B This is my job headline
# njob FEatuRE "This is my job headline"
# njob f This is my cool new feature.
function njob () {
declare type=${1:-Feature}
if [[ $# -lt 2 ]]; then
echo -e "\nUsage: njob {f|b} Your description goes here.\n"
return 1
fi
shift
declare desc=${*:-__EDITME_DESC__}
declare user=$(guess_workshop_user ${USER:-unknown})
declare -i colonHandling=0
declare -i i=1
declare newJobFile=new_${i}.job
declare -a ComponentList
declare -a ComponentDescList
declare Component
declare ComponentDesc
declare -i ComponentCount=0
declare -i ComponentValid
declare tmpFile=
# Simple auto-correct. I'd like to use the bash built-in ${var^^} syntax,
# but that requires bash 4.x, which isn't standard on Mac yet (but is
# ubiquitous on modern Linux).
type=$(echo $type | awk '{print tolower($0)}')
if [[ ${type} == "b"* ]]; then
type=Bug
elif [[ ${type} == "f"* ]]; then
type=Feature
else
echo -e "\nWarning: Type value specified [$type] should be F (Feature) or B (Bug). Unless the Workshop admins have updated the list of supported values...\n"
fi
if [[ -r $TOOLS_DIR/components.txt ]]; then
# Load components list
while read data; do
[[ $data == "#"* ]] && continue
Component=$data
Component=${Component%%:*}
ComponentDesc=$data
ComponentDesc=${ComponentDesc##*:}
ComponentList[$ComponentCount]=$Component
ComponentDescList[$ComponentCount]=$ComponentDesc
ComponentCount+=1
done < $TOOLS_DIR/components.txt
ComponentCount=0
echo -e "SDP Components:"
for Component in ${ComponentList[*]}; do
echo "$((ComponentCount+1)). $Component: ${ComponentDescList[$ComponentCount]}"
ComponentCount+=1
done
ComponentValid=0
while [[ $ComponentValid -eq 0 ]]; do
echo -e -n "\nSelect a Component (1-$ComponentCount): "
read ComponentId
if [[ -n "$ComponentId" ]]; then
ComponentId=$((ComponentId-1))
Component=${ComponentList[$ComponentId]}
for ccheck in ${ComponentList[*]}; do
[[ "$Component" == "$ccheck" ]] && ComponentValid=1
done
else
Component
ComponentValid=1
fi
done
fi
# Get a unique job file name in the current dir by incrementing an
# integer.
while [[ -f $newJobFile ]]; do
i=$((i+1))
newJobFile=new_${i}.job
done
echo -e "\nGenerating new job file: $newJobFile:\n"
template=$TOOLS_DIR/template.job.p4s
if [[ $desc == *":"* ]]; then
colonHandling=1
desc=$(echo $desc | sed "s/:/__COLON__/g")
fi
sed -e "s:__EDITME_TYPE__:$type:g" \
-e "s:__EDITME_USER__:$user:g" \
-e "s:__EDITME_PROJECT__:$WORKSHOP_PROJECT:g" \
-e "s:__EDITME_COMPONENT__:$Component:g" \
-e "s:__EDITME_DESC__:$desc:g" $template > $newJobFile
if [[ $colonHandling -eq 1 ]]; then
tmpFile=tmp.$newJobFile.$$.$RANDOM
sed "s/__COLON__/:/g" $newJobFile > $tmpFile
mv -f "$tmpFile" $newJobFile
fi
cat $newJobFile
echo -e "\n"
}
| # | Change | User | Description | Committed | |
|---|---|---|---|---|---|
| #19 | 31995 | C. Thomas Tyler | Fixed performance issue in sdp_jobs_report.sh. | ||
| #18 | 31100 | C. Thomas Tyler | Added 'bp' alias. | ||
| #17 | 29509 | C. Thomas Tyler | Added guesses for more user names. | ||
| #16 | 29020 | C. Thomas Tyler | Added support for new 'Doc' type in jobspec. | ||
| #15 | 28583 | C. Thomas Tyler | Added alias for gjh.sh utility. | ||
| #14 | 28058 | C. Thomas Tyler | Added simple fjob function to change a job status to 'fixed'. | ||
| #13 | 28056 | C. Thomas Tyler |
Added new 'ofjobs' alias to report open and fixed jobs, useful for ensuring all 'fixed' jobs are submitted for the next release. Added new 'jo' alias to display a job with 'less' and sans the big comment block. |
||
| #12 | 28004 | C. Thomas Tyler | Added support for jobs of type 'Problem'. | ||
| #11 | 26505 | C. Thomas Tyler |
Tweaked PATH in SDP tools/env.sh to make it easier to generate usage docs for developing SDP. This is used only when developing the SDP; it is not part of the SDP. |
||
| #10 | 26417 | C. Thomas Tyler |
Added WORKSHOP_PROJECT_TAG setting to env.sh to slow the jobs report script to be completely generic. |
||
| #9 | 26360 | C. Thomas Tyler |
Enhanced environment so sdp_jobs_report.sh can run without having a local SDP installation. This was done by adding P4U_ENV and P4U_LIB settings that are based on the current workspace structure rather than an as-deployed SDP structure. |
||
| #8 | 25505 | C. Thomas Tyler | Fixed a typo; removed inactive project members. | ||
| #7 | 24749 | C. Thomas Tyler |
Added basic SDP jobs report script, and refactored aliases to call it. |
||
| #6 | 24748 | C. Thomas Tyler | Converted ojobs from alias to function, greatly enhancned. | ||
| #5 | 22032 | C. Thomas Tyler |
Tweak to take advantage of new Component field in Workshop job spec. |
||
| #4 | 20647 | C. Thomas Tyler |
Optimed env.sh for SDP for working on SDP. Enhanced njob() function to guess at the Workshop user, added a usage message, optimized sed, etc. Renamed template file to avoid confusion by auto-complete with generated job files. |
||
| #3 | 19405 | C. Thomas Tyler | Eliminated hard-coding of utility paths. | ||
| #2 | 18780 | C. Thomas Tyler |
Corrected copy/paste carry over from SDP Workshop job creation tool (originally copied from CBD tools). |
||
| #1 | 16680 | C. Thomas Tyler |
Added handy environment file for working on the SDP, filing SDP jobs, etc. Comes with a .p4ignore file. |