#!/bin/bash # A script that retrieves information about the Git tag information # for projects (modules/themes) in the Druapl Git repository. # Exercises the function getLatestContribTag() in drupalLibrary.sh # This information can be found on the drupal source browser site: # http://drupalcode.org/project/drupal.git # (This URL is for the drupal core, adjust as necessary for other projects.) # include library file . "`dirname ${0}`/drupalLibrary.sh" printUsage() { echo -e "Gets contrib latest version information for a Drupal version." echo -e "For more info, see script header." echo -e " " echo -e "Usage:" echo -e "$0 [-ver ] [-alltags] " echo -e "where:" echo -e " " echo -e "-ver " echo -e "\tIf specified, the drupal major version number for which to look up" echo -e "\tversion information. E.g. '6' Defaults to '${DEFAULT_DRUPAL_MAJOR_VERSION}'." echo -e " " echo -e "-alltags" echo -e "\tIf specified, will list all tags and branches (heads)" echo -e "\tin the repo for the given project." echo -e " " echo -e "" echo -e "\tThe name of the module or theme for which to get version information." echo -e " " } ######### # Param handling if [ $# -eq 0 ]; then printUsage exit 0 fi echo " " # Handle flags majorVer="${DEFAULT_DRUPAL_MAJOR_VERSION}" while (true); do case "${1}" in -ver ) if [ $# == 1 ]; then echo -e "** Must specify a version with -ver. Aborting.\n" printUsage exit 1 fi majorVer="${2}" shift; shift ;; -alltags ) pAlltags="-alltags" shift ;; * ) break ;; esac done if [ $# -ne 1 ]; then echo -e "** Invalid number of parameters supplied. Aborting.\n" printUsage exit 1 fi # Get contrib information # Make call three times. It's slow; but it works. project="${1}" echo "For project ${project}:" if [ -n "${pAlltags}" ]; then # listing all tags echo "Branches (Heads) (ascending order):" getContribTags "${project}" "${majorVer}" branch | while read tag; do echo -e "\t${tag}"; done echo "" echo "Tags (ascending order):" getContribTags "${project}" "${majorVer}" tag | while read tag; do echo -e "\t${tag}"; done else # listing just greatest tags latestBranch="`getLatestContribTag "${project}" "${majorVer}" branch`" latestTag="`getLatestContribTag "${project}" "${majorVer}" tag`" echo "Latest branch (head):'${latestBranch}' Latest tag:'${latestTag}'" fi echo -e "\n**Done."