-
Notifications
You must be signed in to change notification settings - Fork 502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing shellcheck warnings in prin #763
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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) | ||
|
@@ -121,7 +123,7 @@ show_tags () { | |
############################################################################### | ||
# Stubbed out | ||
security_layer::hosted_map () { | ||
logecho "Skipping $FUNCNAME extensions..." | ||
logecho "Skipping ${FUNCNAME[0]} extensions..." | ||
return 0 | ||
} | ||
|
||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pswica, here I met this error when used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks so much for catching. No this was my bad. I messed up by putting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR here |
||
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[*]}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a good chance this should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks a lot for reading these. I'm sure there is a lot of hidden bugs/weirdness from my shellcheck changes. I will create an issue and link this, and other things found, to it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a good chance this should be
"$@"
instead, ref: https://github.com/koalaman/shellcheck/wiki/SC2086#exceptions