Skip to content

Commit

Permalink
Add src and dst repo list paging support
Browse files Browse the repository at this point in the history
  • Loading branch information
Yikun authored Oct 27, 2020
1 parent f8921e1 commit 842184a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ fi
function get_all_repo_names
{
PAGE_NUM=100
if [[ "$SRC_TYPE" == "github" ]]; then
total=`curl -sI "$SRC_REPO_LIST_API?page=1&per_page=$PAGE_NUM" | sed -nr "s/^[lL]ink:.*page=([0-9]+)&per_page=$PAGE_NUM.*/\1/p"`
elif [[ "$SRC_TYPE" == "gitee" ]]; then
total=`curl -sI "$SRC_REPO_LIST_API?page=1&per_page=$PAGE_NUM" | grep total_page: |cut -d ' ' -f2 |tr -d '\r'`
URL=$1
HUB_TYPE=$2
if [[ "$HUB_TYPE" == "github" ]]; then
total=`curl -sI "$URL?page=1&per_page=$PAGE_NUM" | sed -nr "s/^[lL]ink:.*page=([0-9]+)&per_page=$PAGE_NUM.*/\1/p"`
elif [[ "$HUB_TYPE" == "gitee" ]]; then
total=`curl -sI "$URL?page=1&per_page=$PAGE_NUM" | grep total_page: |cut -d ' ' -f2 |tr -d '\r'`
fi

# use pagination?
Expand All @@ -92,14 +94,14 @@ function get_all_repo_names

p=1
while [ "$p" -le "$total" ]; do
x=`curl -s "$SRC_REPO_LIST_API?page=$p&per_page=$PAGE_NUM" | jq '.[] | .name' | sed 's/"//g'`
x=`curl -s "$URL?page=$p&per_page=$PAGE_NUM" | jq '.[] | .name' | sed 's/"//g'`
echo $x
p=$(($p + 1))
done
}

if [[ -z $STATIC_LIST ]]; then
SRC_REPOS=`get_all_repo_names`
SRC_REPOS=`get_all_repo_names $SRC_REPO_LIST_API $SRC_TYPE`
else
SRC_REPOS=`echo $STATIC_LIST | tr ',' ' '`
fi
Expand Down

0 comments on commit 842184a

Please sign in to comment.