Script 'schedule': reduce amounts of 'sed' invocation.
This commit is contained in:
parent
2b877bf7c4
commit
2acfb94611
12
schedule
12
schedule
@ -57,11 +57,11 @@ function setup_repo {
|
|||||||
if [[ $REPO_DIR =~ ^https://github\.com/(.*) ]]; then
|
if [[ $REPO_DIR =~ ^https://github\.com/(.*) ]]; then
|
||||||
REPO_API="https://api.github.com/repos/${BASH_REMATCH[1]}/contents"
|
REPO_API="https://api.github.com/repos/${BASH_REMATCH[1]}/contents"
|
||||||
local year=$(curl $CURL_OPTS $REPO_API \
|
local year=$(curl $CURL_OPTS $REPO_API \
|
||||||
| sed -En "/\"path\":/h;/\"type\": \"dir\"/{g;p;}" \
|
| sed -En "/\"path\":/h;/\"type\": \"dir\"/ \
|
||||||
| sed -En "s|.*\"([0-9]{4})\".*|\1|p" | tail -1)
|
{g;s|.*\"([0-9]{4})\".*|\1|p;}" | tail -1)
|
||||||
TOURNAMENT=$(curl $CURL_OPTS ${REPO_API}/${year} \
|
TOURNAMENT=$(curl $CURL_OPTS ${REPO_API}/${year} \
|
||||||
| sed -En "/\"path\":/h;/\"type\": \"dir\"/{g;p;}" \
|
| sed -En "/\"path\":/h;/\"type\": \"dir\"/ \
|
||||||
| sed -En "s|.*\"(${year}/[0-9]-.*)\".*|\1|p" | tail -1)
|
{g;s|.*\"(${year}/[0-9]-.*)\".*|\1|p;}" | tail -1)
|
||||||
|
|
||||||
REPO_URL="${REPO_DIR}/raw/master"
|
REPO_URL="${REPO_DIR}/raw/master"
|
||||||
else
|
else
|
||||||
@ -86,8 +86,8 @@ function show_tour_sequence {
|
|||||||
if [[ -z $tour_seq ]]; then
|
if [[ -z $tour_seq ]]; then
|
||||||
if [[ $REPO_DIR =~ ^https://github\.com/ ]]; then
|
if [[ $REPO_DIR =~ ^https://github\.com/ ]]; then
|
||||||
tour_seq=$(curl $CURL_OPTS ${REPO_API}/${TOURNAMENT}/tours \
|
tour_seq=$(curl $CURL_OPTS ${REPO_API}/${TOURNAMENT}/tours \
|
||||||
| sed -En "/\"path\":/h;/\"type\": \"dir\"/{g;p;}" \
|
| sed -En "/\"path\":/h;/\"type\": \"dir\"/ \
|
||||||
| sed -En "s|.*\"${TOURNAMENT}/tours/([0-9]{2})\".*|\1|p")
|
{g;s|.*\"${TOURNAMENT}/tours/([0-9]{2})\".*|\1|p;}")
|
||||||
else
|
else
|
||||||
tour_seq=$(ls -1 -d ${REPO_DIR}/${TOURNAMENT}/tours/[0-9][0-9]/ \
|
tour_seq=$(ls -1 -d ${REPO_DIR}/${TOURNAMENT}/tours/[0-9][0-9]/ \
|
||||||
| sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|")
|
| sed -E "s|${REPO_DIR}/${TOURNAMENT}/tours/([0-9]{2})/|\1|")
|
||||||
|
Loading…
Reference in New Issue
Block a user