Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh repo list #642

Closed
tammersaleh opened this issue Mar 12, 2020 · 23 comments · Fixed by #2953
Closed

gh repo list #642

tammersaleh opened this issue Mar 12, 2020 · 23 comments · Fixed by #2953
Labels
enhancement a request to improve CLI help wanted Contributions welcome

Comments

@tammersaleh
Copy link

tammersaleh commented Mar 12, 2020

I often wish I had a way of listing the repositories for an org.


Edited by maintainers:
The UI specification is here: https://docs.google.com/document/d/1QoktdMTS8FEXYLH_1WvzZe_OoGV_ZiTxf0c3QVF1soY/edit#

We're happy to accept contributions for this feature ✨ If you're interested in working on this please comment as such so it can be assigned to you.

@tammersaleh tammersaleh added the enhancement a request to improve CLI label Mar 12, 2020
@mislav
Copy link
Contributor

mislav commented Mar 13, 2020

👋 Thanks for the feature idea!

Do you think it might be useful to output the list of repositories in ORG/REPO format? The ORG/ part would seem repetitive, of course, but since the repository is passed around as argument to most CLI commands in ORG/REPO format, it might be useful to keep the output consistent in case somebody is going to pipe the lines to a script. 🤔

@sibis
Copy link
Contributor

sibis commented Mar 13, 2020

+1 for ORG/REPO format to follow the consistency.

@tammersaleh
Copy link
Author

Yeah, that would be better!

@sibis
Copy link
Contributor

sibis commented Mar 13, 2020

@mislav I am interested in working on this issue. Can I take up this?

@mislav
Copy link
Contributor

mislav commented Mar 13, 2020

@sibis Not yet. We're still open for feedback about which kinds of repo filtering options will be necessary, but when we do greenlight this feature for development, it will be after our design person @ampinsk has taken a pass on this and the related set of features.

@jonchurch
Copy link

jonchurch commented Apr 5, 2020

I came here looking for this feature.

My usecase:

I'm working with the Express project, which is fairly unique in that we have many packages spread out across three different orgs expressjs, pillarjs, jshttp.

I want to get a list of every repo in each org, so I can make filters for my GH notifications. I typically have used other tools or the API to get these lists in the past. Specifically for the notifications filters, I'm creating a list of repos in the format expressjs/body-parser. The output format of the command is really not super important to me, since I can just alter it with sed or awk later. As long as I can get a clean list of repo names to stdout, I'd be happy.

But what I want right now is to be able to output the list of repos, sort of like:

gh repo list --org expressjs > expressjs.txt

I think we're unique in our use of multiple orgs, but an org command would make sense to me bc I think about orgs a lot as a result of this quirk of ours. I'd be happy with the above command, however.

bdpiprava added a commit to bdpiprava/cli that referenced this issue Apr 24, 2020
This is an initial draf to support list command. The idea is to have
a common list command for the repos, orgs etc..

- List repositories with default limit
```bash
$ gh list repo // list repos of the logged in user(Defaults to 30 repos)

Showing 30 of 173 repositories.

bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bdpiparva/ansible-gocd
...
```

- List repositories with custom limit

```bash
$ gh list repo -L 10 // You can set the custom limit for the page.

Showing 10 of 173 repositories.

bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bdpiparva/ansible-gocd
...
```

- Print raw result for scripting

```bash
$ gh list repo --raw
bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bapiparva/ansible-gocd
...
```

- List repositories for a organization

```bash
$ gh list repo --org Area51

//Output
```

**NOTE:** Related issue(s) for the PR: cli#642, cli#645

- [ ] Add support to list organization for the loggedin user

```bash
$ gh list org
bdpiprava added a commit to bdpiprava/cli that referenced this issue Apr 24, 2020
This is an initial draf to support list command. The idea is to have
a common list command for the repos, orgs etc..

- List repositories with default limit
```bash
$ gh list repo // list repos of the logged in user(Defaults to 30 repos)

Showing 30 of 173 repositories.

bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bdpiparva/ansible-gocd
...
```

- List repositories with custom limit

```bash
$ gh list repo -L 10 // You can set the custom limit for the page.

Showing 10 of 173 repositories.

bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bdpiparva/ansible-gocd
...
```

- Print raw result for scripting

```bash
$ gh list repo --raw
bdpiparva/deb-repo-query
bdpiparva/deb-repo-poller
bapiparva/ansible-gocd
...
```

- List repositories for a organization

```bash
$ gh list repo --org Area51

//Output
```

**NOTE:** Related issue(s) for the PR: cli#642, cli#645

 ## TODO

- [ ] Add support to list organization for the loggedin user

```bash
$ gh list org
@vilmibm vilmibm changed the title gh repos list gh repo list May 13, 2020
@ampinsk ampinsk added the repo label Jul 14, 2020
@adimyth
Copy link

adimyth commented Sep 16, 2020

Any updates on this feature?

@mislav
Copy link
Contributor

mislav commented Sep 16, 2020

@adimyth No, but you can query the list of repositories using gh api. Here's an example alias you can set up:

# ~/.config/gh/config.yml
aliases:
    repos: |
        !gh api --paginate graphql -f owner="$1" -f query='
          query($owner: String!, $per_page: Int = 100, $endCursor: String) {
            repositoryOwner(login: $owner) {
              repositories(first: $per_page, after: $endCursor, ownerAffiliations: OWNER) {
                nodes { nameWithOwner }
                pageInfo { hasNextPage endCursor }
              }
            }
          }
        ' | jq -r '.data.repositoryOwner.repositories.nodes[].nameWithOwner' | sort

Usage:

$ gh repos cli

@Kilo-Loco
Copy link

The solution provided by @mislav works great but you should be aware of two things:

  1. You may want to use !gh instead of !hub if you dont have hub as an alias for the GitHub CLI
  2. jq needs to be installed on your machine which you can find here: https://stedolan.github.io/jq/

@mislav
Copy link
Contributor

mislav commented Sep 18, 2020

@Kilo-Loco Haha whoops 🙈

@vilmibm vilmibm removed the repo label Sep 29, 2020
@wimglenn
Copy link

wimglenn commented Oct 5, 2020

I'd also like the option to filter on/without forks

@vilmibm vilmibm added the needs-design An engineering task needs design to proceed label Oct 7, 2020
@Artofaj
Copy link

Artofaj commented Nov 10, 2020

Came here looking for exactly this feature. The workaround is great, but having it implemented by default would be way nicer!

@ampinsk
Copy link
Contributor

ampinsk commented Nov 25, 2020

Hey everyone, playing with some ideas for how this command could display

Screen Shot 2020-11-25 at 10 59 52 AM

This is pretty minimal on info, is there any other information that would be important to see from this view? Is separating out Pinned repos helpful or just noise?

@notquiteamonad
Copy link

That list looks good to me - minimal is appealing in a CLI imo.

Pins are probably good to separate on larger orgs but not so important for smaller ones. Perhaps one unbroken list with an asterisk for pins and keeping them at the top of the list or something similar would please both sides?

@pletnes
Copy link

pletnes commented Dec 1, 2020

@ampinsk I'd like something that's "one line one record" - i.e. will fit into grep/awk/...

$ gh repo list orgname

orgname/foo-web
orgname/bar-desktop
orgname/ham-spam-eggs

Now I can do

$ gh repo list orgname | grep -i web
orgname/foo-web

@abacao
Copy link

abacao commented Dec 15, 2020

Can we have a way to search specific topics also?

gh repo list orgname --topic my_search_topic

@vilmibm vilmibm added help wanted Contributions welcome and removed needs-design An engineering task needs design to proceed labels Feb 1, 2021
@vilmibm
Copy link
Contributor

vilmibm commented Feb 1, 2021

Just updated the body with UI spec and marked as help wanted.

@cristiand391
Copy link
Contributor

I would like to take this up ✋🏾

@vilmibm
Copy link
Contributor

vilmibm commented Feb 3, 2021

thanks, @cristiand391 . post here if you have questions.

@AlonGluz
Copy link

AlonGluz commented Feb 3, 2021

Any updates on this?

@stuartro
Copy link

I too am—eagerly—awaiting --list

@ksandvik
Copy link

Any updates, this was the first thing I expected glab to have, to get a list of all the gitlab repos I have?

@samcoe
Copy link
Contributor

samcoe commented Mar 24, 2021

@ksandvik This feature was merged and released in the latest version 1.7.0. Additionally this repo is for the GitHub CLI tool (gh) and does not have any affiliation with glab or GitLab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a request to improve CLI help wanted Contributions welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.