You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've built a cli app named gh-label using Go. It helps you export and generate issue labels. It uses json files to hold label list. I also add a few starter label list to use.
If the maintainers are okay with this feature, I'm willing to implement this feature.
NOTE: I hope I can implement it.
Additional context
I made a tool called labman which handles cloning labels between repos. Should be a great reference!
I do have a CLI lying around as well for labels. It actually offers a command to register gh aliases: https://github.com/SirWindfield/gh-labels-cli. You can simply run gh-labels integration install and the alias gets registered.
I mostly use it in two scenarios:
Create repo-specific labels. You can define template colors inside the label definition file (LDF) and create labels based on those. I linked my LDF inside the repo's readme. If I want to create a new label (for example for a new package insdie a monorepo), I usually run gh labels create --template component --name ....
To bulk-create a standard set of labels during repo creation. I created a custom alias that invokes the CLI after initializing a new repository using gh:
$ gh alias set -s new 'gh repo create $1; cd $1; gh labels update --purge'
- Adding alias for new: gh repo create $1; cd $1; gh labels update --purge
The command deletes all labels inside a repository (--purge) and creates all labels defined inside your LDF.
Take a look at the README file for more about the LDF and where to place it :) Hopefully this is as useful for others as it is to me :)
As an organization owner (of several actually) I'd like to be able to standardize labels across the repositories in my organizations.
To facilitate that, it'd be nice if there was a way to apply the actions against all repositories in an organization; by default though it should work on a specified repository since GitHub doesn't have organization level labels.
Instead of cloning, perhaps consider an export and import command which, on their own, could also be useful. Perhaps someone wants to import a bunch of labels via CSV or TSV, like managed in Excel.
For that currently, I have the heaths/gh-label extension and, @vilmibm, if interested could add those in a separate PR.
The REST and GraphQL APIs do not support an upsert, which is why in https://github.com/heaths/gh-label I first try a create and, if that fails, update. IMO, the gh label create command should do the same.
@mishabruml I think it would be best to open up new issues for continued label work.
I agree that the error message could be better for when a label already exists, that should be a fairly easy fix.
I am not sure I understand the use case for viewing a label when we already have the label list command which shows the title, color, and description of every label in a repo.
@heaths The label import/export command ideas are a good one, it seems like they would function as a more generic form of a label clone command that works between two repos. My question would be do we actually need a more generic form? Or is one simplified command, label clone, a more streamlined approach that covers the majority of cases that users will want? Personally, I feel more value would be created with the label clone command as I don't have a good sense of where someone might want to import/export repo labels to except to another repo.
@samcoe for my extension I decided on import/export mainly because of the issues - especially for extensions - off authenticating against repos. Apart from the -R command line switch, which supports optional enterprises, optional orgs (assumes your username otherwise), and repo name, there are environment variables which can be used for the source repo. All of that - and not sure how that would work for env vars - would probably have to be replicated for the target repo for a clone.
Export on its own could also be useful, as you could dump to a csv/tsv, open it in Excel or similar, and make modifications, then re-import into the same repo in bulk.
Speaking of which, because there are no bulk or bulk-friendly operations for labels in the GitHub REST or GraphQL APIs, is why both my create and import subcommands try to do an upsert. While some may argue a single label create command doesn't need an upsert, a label clone or label import definitely should because the target repo may have some, but not all, labels you want to clone/import.
I created my extension, for example, to help unify the Azure SDK repos that we use the same labels across all them. The colors themselves are also import to match exactly, since we have bots that may do different actions based on the colors e.g., we have a single color we use to represent all the different services we currently support. But it's not uncommon that those repos will have some labels and not all, and even if they do have the same label name we also want to make sure it's been updated (e.g., same color) from the source repo.
Ideally, the service supports an upsert for labels since it'd be faster and easier than two network calls, but it's still achievable by a create + update, if necessary.
@heaths Thanks for the explanation. Seems like going with a single label clone command would be sufficient to start. I agree that it should support some sort of --overwrite flag that will do the upsert operation, but I would be hesitant to have that be the default behavior and would rather see the user have to opt in to a potentially destructive operation.
How would you feel about a --force switch intead? More common, or do you feel it's too vague in this case? Personally - though I've seen the same gripe from others, though anecdotal at best - I get a little annoyed when CLIs have similar commands with different names. For example, on Windows we have deployment managers like choco, scoop, winget, etc., that use either upgrade or update verbs for upgrades. There's also switches that are similar but different. It's always a guessing game to remember which verb/param I use in which context. Ergo, using --force to force overwriting would be nice.
And is clone something someone is already working on, or are you looking for help?
@heaths I don't have strong feelings about --overwrite and I think --force would also be suitable as long as the flag description appropriately describes the behavior.
I opened up #5441 for the label clone work and marked it as "help wanted" if you would like to pick it up.
I see the comment about "why not just use list". List with search can be used, but use it and it quickly becomes clear why this is not very ergonomic:
gh label list --search REDACTED
Showing 30 of 174 labels in redacted
NAME DESCRIPTION COLOR
... 30 labels are listed
So it spams the screen. Try to fix with --limit 1:
gh label list --search REDACTED --limit 1
Showing 30 of 174 labels in redacted
NAME DESCRIPTION COLOR
... 1 label is listed
Now it provides just one label BUT one needs to look carefully, because if the requested label doesn't exist, the closest entry will be listed. This invites errors.
Activity
EmilyGraceSeville7cf commentedon Apr 14, 2020
Please also facilitate label assignment to issues/pull requests perhaps as:
erdaltsksn commentedon Jul 21, 2020
I've built a cli app named gh-label using Go. It helps you export and generate issue labels. It uses
jsonfiles to hold label list. I also add a few starter label list to use.If the maintainers are okay with this feature, I'm willing to implement this feature.
NOTE: I hope I can implement it.
mainrs commentedon Mar 17, 2021
I do have a CLI lying around as well for labels. It actually offers a command to register
ghaliases: https://github.com/SirWindfield/gh-labels-cli. You can simply rungh-labels integration installand the alias gets registered.I mostly use it in two scenarios:
gh labels create --template component --name ....gh:The command deletes all labels inside a repository (
--purge) and creates all labels defined inside your LDF.Take a look at the README file for more about the LDF and where to place it :) Hopefully this is as useful for others as it is to me :)
BenjamenMeyer commentedon Apr 21, 2021
As an organization owner (of several actually) I'd like to be able to standardize labels across the repositories in my organizations.
To facilitate that, it'd be nice if there was a way to apply the actions against all repositories in an organization; by default though it should work on a specified repository since GitHub doesn't have organization level labels.
BenjamenMeyer commentedon Apr 21, 2021
There should also be a separate command to delete a specified label.
Corfucinas commentedon Feb 1, 2022
Definitely something that I'm looking forward to be implemented
vilmibm commentedon Feb 14, 2022
We're opening this up for help wanted as we'd be happy to merge it into core (or check out an extension that could be merged).
The UX outlined above is a good start with the following amendments/clarifications:
gh label clonefor nowgh label createand no color is specified,ghshould select a random color from the palette:heaths commentedon Mar 30, 2022
Instead of cloning, perhaps consider an
exportandimportcommand which, on their own, could also be useful. Perhaps someone wants to import a bunch of labels via CSV or TSV, like managed in Excel.For that currently, I have the heaths/gh-label extension and, @vilmibm, if interested could add those in a separate PR.
mishabruml commentedon Apr 5, 2022
Hey, would love if the feature here #2196 was addressed. I just tried out creating a label that already exists i.e.
gh label create testand gotIMO gh cli should create if not exist already, or exit gracefully if already exist
Should I use this issue to track feature requests against the
gh labelcommand or open a new one?Another feature I think would be useful is listing/viewing specific labels e.g.
gh label view test, similar to thegh pr view 123behaviour.heaths commentedon Apr 5, 2022
The REST and GraphQL APIs do not support an upsert, which is why in https://github.com/heaths/gh-label I first try a create and, if that fails, update. IMO, the
gh label createcommand should do the same.samcoe commentedon Apr 7, 2022
@mishabruml I think it would be best to open up new issues for continued label work.
I agree that the error message could be better for when a label already exists, that should be a fairly easy fix.
I am not sure I understand the use case for viewing a label when we already have the
label listcommand which shows the title, color, and description of every label in a repo.@heaths The
label import/exportcommand ideas are a good one, it seems like they would function as a more generic form of alabel clonecommand that works between two repos. My question would be do we actually need a more generic form? Or is one simplified command,label clone, a more streamlined approach that covers the majority of cases that users will want? Personally, I feel more value would be created with thelabel clonecommand as I don't have a good sense of where someone might want to import/export repo labels to except to another repo.heaths commentedon Apr 7, 2022
@samcoe for my extension I decided on import/export mainly because of the issues - especially for extensions - off authenticating against repos. Apart from the
-Rcommand line switch, which supports optional enterprises, optional orgs (assumes your username otherwise), and repo name, there are environment variables which can be used for the source repo. All of that - and not sure how that would work for env vars - would probably have to be replicated for the target repo for aclone.Export on its own could also be useful, as you could dump to a csv/tsv, open it in Excel or similar, and make modifications, then re-import into the same repo in bulk.
Speaking of which, because there are no bulk or bulk-friendly operations for labels in the GitHub REST or GraphQL APIs, is why both my
createandimportsubcommands try to do an upsert. While some may argue a singlelabel createcommand doesn't need an upsert, alabel cloneorlabel importdefinitely should because the target repo may have some, but not all, labels you want to clone/import.I created my extension, for example, to help unify the Azure SDK repos that we use the same labels across all them. The colors themselves are also import to match exactly, since we have bots that may do different actions based on the colors e.g., we have a single color we use to represent all the different services we currently support. But it's not uncommon that those repos will have some labels and not all, and even if they do have the same label name we also want to make sure it's been updated (e.g., same color) from the source repo.
Ideally, the service supports an upsert for labels since it'd be faster and easier than two network calls, but it's still achievable by a create + update, if necessary.
samcoe commentedon Apr 11, 2022
@heaths Thanks for the explanation. Seems like going with a single
label clonecommand would be sufficient to start. I agree that it should support some sort of--overwriteflag that will do the upsert operation, but I would be hesitant to have that be the default behavior and would rather see the user have to opt in to a potentially destructive operation.heaths commentedon Apr 11, 2022
How would you feel about a
--forceswitch intead? More common, or do you feel it's too vague in this case? Personally - though I've seen the same gripe from others, though anecdotal at best - I get a little annoyed when CLIs have similar commands with different names. For example, on Windows we have deployment managers likechoco,scoop,winget, etc., that use eitherupgradeorupdateverbs for upgrades. There's also switches that are similar but different. It's always a guessing game to remember which verb/param I use in which context. Ergo, using--forceto force overwriting would be nice.And is
clonesomething someone is already working on, or are you looking for help?samcoe commentedon Apr 11, 2022
@heaths I don't have strong feelings about
--overwriteand I think--forcewould also be suitable as long as the flag description appropriately describes the behavior.I opened up #5441 for the
label clonework and marked it as "help wanted" if you would like to pick it up.bitdivine commentedon Mar 11, 2025
+1 for
gh label viewI see the comment about "why not just use list". List with search can be used, but use it and it quickly becomes clear why this is not very ergonomic:
So it spams the screen. Try to fix with
--limit 1:Now it provides just one label BUT one needs to look carefully, because if the requested label doesn't exist, the closest entry will be listed. This invites errors.
feat: redact content from a message in a session (cli#446)
auto compare and clone labels
auto compare and clone labels