Skip to content

tnagatomi/gh-fuda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

252 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gh-fuda

gh-fuda is a gh extension which extends label manipulations.

Installation

Install as a gh extension (ref. gh manual of gh extension install).

gh extension install tnagatomi/gh-fuda

Usage

Login to GitHub with gh auth login (ref. gh manual of gh auth login) so that the extension can access the repositories.

Global Options

  • -R, --repos: Select repositories using the OWNER/REPO format separated by comma (e.g., owner1/repo1,owner2/repo1)
  • --dry-run: Check what operations would be executed without actually operating on the repositories
  • -v, --version: Print the installed extension version and exit (also available as the version subcommand)

List of Commands

List Labels

gh fuda list

List existing labels from the specified repositories.

Example
gh fuda list -R "owner1/repo1,owner1/repo2,owner2/repo1"

Create Labels

gh fuda create

Create specified labels to the specified repositories.

Options
  • -l, --labels: Specify the labels to create (see Label Format below)
  • --json: Specify the path to a JSON file containing labels to create
  • --yaml: Specify the path to a YAML file containing labels to create
  • -f, --force: Update the label color and description if label already exists

Note: --json, --yaml, and -l/--labels flags are mutually exclusive. You must use exactly one of these options.

Example
# Using inline labels
gh fuda create -R "owner1/repo1,owner1/repo2,owner2/repo1" -l "bug,feature:a2eeef,enhancement:00ff00:New feature"

# Using JSON file
gh fuda create -R "owner1/repo1,owner1/repo2,owner2/repo1" --json labels.json

# Using YAML file
gh fuda create -R "owner1/repo1,owner1/repo2,owner2/repo1" --yaml labels.yaml
Label Format

The --labels flag supports the following formats:

  • name - Name only (color is auto-generated)
  • name:color - Name and color
  • name:color:description - Name, color, and description
  • name::description - Name and description (color is auto-generated)

Color Auto-Generation: When color is omitted, it is automatically generated from the label name using a hash function. The same label name always produces the same color.

JSON File Format

The color field is optional. If omitted or empty, color is auto-generated.

[
  {
    "name": "bug",
    "description": "Something isn't working"
  },
  {
    "name": "enhancement",
    "color": "a2eeef",
    "description": "New feature or request"
  },
  {
    "name": "documentation",
    "color": "07c",
    "description": "Improvements or additions to documentation"
  }
]
YAML File Format

The color field is optional. If omitted or empty, color is auto-generated.

- name: bug
  description: Something isn't working
- name: enhancement
  color: a2eeef
  description: New feature or request
- name: documentation
  color: 07c
  description: Improvements or additions to documentation

Delete Labels

gh fuda delete

Delete specified labels from the specified repositories.

Options
  • -l, --labels: Specify the labels to delete in the format of 'label1[,label2,...]'
  • -y, --yes: Do not prompt for confirmation
Example
gh fuda delete -R "owner1/repo1,owner1/repo2,owner2/repo1" -l "label1,label2,label3"

Sync Labels

gh fuda sync

Sync the labels in the specified repositories with the specified labels.

Options
  • -l, --labels: Specify the labels to set (see Label Format in Create Labels section)
  • --json: Specify the path to a JSON file containing labels to sync
  • --yaml: Specify the path to a YAML file containing labels to sync
  • -y, --yes: Do not prompt for confirmation

Note: --json, --yaml, and -l/--labels flags are mutually exclusive. You must use exactly one of these options.

Example
# Using inline labels
gh fuda sync -R "owner1/repo1,owner1/repo2,owner2/repo1" -l "bug,feature:a2eeef,enhancement:00ff00:New feature"

# Using JSON file
gh fuda sync -R "owner1/repo1,owner1/repo2,owner2/repo1" --json labels.json

# Using YAML file
gh fuda sync -R "owner1/repo1,owner1/repo2,owner2/repo1" --yaml labels.yaml
File Formats

The JSON and YAML file formats are the same as those used for the create command. See the Create Labels section for details.

Empty Labels

gh fuda empty

Delete all labels from the specified repositories.

Options
  • -y, --yes: Do not prompt for confirmation
Example
gh fuda empty -R "owner1/repo1,owner1/repo2,owner2/repo1"

Merge Labels

gh fuda merge

Merge a source label into a target label across repositories. This command:

  1. Adds the target label to all issues, PRs, and discussions that have the source label
  2. Removes the source label from those items
  3. Deletes the source label from the repository

Both the source (--from) and target (--to) labels must exist in each repository.

Options
  • --from: Source label to merge from (will be deleted)
  • --to: Target label to merge into
  • -y, --yes: Do not prompt for confirmation
Example
gh fuda merge -R "owner1/repo1,owner1/repo2,owner2/repo1" --from "old-bug" --to "bug"

Development

Prerequisites

  • Go 1.25.0 or later
  • gh CLI (for authentication)

Build

go build

Test

# Run unit tests
go test ./...

# Run E2E tests (requires GH_TOKEN and two empty test repositories)
GH_FUDA_TEST_REPO_1=youruser/test-repo-1 GH_FUDA_TEST_REPO_2=youruser/test-repo-2 \
  GH_TOKEN=$(gh auth token) go test -tags=e2e -v

E2E Tests

E2E tests execute actual CLI commands against real GitHub repositories. They are intended for local execution only (not run in CI).

Test Repositories:

Set GH_FUDA_TEST_REPO_1 and GH_FUDA_TEST_REPO_2 environment variables to repositories you own.

Warning

The tests will create, delete, and empty labels in these repositories. Use dedicated empty repositories.

Lint

golangci-lint run

About

gh-fuda is a gh extension which extends label manipulations

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages