How to list all issues of a github repository with all assignees

109 Views Asked by At

I use gh command to list and print all issues to a CSV file, but I can't get the all assignees also.

The complete command I use:

gh issue list --limit 1000 --state all | tr '\t' ',' > issues.csv
2

There are 2 best solutions below

0
Benjamin W. On BEST ANSWER

Since the default output contains comma-separated labels and one issue can have more than one label, your approach (converting all tabs to commas) can result in a malformed CSV output. To fix just that, you could use a CSV-aware tool such as xsv:

gh issue list --state all | xsv fmt -d '\t' > issues.csv

This properly quotes fields containing a comma.

Now, to get assignees as well, you can use the --json flag that lets you select which fields you want in the response, and --jq to massage the JSON response into CSV format.

For example, to get number, state, title, timestamp of the last update, labels, and assignees:

gh issue list --state all \
    --json number,state,title,labels,updatedAt,assignees \
    --jq '
        map([
            .number,
            .state,
            .title,
            .updatedAt,
            (.labels | map(.name) | join(",")),
            (.assignees | map(.login) | join(","))
        ])[]
        | @csv
    '
1
Joe On

If there are a lot of issues, need to use -L to get more than 30 issues.