# Usage: # cd /dir/containing/env.sh export APP_HOME=$(dirname $PWD) export TOOLS_DIR=$APP_HOME/tools export WORKSHOP_PROJECT=perforce-software-cbd export PATH=$PATH:$TOOLS_DIR MV=$(which mv) SED=$(which sed) # Alias to list CBD jobs to work on (open/inprogress/blocked/review). alias wjobs='p4 jobs -e "$WORKSHOP_PROJECT Status=open|inprogress|blocked|review"' # Alias to list CBD jobs other than closed or punted ones. alias ojobs='p4 jobs -e "$WORKSHOP_PROJECT ^Status=closed ^Status=punted"' # Alias to list all CBD jobs. alias ajobs='p4 jobs -e "$WORKSHOP_PROJECT"' #------------------------------------------------------------------------------ # 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} [[ $# -ne 0 ]] && shift declare desc=${*:-__EDITME_DESC__} declare user=$USER declare -i colonHandling=0 declare -i i=1 declare newJobFile=new_job_${i}.txt declare tmpFile= # Simple auto-correct. I'd like to use the bash built-in ${var^^} syntax, # but that require bash4, 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 Feature or Bug. Unless the Workshop admins have update the list of supported values...\n" fi # Get a unique job file name in the current dir by incrementing an # integer. while [[ -f $newJobFile ]]; do i=$((i+1)) newJobFile=new_job_${i}.txt done echo -e "\nGenerating new job file: $newJobFile:\n" template=$TOOLS_DIR/new_cbd_job.p4s if [[ $desc == *":"* ]]; then colonHandling=1 desc=$(echo $desc | $SED "s/:/__COLON__/g") fi $SED "s:__EDITME_TYPE__:$type:g" $template |\ $SED "s:__EDITME_USER__:$user:g" |\ $SED "s:__EDITME_PROJECT__:$WORKSHOP_PROJECT:g" |\ $SED "s:__EDITME_DESC__:$desc:g" > $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 | |
---|---|---|---|---|---|
#6 | 22310 | C. Thomas Tyler | Adapted aliases for listing jobs to encompoass more job Status values. | ||
#5 | 19398 | C. Thomas Tyler | Eliminated hard-coding of utility paths. | ||
#4 | 15165 | C. Thomas Tyler | Added TOOLS_DIR to PATH. | ||
#3 | 13881 | C. Thomas Tyler |
Added handling for descriptions containing ':' characters which busted the simplitic SED calls. |
||
#2 | 13880 | C. Thomas Tyler |
Made it easier to use this tool for other Workshop projects. Added comment for alias to list open jobs. Added new alias to list all jobs (not just open ones) for a project. |
||
#1 | 13879 | C. Thomas Tyler | Added tools to simplify CBD job management. |