Add a flag to give an exit code if there are still pages left for repos ls? #498

Open
opened 2022-08-27 17:18:14 +00:00 by dmoonfire · 1 comment

I have a number of processes that pull in all the repositories of a given organization (website generation, ebook, some metadata processing). I'm using tea to download the repositories as part of a CI/CD pipeline without having to remember what is in the repository. In effect, using the organization's repository list as the source of truth.

However, because tea repos ls --limit 200 doesn't really return 200 entries, I would like some ability to determine if there is more data available. At the moment, I'm just fudging the page count with this:

for p in 1 2 3 4 5 6 7 8 9 10
do
  for i in $(tea repos ls --login mfgames --page $p --output simple | grep fedran-sources | cut -f 4 -d ' ')
  do
    echo magic happens
  done
done

It would be nice if there was some way of knowing that there is more pages so I can change it from an arbitrary number of pages to always grabbing only the needed amount.

At the moment, exit codes seem to be a useful manner of doing that but today's code returns 0 for a page retrieval, so to use an exit code might include --more-pages-exit-code 2 or something like that? Or another mechanism that would let me know how many pages I need to retrieve.

Thank you.

I have a number of processes that pull in all the repositories of a given organization (website generation, ebook, some metadata processing). I'm using `tea` to download the repositories as part of a CI/CD pipeline without having to remember *what* is in the repository. In effect, using the organization's repository list as the source of truth. However, because `tea repos ls --limit 200` doesn't really return 200 entries, I would like some ability to determine if there is more data available. At the moment, I'm just fudging the page count with this: ```shell for p in 1 2 3 4 5 6 7 8 9 10 do for i in $(tea repos ls --login mfgames --page $p --output simple | grep fedran-sources | cut -f 4 -d ' ') do echo magic happens done done ``` It would be nice if there was some way of knowing that there is more pages so I can change it from an arbitrary number of pages to always grabbing only the needed amount. At the moment, exit codes seem to be a useful manner of doing that but today's code returns `0` for a page retrieval, so to use an exit code might include `--more-pages-exit-code 2` or something like that? Or another mechanism that would let me know how many pages I need to retrieve. Thank you.
Member
  1. You don't get 200 results, because you can't query arbitrary page sizes. the maximum is configured server side and can be queried at /api/v1/settings/api. Maybe tea should provide a helper for that.

  2. I'm not a fan of the exit code as notification channel for this - people may run tea in scripts with set -e, halting the script in that case.
    Maybe something like more results - listing 10-20 of 50 could be emitted on stderr? This solution would depend on #456

1. You don't get 200 results, because you can't query arbitrary page sizes. the maximum is configured server side and can be queried at `/api/v1/settings/api`. Maybe tea should provide a helper for that. 2. I'm not a fan of the exit code as notification channel for this - people may run tea in scripts with `set -e`, halting the script in that case. Maybe something like `more results - listing 10-20 of 50` could be emitted on stderr? This solution would depend on #456
noerw added the
kind
enhancement
kind/proposal
labels 2022-09-13 15:17:38 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gitea/tea#498
No description provided.