env.sh #1

  • //
  • guest/
  • perforce_software/
  • sdp/
  • tools/
  • env.sh
  • View
  • Commits
  • Open Download .zip Download (2 KB)
# Usage:
# cd /dir/containing/env.sh

export APP_HOME=$(dirname $PWD)
export TOOLS_DIR=$APP_HOME/tools
export WORKSHOP_PROJECT=perforce-software-sdp
export PATH=$PATH:$TOOLS_DIR
MV=/bin/mv
SED=/usr/bin/sed

# Alias to list open SDP jobs.
alias ojobs='p4 jobs -e "$WORKSHOP_PROJECT ^Status=closed"'

# Alias to list all SDP 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
#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.