These are a few helper functions written in Bash that I use to help with daily tasks that are repetitive and eat up time.
If you find bugs or make updates to these scripts that would be beneficial to others, please contribute them back to the community.
USER="<your username here>"
DRUPAL_LOC="<path to drupal install on sandboxes here>"
REPOS=(list of supported project repositories)
REPO_HOME=<local path to where your repositories are installed>
# Return the url of the sandbox
function sandbox {
echo "${2:-root}@<url-of-sandbox>-${1:-$USER}<url-of-sandbox>"
}
# Determine master branch by repo convention if not master
function getMaster {
master="master"
# logic to determine the appropriate development root on which to build your branches
[[ $(pwd | grep -i "<name of repo>") ]] && master="<name of development branch>"
...
# return
echo $master
}
#Load functions
for file in $(find <local path where you keep these scripts> -type f -name "functions-*"); do
test -f $file && . $_
done
newbranch <branch-name>
: Creates a new branch off of the appropriate master branch, along with the tracking branch.
$ newbranch US123-new-branch
fork <branch-name>
: Creates a new branch based on the current branch you are on (as well as the tracking branch).
$ fork US123-branch-fork
push
: Runs the linter first if you are in webux or webrh, prompts for a commit message (or you can optionally put the message after the push command), prefixes the message with the user story for the branch, then pushes to tracking branch
$ push
$ push Minor update to package.json
$(currbranch)
: Provides the name of the current branch for the repo you are in.
$ echo $(currbranch)
gitclean
: Runs git add .
and git stash
to clear out any files you don't currently needco <branch-name>
: Stashes uncommitted changes, checks out the appropriate version of master, checks out the branch, and pulls the latest.
$ co US123-branch-to-checkout
killbranch <branch-name> <branch-name>
: Removes the local and tracking branch for the provided branch(es).
$ killbranch US123-branch-to-kill US124-branch-to-die
$ project
will automatically cd you to the top level of that repo.sshsandbox
: SSH's into your sandbox or can accept 1 input to log into a box that doesn't match your username.
$ sshsandbox
or $ sshsandbox <other-username>
buildstatus
: This will return the build status of your sandbox; to check the status of a box other than your own, pass in that username: $ buildstatus <other-username>
buildbox
: This will kick off a build of your sandbox off of master and show you it's build progress in the command line.These will be less useful for general audiences.
runwraith
: Still a WIP but will (in theory) kick off grunt watcher in the background and generate wraith baselines.pksync
: This bower links the webrh repository with webdrupal and rsyncs to your sandbox. To change the sandbox it builds on, you must set the USER variable to a different value: $ USER="<other-username>"; pksync
pkimport
: This ssh's into your sandbox, cds to the location of the Drupal install, runs the pbi importer, then clears the cache. The default runs --all or you can pass in the specific patterns you want to import.
$ pkimport card group band
$ USER=<other-username>; pkimport card group band;
pkbuild
: This ssh's into your sandbox, cds to the location of the Drupal install, runs a pbi remove and then the import, clearing the cache at the end. The default runs --all or you can pass in the specific patterns you want to remove and reimport. To import on a box other than your own, follow the same steps as the pkimport (above).
$ pkbuild card group band
testupdate <test names>
: This accepts a space-separated list of patterns and will create new baselines for those patterns for webrh.