Skip to content

Commit

Permalink
Filter incoming strings
Browse files Browse the repository at this point in the history
  • Loading branch information
wesley-dean-gsa committed Aug 22, 2024
1 parent 87bd87d commit 0be7e6c
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions bin/has_newer_commits.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ build_url() {
echo "https://api.github.com/repos/${repo}/branches/${branch}"
}

a="${1?Error: two owner/repo@branch values must be provided (0 were)}"
b="${2?Error: two owner/repo@branch values must be provided (1 was)}"

if [ "$(compare_dates "$a" "$b")" == "true" ] ; then
exit 0
else
exit 1
fi
filter_branch_string() {
string="${1:-}"

echo "$string" | tr -cd '[:alnum:]\/\-\_\.\@'
}

raw_a="${1?Error: two owner/repo@branch values must be provided (0 were)}"
raw_b="${2?Error: two owner/repo@branch values must be provided (1 was)}"

a="$(filter_branch_string "$raw_a")"
b="$(filter_branch_string "$raw_b")"

[ "$(compare_dates "$a" "$b")" == "true" ]

0 comments on commit 0be7e6c

Please sign in to comment.