Skip to content

Commit

Permalink
Cleaning prin so that it passes shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
pswica committed Jun 30, 2019
1 parent 3a2b94b commit d168425
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions prin
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ PROG=${0##*/}
# If NO ARGUMENTS should return *usage*, uncomment the following line:
usage=${1:-yes}

source $(dirname $(readlink -ne $BASH_SOURCE))/lib/common.sh
source $TOOL_LIB_PATH/gitlib.sh
# shellcheck source=./lib/common.sh
source "$(dirname "$(readlink -ne ${BASH_SOURCE[0]})")/lib/common.sh"
# shellcheck source=./lib/gitlib.sh
source "$TOOL_LIB_PATH/gitlib.sh"

###############################################################################
# FUNCTIONS
Expand All @@ -70,7 +72,7 @@ show_tags () {
local pr=$1
local initial_commit=$2
shift 2
local cp_commits=($*)
local cp_commits=("$*")
local commit
local commit_seconds
local tag_seconds
Expand All @@ -97,11 +99,11 @@ show_tags () {
fi

# We only care about the initial commit for latency calculation
commit_seconds=$(git show -s --format="%ct" $initial_commit)
commit_seconds=$(git show -s --format="%ct" "$initial_commit")

for commit in $initial_commit ${cp_commits[*]}; do
for tag in $(git tag --contains $commit); do
tag_seconds=$(git show -s --pretty=format:%ct $tag |tail -1)
for tag in $(git tag --contains "$commit"); do
tag_seconds=$(git show -s --pretty=format:%ct "$tag" |tail -1)

# Convert to days with some precision
days=$(echo "scale=2; ($tag_seconds-$commit_seconds)/86400"|bc)
Expand All @@ -121,7 +123,7 @@ show_tags () {
###############################################################################
# Stubbed out
security_layer::hosted_map () {
logecho "Skipping $FUNCNAME extensions..."
logecho "Skipping ${FUNCNAME[0]} extensions..."
return 0
}

Expand All @@ -142,15 +144,15 @@ if [[ ${POSITIONAL_ARGV[0]} =~ [0-9]{5,} ]]; then
# non-cherrypick commit searches on branches
INITIAL_COMMIT=$(git log --grep "Merge pull request #$PR" \
--all --pretty=format:"%h")
CP_COMMITS=($(git log --grep "cherry-pick-of-.*#$PR-" \
--all --pretty=format:"%h"))
mapfile -i CP_COMMITS < <(git log --grep "cherry-pick-of-.*#$PR-" \
--all --pretty=format:"%h")
else
# TODO: Need to validate this is a git hash
INITIAL_COMMIT=("${POSITIONAL_ARGV[0]}")
fi

[[ -z "$INITIAL_COMMIT" ]] && common::exit 1 "No commit/pr found in this repo."
[[ -z "${INITIAL_COMMIT[0]}" ]] && common::exit 1 "No commit/pr found in this repo."

security_layer::hosted_map

show_tags "$PR" $INITIAL_COMMIT ${CP_COMMITS[*]}
show_tags "$PR" "${INITIAL_COMMIT[0]}" "${CP_COMMITS[*]}"

0 comments on commit d168425

Please sign in to comment.