#!/usr/bin/env bash
#
# pre-commit hook:
# Check for Habitat default variables in a plan.sh file
#
# Authors:
# - Mike Fiedler <miketheman@gmail.com>

required_variables=(
  pkg_description
  pkg_license
  pkg_maintainer
  pkg_name
  pkg_origin
  pkg_source
  pkg_upstream_url
  pkg_version
)

for var in "${required_variables[@]}"
do
  grep -Eq "^$var" "$@"
  if [[ $? -ne 0 ]]
  then
    echo "Error detected by Check Default Variables."
    echo ""
    echo "    Unable to find '$var' in $*"
    echo ""
    echo "Ensure that your plan.sh contains all of:"
    IFS=$'\n'; echo "${required_variables[*]}"
    exit 1
  fi

done

exit 0

#!/usr/bin/env bash
#
# pre-commit hook:
# Check for Habitat default variables in a plan.sh file
#
# Authors:
# - Mike Fiedler <miketheman@gmail.com>

required_variables=(
  pkg_description
  pkg_license
  pkg_maintainer
  pkg_name
  pkg_origin
  pkg_upstream_url
)

for var in "${required_variables[@]}"
do
  grep -Eq "^$var" "$@"
  if [[ $? -ne 0 ]]
  then
    echo "Error detected by Check Default Variables."
    echo ""
    echo "    Unable to find '$var' in $*"
    echo ""
    echo "Ensure that your plan.sh contains all of:"
    IFS=$'\n'; echo "${required_variables[*]}"
    exit 1
  fi

done

exit 0

Drop required variable check for pkg_source & pkg_version.
[ci] Drop required variable check for pkg_source & pkg_version.

* A required `$pkg_source` was dropped in habitat-sh/habitat#2074 which
affects Scaffolding package Plans where the code is located with the
Plan.
* A require `$pkg_version` was dropped in habitat-sh/habitat#2235 which
will affect the cacerts and cargo-nightly Plans once updated to use the
new `pkg_version()` helper.

Signed-off-by: Fletcher Nichol <77a0fd9e8048bbacd11af4e957bc6ff03b549f49@nichol.ca>
